Merge with 'geppetto': Generate bytecode while parsing
This commit is contained in:
@@ -166,6 +166,11 @@ OP_CODE_DECL (b_xor, T_IDX_IDX_IDX,
|
||||
var_left,
|
||||
var_right)
|
||||
|
||||
/** dst = ~ R */
|
||||
OP_CODE_DECL (b_not, T_IDX_IDX,
|
||||
dst,
|
||||
var_right)
|
||||
|
||||
// Binary logical operators.
|
||||
// Operands are booleans.
|
||||
// Return boolean.
|
||||
@@ -182,6 +187,11 @@ OP_CODE_DECL (logical_or, T_IDX_IDX_IDX,
|
||||
var_left,
|
||||
var_right)
|
||||
|
||||
/** dst = ! R */
|
||||
OP_CODE_DECL (logical_not, T_IDX_IDX,
|
||||
dst,
|
||||
var_right)
|
||||
|
||||
// Equality operations.
|
||||
|
||||
/** dst = L == R. */
|
||||
@@ -234,6 +244,18 @@ OP_CODE_DECL (greater_or_equal_than, T_IDX_IDX_IDX,
|
||||
var_left,
|
||||
var_right)
|
||||
|
||||
/** dst = L instanceof R. */
|
||||
OP_CODE_DECL (instanceof, T_IDX_IDX_IDX,
|
||||
dst,
|
||||
var_left,
|
||||
var_right)
|
||||
|
||||
/** dst = L in R. */
|
||||
OP_CODE_DECL (in, T_IDX_IDX_IDX,
|
||||
dst,
|
||||
var_left,
|
||||
var_right)
|
||||
|
||||
// Assignment operators.
|
||||
// Assign value to LEFT operand based on value of RIGHT operand.
|
||||
|
||||
@@ -245,22 +267,43 @@ OP_CODE_DECL (assignment, T_IDX_IDX_IDX,
|
||||
|
||||
// Functions calls, declarations and argument handling
|
||||
|
||||
/** name(arg1); */
|
||||
OP_CODE_DECL (call_1, T_IDX_IDX,
|
||||
/** a = name(); */
|
||||
OP_CODE_DECL (call_0, T_IDX_IDX,
|
||||
lhs,
|
||||
name_lit_idx)
|
||||
|
||||
/** a = name(arg1); */
|
||||
OP_CODE_DECL (call_1, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
name_lit_idx,
|
||||
arg1_lit_idx)
|
||||
|
||||
/** name(arg1, arg2); */
|
||||
OP_CODE_DECL (call_2, T_IDX_IDX_IDX,
|
||||
name_lit_idx,
|
||||
arg1_lit_idx,
|
||||
arg2_lit_idx)
|
||||
|
||||
/** name(arg1, arg2, ... */
|
||||
/** a = name(arg1, ... */
|
||||
OP_CODE_DECL (call_n, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
name_lit_idx,
|
||||
arg1_lit_idx,
|
||||
arg2_lit_idx)
|
||||
arg1_lit_idx)
|
||||
|
||||
/** a = new name(); */
|
||||
OP_CODE_DECL (construct_0, T_IDX_IDX,
|
||||
lhs,
|
||||
name_lit_idx)
|
||||
|
||||
/** a = new name(arg1); */
|
||||
OP_CODE_DECL (construct_1, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
name_lit_idx,
|
||||
arg1_lit_idx)
|
||||
|
||||
/** a = new name(arg1, ... */
|
||||
OP_CODE_DECL (construct_n, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
name_lit_idx,
|
||||
arg1_lit_idx)
|
||||
|
||||
/** name(); */
|
||||
OP_CODE_DECL (func_decl_0, T_IDX,
|
||||
name_lit_idx)
|
||||
|
||||
/** name(arg1); */
|
||||
OP_CODE_DECL (func_decl_1, T_IDX_IDX,
|
||||
@@ -279,19 +322,27 @@ OP_CODE_DECL (func_decl_n, T_IDX_IDX_IDX,
|
||||
arg1_lit_idx,
|
||||
arg2_lit_idx)
|
||||
|
||||
/** ..., arg1, ... */
|
||||
OP_CODE_DECL (varg_1, T_IDX,
|
||||
/** a = name(); */
|
||||
OP_CODE_DECL (func_expr_0, T_IDX_IDX,
|
||||
lhs,
|
||||
name_lit_idx)
|
||||
|
||||
/** a = name(arg1); */
|
||||
OP_CODE_DECL (func_expr_1, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
name_lit_idx,
|
||||
arg1_lit_idx)
|
||||
|
||||
/** a = name(arg1, ... */
|
||||
OP_CODE_DECL (func_expr_n, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
name_lit_idx,
|
||||
arg1_lit_idx)
|
||||
|
||||
/** ..., arg1); */
|
||||
OP_CODE_DECL (varg_1_end, T_IDX,
|
||||
arg1_lit_idx)
|
||||
|
||||
/** ..., arg1, arg2, ... */
|
||||
OP_CODE_DECL (varg_2, T_IDX_IDX,
|
||||
arg1_lit_idx,
|
||||
arg2_lit_idx)
|
||||
|
||||
/** ..., arg1, arg2); */
|
||||
OP_CODE_DECL (varg_2_end, T_IDX_IDX,
|
||||
arg1_lit_idx,
|
||||
@@ -361,26 +412,91 @@ OP_CODE_DECL (loop_postcond, T_IDX_IDX,
|
||||
condition,
|
||||
body_root)
|
||||
|
||||
///** for vars...in iter, state, ctl */
|
||||
//OP_CODE_DECL (loop_init, T_IDX_IDX_IDX,
|
||||
// start_idx, stop_idx, step_idx)
|
||||
///** loop (condition) */
|
||||
//OP_CODE_DECL (loop_cond_pre_begin, T_IDX_IDX,
|
||||
// condition, body_root)
|
||||
///** i++;*/
|
||||
//OP_CODE_DECL (loop_cond_pre_end, T_IDX,
|
||||
// iterator, body_root)
|
||||
/** a = [] */
|
||||
OP_CODE_DECL (array_0, T_IDX,
|
||||
lhs)
|
||||
|
||||
// Property accessors (array, objects, strings)
|
||||
/** Array ops for ILMIR*/
|
||||
//OP_CODE_DECL (array_copy, T_IDX_IDX, /** L = R */
|
||||
// var_left, var_right)
|
||||
//OP_CODE_DECL (array_set, T_IDX_IDX_IDX, /** array[index] = src */
|
||||
// dst, var_left, var_right)
|
||||
//OP_CODE_DECL (array_get, T_IDX_IDX_IDX, /** dst = array[index] */
|
||||
// dst, array, index)
|
||||
/** a = [b] */
|
||||
OP_CODE_DECL (array_1, T_IDX_IDX,
|
||||
lhs,
|
||||
elem1)
|
||||
|
||||
//// TODO
|
||||
/** a = [b, c] */
|
||||
OP_CODE_DECL (array_2, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
elem1,
|
||||
elem2)
|
||||
|
||||
/** a = [b, c ... */
|
||||
OP_CODE_DECL (array_n, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
elem1,
|
||||
elem2)
|
||||
|
||||
/** a = b : c */
|
||||
OP_CODE_DECL (prop, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
name,
|
||||
value)
|
||||
|
||||
/** a = b.c OR a = b[c] */
|
||||
OP_CODE_DECL (prop_access, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
obj,
|
||||
prop)
|
||||
|
||||
/** a = get prop () */
|
||||
OP_CODE_DECL (prop_get_decl, T_IDX_IDX,
|
||||
lhs,
|
||||
prop)
|
||||
|
||||
/** a = set prop (arg) */
|
||||
OP_CODE_DECL (prop_set_decl, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
prop,
|
||||
arg)
|
||||
|
||||
/** a = { } */
|
||||
OP_CODE_DECL (obj_0, T_IDX,
|
||||
lhs)
|
||||
|
||||
/** a = { b } */
|
||||
OP_CODE_DECL (obj_1, T_IDX_IDX,
|
||||
lhs,
|
||||
arg1)
|
||||
|
||||
/** a = { b, c } */
|
||||
OP_CODE_DECL (obj_2, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
arg1,
|
||||
arg2)
|
||||
|
||||
/** a = { b, c ... */
|
||||
OP_CODE_DECL (obj_n, T_IDX_IDX_IDX,
|
||||
lhs,
|
||||
arg1,
|
||||
arg2)
|
||||
|
||||
/** a = this */
|
||||
OP_CODE_DECL (this, T_IDX,
|
||||
lhs)
|
||||
|
||||
/** a = delete b */
|
||||
OP_CODE_DECL (delete, T_IDX_IDX,
|
||||
lhs,
|
||||
obj)
|
||||
|
||||
/** a = delete b */
|
||||
OP_CODE_DECL (typeof, T_IDX_IDX,
|
||||
lhs,
|
||||
obj)
|
||||
|
||||
/** with (b) { */
|
||||
OP_CODE_DECL (with, T_IDX,
|
||||
expr)
|
||||
|
||||
/** } */
|
||||
OP_CODE_DECL_VOID (end_with)
|
||||
|
||||
// Variable declaration
|
||||
OP_CODE_DECL (var_decl, T_IDX,
|
||||
|
||||
@@ -322,14 +322,12 @@ do_number_arithmetic(struct __int_data *int_data, /**< interpreter context */
|
||||
op(loop_precond_begin_num) \
|
||||
op(loop_precond_end_num) \
|
||||
op(loop_postcond) \
|
||||
op(call_2) \
|
||||
op(call_0) \
|
||||
op(call_n) \
|
||||
op(func_decl_1) \
|
||||
op(func_decl_2) \
|
||||
op(func_decl_n) \
|
||||
op(varg_1) \
|
||||
op(varg_1_end) \
|
||||
op(varg_2) \
|
||||
op(varg_2_end) \
|
||||
op(varg_3) \
|
||||
op(varg_3_end) \
|
||||
@@ -353,7 +351,35 @@ do_number_arithmetic(struct __int_data *int_data, /**< interpreter context */
|
||||
op(greater_or_equal_than) \
|
||||
op(jmp_up) \
|
||||
op(jmp_down) \
|
||||
op(nop)
|
||||
op(nop) \
|
||||
op(construct_0) \
|
||||
op(construct_1) \
|
||||
op(construct_n) \
|
||||
op(func_decl_0) \
|
||||
op(func_expr_0) \
|
||||
op(func_expr_1) \
|
||||
op(func_expr_n) \
|
||||
op(array_0) \
|
||||
op(array_1) \
|
||||
op(array_2) \
|
||||
op(array_n) \
|
||||
op(prop) \
|
||||
op(prop_access) \
|
||||
op(prop_get_decl) \
|
||||
op(prop_set_decl) \
|
||||
op(obj_0) \
|
||||
op(obj_1) \
|
||||
op(obj_2) \
|
||||
op(obj_n) \
|
||||
op(this) \
|
||||
op(delete) \
|
||||
op(typeof) \
|
||||
op(with) \
|
||||
op(end_with) \
|
||||
op(logical_not) \
|
||||
op(b_not) \
|
||||
op(instanceof) \
|
||||
op(in)
|
||||
|
||||
#define DEFINE_UNIMPLEMENTED_OP(op) \
|
||||
ecma_CompletionValue_t opfunc_ ## op(OPCODE opdata, struct __int_data *int_data) { \
|
||||
@@ -796,15 +822,13 @@ GETOP_IMPL_3 (greater_than, dst, var_left, var_right)
|
||||
GETOP_IMPL_3 (less_or_equal_than, dst, var_left, var_right)
|
||||
GETOP_IMPL_3 (greater_or_equal_than, dst, var_left, var_right)
|
||||
GETOP_IMPL_3 (assignment, var_left, type_value_right, value_right)
|
||||
GETOP_IMPL_2 (call_1, name_lit_idx, arg1_lit_idx)
|
||||
GETOP_IMPL_3 (call_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx)
|
||||
GETOP_IMPL_3 (call_n, name_lit_idx, arg1_lit_idx, arg2_lit_idx)
|
||||
GETOP_IMPL_2 (call_0, lhs, name_lit_idx)
|
||||
GETOP_IMPL_3 (call_1, lhs, name_lit_idx, arg1_lit_idx)
|
||||
GETOP_IMPL_3 (call_n, lhs, name_lit_idx, arg1_lit_idx)
|
||||
GETOP_IMPL_2 (func_decl_1, name_lit_idx, arg1_lit_idx)
|
||||
GETOP_IMPL_3 (func_decl_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx)
|
||||
GETOP_IMPL_3 (func_decl_n, name_lit_idx, arg1_lit_idx, arg2_lit_idx)
|
||||
GETOP_IMPL_1 (varg_1, arg1_lit_idx)
|
||||
GETOP_IMPL_1 (varg_1_end, arg1_lit_idx)
|
||||
GETOP_IMPL_2 (varg_2, arg1_lit_idx, arg2_lit_idx)
|
||||
GETOP_IMPL_2 (varg_2_end, arg1_lit_idx, arg2_lit_idx)
|
||||
GETOP_IMPL_3 (varg_3, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx)
|
||||
GETOP_IMPL_3 (varg_3_end, arg1_lit_idx, arg2_lit_idx, arg3_lit_idx)
|
||||
@@ -818,4 +842,32 @@ GETOP_IMPL_2 (loop_precond_begin_num, condition, after_loop_op)
|
||||
GETOP_IMPL_3 (loop_precond_end_num, iterator, step, precond_begin)
|
||||
GETOP_IMPL_2 (loop_postcond, condition, body_root)
|
||||
GETOP_IMPL_1 (var_decl, variable_name)
|
||||
GETOP_IMPL_2 (b_not, dst, var_right)
|
||||
GETOP_IMPL_2 (logical_not, dst, var_right)
|
||||
GETOP_IMPL_3 (instanceof, dst, var_left, var_right)
|
||||
GETOP_IMPL_3 (in, dst, var_left, var_right)
|
||||
GETOP_IMPL_2 (construct_0, lhs, name_lit_idx)
|
||||
GETOP_IMPL_3 (construct_1, lhs, name_lit_idx, arg1_lit_idx)
|
||||
GETOP_IMPL_3 (construct_n, lhs, name_lit_idx, arg1_lit_idx)
|
||||
GETOP_IMPL_1 (func_decl_0, name_lit_idx)
|
||||
GETOP_IMPL_2 (func_expr_0, lhs, name_lit_idx)
|
||||
GETOP_IMPL_3 (func_expr_1, lhs, name_lit_idx, arg1_lit_idx)
|
||||
GETOP_IMPL_3 (func_expr_n, lhs, name_lit_idx, arg1_lit_idx)
|
||||
GETOP_IMPL_1 (array_0, lhs)
|
||||
GETOP_IMPL_2 (array_1, lhs, elem1)
|
||||
GETOP_IMPL_3 (array_2, lhs, elem1, elem2)
|
||||
GETOP_IMPL_3 (array_n, lhs, elem1, elem2)
|
||||
GETOP_IMPL_3 (prop, lhs, name, value)
|
||||
GETOP_IMPL_3 (prop_access, lhs, obj, prop)
|
||||
GETOP_IMPL_2 (prop_get_decl, lhs, prop)
|
||||
GETOP_IMPL_3 (prop_set_decl, lhs, prop, arg)
|
||||
GETOP_IMPL_1 (obj_0, lhs)
|
||||
GETOP_IMPL_2 (obj_1, lhs, arg1)
|
||||
GETOP_IMPL_3 (obj_2, lhs, arg1, arg2)
|
||||
GETOP_IMPL_3 (obj_n, lhs, arg1, arg2)
|
||||
GETOP_IMPL_1 (this, lhs)
|
||||
GETOP_IMPL_2 (delete, lhs, obj)
|
||||
GETOP_IMPL_2 (typeof, lhs, obj)
|
||||
GETOP_IMPL_1 (with, expr)
|
||||
GETOP_IMPL_0 (end_with)
|
||||
|
||||
|
||||
@@ -43,15 +43,20 @@ typedef ecma_CompletionValue_t (*opfunc)(OPCODE, struct __int_data *);
|
||||
op(loop_postcond)
|
||||
|
||||
#define OP_CALLS_AND_ARGS(op) \
|
||||
op(call_0) \
|
||||
op(call_1) \
|
||||
op(call_2) \
|
||||
op(call_n) \
|
||||
op(construct_0) \
|
||||
op(construct_1) \
|
||||
op(construct_n) \
|
||||
op(func_decl_0) \
|
||||
op(func_decl_1) \
|
||||
op(func_decl_2) \
|
||||
op(func_decl_n) \
|
||||
op(varg_1) \
|
||||
op(func_expr_0) \
|
||||
op(func_expr_1) \
|
||||
op(func_expr_n) \
|
||||
op(varg_1_end) \
|
||||
op(varg_2) \
|
||||
op(varg_2_end) \
|
||||
op(varg_3) \
|
||||
op(varg_3_end) \
|
||||
@@ -59,6 +64,25 @@ typedef ecma_CompletionValue_t (*opfunc)(OPCODE, struct __int_data *);
|
||||
op(retval) \
|
||||
op(ret)
|
||||
|
||||
#define OP_INITS(op) \
|
||||
op(array_0) \
|
||||
op(array_1) \
|
||||
op(array_2) \
|
||||
op(array_n) \
|
||||
op(prop) \
|
||||
op(prop_access) \
|
||||
op(prop_get_decl) \
|
||||
op(prop_set_decl) \
|
||||
op(obj_0) \
|
||||
op(obj_1) \
|
||||
op(obj_2) \
|
||||
op(obj_n) \
|
||||
op(this) \
|
||||
op(delete) \
|
||||
op(typeof) \
|
||||
op(with) \
|
||||
op(end_with)
|
||||
|
||||
#define OP_ASSIGNMENTS(op) \
|
||||
op(assignment)
|
||||
|
||||
@@ -70,11 +94,13 @@ typedef ecma_CompletionValue_t (*opfunc)(OPCODE, struct __int_data *);
|
||||
#define OP_B_BITWISE(op) \
|
||||
op(b_and) \
|
||||
op(b_or) \
|
||||
op(b_xor)
|
||||
op(b_xor) \
|
||||
op(b_not)
|
||||
|
||||
#define OP_B_LOGICAL(op) \
|
||||
op(logical_and) \
|
||||
op(logical_or)
|
||||
op(logical_or) \
|
||||
op(logical_not)
|
||||
|
||||
#define OP_EQUALITY(op) \
|
||||
op(equal_value) \
|
||||
@@ -86,7 +112,9 @@ typedef ecma_CompletionValue_t (*opfunc)(OPCODE, struct __int_data *);
|
||||
op(less_than) \
|
||||
op(greater_than) \
|
||||
op(less_or_equal_than) \
|
||||
op(greater_or_equal_than)
|
||||
op(greater_or_equal_than) \
|
||||
op(instanceof) \
|
||||
op(in)
|
||||
|
||||
#define OP_ARITHMETIC(op) \
|
||||
op(addition) \
|
||||
@@ -108,6 +136,7 @@ typedef ecma_CompletionValue_t (*opfunc)(OPCODE, struct __int_data *);
|
||||
#define OP_LIST(op) \
|
||||
OP_LOOPS(op) \
|
||||
OP_CALLS_AND_ARGS(op) \
|
||||
OP_INITS(op) \
|
||||
OP_ASSIGNMENTS(op) \
|
||||
OP_B_LOGICAL(op) \
|
||||
OP_B_BITWISE(op) \
|
||||
|
||||
Reference in New Issue
Block a user