jerryscript/tests/unit/test_addition_opcode_number_operands.c
Ilmir Usmanov e77bd4f4e5 Add try-catch-finally support: parse and generate opcodes for this construct
Fix varg generation: generate *_n opcodes with parameters in following meta opcodes
Add stack internal structure: dimanically allocated stack.
Use dynamically allocated memory in parser: every local and global variables are stored in dinamically allocated stacks.
Use dynamically allocated memory in serializer: opcodes are also stored in stack.
Change is_true_jmp and is_false_jmp opcodes to relative.
Change *jmp* opcodes to be able to store opcode_counter_t instead of idx_t.
2014-09-16 21:32:59 +04:00

57 lines
1.5 KiB
C

/* Copyright 2014 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "globals.h"
#include "interpreter.h"
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
/**
* Unit test's main function.
*/
int
main( int __unused argc,
char __unused **argv)
{
const opcode_t test_program[] = {
getop_reg_var_decl( 255, 255),
getop_var_decl( 0),
getop_var_decl( 1),
getop_assignment( 0, OPCODE_ARG_TYPE_SMALLINT, 253),
getop_assignment( 1, OPCODE_ARG_TYPE_NUMBER, 2),
getop_addition( 0, 0, 1),
getop_exitval( 0)
};
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b" };
ecma_number_t nums [] = { 2.0 };
uint16_t offset = serializer_dump_strings( strings, 2);
serializer_dump_nums( nums, 1, offset, 2);
init_int( test_program, false);
bool status = run_int();
serializer_free ();
mem_finalize (false);
return (status ? 0 : 1);
} /* main */