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.
This commit is contained in:
Ilmir Usmanov
2014-09-16 21:22:11 +04:00
parent cd41b236d9
commit e77bd4f4e5
26 changed files with 1644 additions and 1710 deletions
+17 -16
View File
@@ -28,7 +28,7 @@ main( int __unused argc,
{
const opcode_t test_program[] = {
[ 0] = getop_reg_var_decl (240, 255),
[ 1] = getop_jmp_down (2),
[ 1] = getop_jmp_down (0, 2),
[ 2] = getop_exitval (1),
/* var a, b; */
@@ -52,35 +52,35 @@ main( int __unused argc,
[14] = getop_prop_getter (240, 0, 240),
[15] = getop_assignment (241, OPCODE_ARG_TYPE_SMALLINT, 3),
[16] = getop_equal_value_type (240, 240, 241),
[17] = getop_is_false_jmp (240, 2),
[17] = getop_is_false_jmp_up (240, 0, 15),
/* assert (a[0] === 12.0); */
[18] = getop_assignment (240, OPCODE_ARG_TYPE_SMALLINT, 0),
[19] = getop_prop_getter (240, 0, 240),
[20] = getop_assignment (241, OPCODE_ARG_TYPE_NUMBER, 5),
[21] = getop_equal_value_type (240, 240, 241),
[22] = getop_is_false_jmp (240, 2),
[22] = getop_is_false_jmp_up (240, 0, 20),
/* assert (a['1'] === 'length'); */
[23] = getop_assignment (240, OPCODE_ARG_TYPE_STRING, 3),
[24] = getop_prop_getter (240, 0, 240),
[25] = getop_assignment (241, OPCODE_ARG_TYPE_STRING, 2),
[26] = getop_equal_value_type (240, 240, 241),
[27] = getop_is_false_jmp (240, 2),
[27] = getop_is_false_jmp_up (240, 0, 25),
/* assert (a[2.0] === null); */
[28] = getop_assignment (240, OPCODE_ARG_TYPE_NUMBER, 4),
[29] = getop_prop_getter (240, 0, 240),
[30] = getop_assignment (241, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_NULL),
[31] = getop_equal_value_type (240, 240, 241),
[32] = getop_is_false_jmp (240, 2),
[32] = getop_is_false_jmp_up (240, 0, 30),
/* assert (a[2.5] === undefined); */
[33] = getop_assignment (240, OPCODE_ARG_TYPE_NUMBER, 6),
[34] = getop_prop_getter (240, 0, 240),
[35] = getop_assignment (241, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_UNDEFINED),
[36] = getop_equal_value_type (240, 240, 241),
[37] = getop_is_false_jmp (240, 2),
[37] = getop_is_false_jmp_up (240, 0, 35),
/* a.length = 1; */
[38] = getop_assignment (240, OPCODE_ARG_TYPE_STRING, 2),
@@ -92,27 +92,27 @@ main( int __unused argc,
[42] = getop_prop_getter (240, 0, 240),
[43] = getop_assignment (241, OPCODE_ARG_TYPE_SMALLINT, 1),
[44] = getop_equal_value_type (240, 240, 241),
[45] = getop_is_false_jmp (240, 2),
[45] = getop_is_false_jmp_up (240, 0, 43),
/* assert (a[0] === 12.0); */
[46] = getop_assignment (240, OPCODE_ARG_TYPE_SMALLINT, 0),
[47] = getop_prop_getter (240, 0, 240),
[48] = getop_assignment (241, OPCODE_ARG_TYPE_NUMBER, 5),
[49] = getop_equal_value_type (240, 240, 241),
[50] = getop_is_false_jmp (240, 2),
[50] = getop_is_false_jmp_up (240, 0, 48),
/* assert (a['1'] === undefined); */
[51] = getop_assignment (240, OPCODE_ARG_TYPE_STRING, 3),
[52] = getop_prop_getter (240, 0, 240),
[53] = getop_assignment (241, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_UNDEFINED),
[54] = getop_equal_value_type (240, 240, 241),
[55] = getop_is_false_jmp (240, 2),
[55] = getop_is_false_jmp_up (240, 0, 53),
/* assert (a[2.0] === undefined); */
[56] = getop_assignment (240, OPCODE_ARG_TYPE_NUMBER, 4),
[57] = getop_prop_getter (240, 0, 240),
[58] = getop_equal_value_type (240, 240, 241),
[59] = getop_is_false_jmp (240, 2),
[59] = getop_is_false_jmp_up (240, 0, 57),
/* a.length = 8; */
[60] = getop_assignment (240, OPCODE_ARG_TYPE_STRING, 2),
@@ -124,7 +124,7 @@ main( int __unused argc,
[64] = getop_prop_getter (240, 0, 240),
[65] = getop_assignment (241, OPCODE_ARG_TYPE_SMALLINT, 8),
[66] = getop_equal_value_type (240, 240, 241),
[67] = getop_is_false_jmp (240, 2),
[67] = getop_is_false_jmp_up (240, 0, 65),
/* a[10] = true; */
[68] = getop_assignment (240, OPCODE_ARG_TYPE_SMALLINT, 10),
@@ -136,34 +136,34 @@ main( int __unused argc,
[72] = getop_prop_getter (240, 0, 240),
[73] = getop_assignment (241, OPCODE_ARG_TYPE_SMALLINT, 11),
[74] = getop_equal_value_type (240, 240, 241),
[75] = getop_is_false_jmp (240, 2),
[75] = getop_is_false_jmp_up (240, 0, 73),
/* assert (a[0] === 12.0); */
[76] = getop_assignment (240, OPCODE_ARG_TYPE_SMALLINT, 0),
[77] = getop_prop_getter (240, 0, 240),
[78] = getop_assignment (241, OPCODE_ARG_TYPE_NUMBER, 5),
[79] = getop_equal_value_type (240, 240, 241),
[80] = getop_is_false_jmp (240, 2),
[80] = getop_is_false_jmp_up (240, 0, 78),
/* assert (a['1'] === undefined); */
[81] = getop_assignment (240, OPCODE_ARG_TYPE_STRING, 3),
[82] = getop_prop_getter (240, 0, 240),
[83] = getop_assignment (241, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_UNDEFINED),
[84] = getop_equal_value_type (240, 240, 241),
[85] = getop_is_false_jmp (240, 2),
[85] = getop_is_false_jmp_up (240, 0, 83),
/* assert (a[2.0] === undefined); */
[86] = getop_assignment (240, OPCODE_ARG_TYPE_NUMBER, 4),
[87] = getop_prop_getter (240, 0, 240),
[88] = getop_equal_value_type (240, 240, 241),
[89] = getop_is_false_jmp (240, 2),
[89] = getop_is_false_jmp_up (240, 0, 87),
/* assert (a[17] === true); */
[90] = getop_assignment (240, OPCODE_ARG_TYPE_SMALLINT, 10),
[91] = getop_prop_getter (240, 0, 240),
[92] = getop_assignment (241, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_TRUE),
[93] = getop_equal_value_type (240, 240, 241),
[94] = getop_is_false_jmp (240, 2),
[94] = getop_is_false_jmp_up (240, 0, 92),
[95] = getop_exitval (0),
};
@@ -186,6 +186,7 @@ main( int __unused argc,
bool status = run_int();
serializer_free ();
mem_heap_print (true, false, true);
mem_finalize (false);
return (status ? 0 : 1);