fix warnings

This commit is contained in:
e.gavrin 2014-07-08 13:47:33 +04:00
parent 4255c43f4a
commit 26d0824def
2 changed files with 68 additions and 68 deletions

View File

@ -34,8 +34,8 @@ struct __int_data
int *root_op_addr; int *root_op_addr;
}; };
void gen_bytecode (); void gen_bytecode (void);
void run_int (); void run_int (void);
void run_int_from_pos (struct __int_data *); void run_int_from_pos (struct __int_data *);
#endif /* INTERPRETER_H */ #endif /* INTERPRETER_H */

View File

@ -21,11 +21,11 @@
#define OP_CODE_DECL_VOID(name) \ #define OP_CODE_DECL_VOID(name) \
struct __op_##name { }; \ struct __op_##name { T_IDX __do_not_use; }; \
OPCODE getop_##name (); OPCODE getop_##name ( void );
#define OP_CODE_DECL(name, type, ... ) \ #define OP_CODE_DECL(name, type, ... ) \
OP_DEF (name, type##_DECL( __VA_ARGS__ ) ); \ OP_DEF (name, type##_DECL( __VA_ARGS__ ) ) \
OPCODE getop_##name ( type ); OPCODE getop_##name ( type );
#define T_IDX_IDX T_IDX, T_IDX #define T_IDX_IDX T_IDX, T_IDX
@ -49,112 +49,112 @@
/** L < R */ /** L < R */
OP_CODE_DECL (is_less_than, T_IDX_IDX, OP_CODE_DECL (is_less_than, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L <= R */ /** L <= R */
OP_CODE_DECL (is_less_or_equal, T_IDX_IDX, OP_CODE_DECL (is_less_or_equal, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L > R */ /** L > R */
OP_CODE_DECL (is_greater_than, T_IDX_IDX, OP_CODE_DECL (is_greater_than, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L >= R */ /** L >= R */
OP_CODE_DECL (is_greater_or_equal, T_IDX_IDX, OP_CODE_DECL (is_greater_or_equal, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L == R */ /** L == R */
OP_CODE_DECL (is_equal_value, T_IDX_IDX, OP_CODE_DECL (is_equal_value, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L != R */ /** L != R */
OP_CODE_DECL (is_not_equal_value, T_IDX_IDX, OP_CODE_DECL (is_not_equal_value, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L === R */ /** L === R */
OP_CODE_DECL (is_equal_value_type, T_IDX_IDX, OP_CODE_DECL (is_equal_value_type, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L !== R */ /** L !== R */
OP_CODE_DECL (is_not_equal_value_type, T_IDX_IDX, OP_CODE_DECL (is_not_equal_value_type, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** Instruction tests if BOOLEAN value is TRUE and JMP to DST */ /** Instruction tests if BOOLEAN value is TRUE and JMP to DST */
OP_CODE_DECL (is_true_jmp, T_IDX_IDX, OP_CODE_DECL (is_true_jmp, T_IDX_IDX,
value, value,
opcode); opcode)
/** Instruction tests if BOOLEAN value is FALSE and JMP to DST */ /** Instruction tests if BOOLEAN value is FALSE and JMP to DST */
OP_CODE_DECL (is_false_jmp, T_IDX_IDX, OP_CODE_DECL (is_false_jmp, T_IDX_IDX,
value, value,
opcode); opcode)
/** Unconditional JMP to the specified opcode index */ /** Unconditional JMP to the specified opcode index */
OP_CODE_DECL (jmp, T_IDX, OP_CODE_DECL (jmp, T_IDX,
opcode_idx); opcode_idx)
/** Unconditional JMP on opcode_count up */ /** Unconditional JMP on opcode_count up */
OP_CODE_DECL (jmp_up, T_IDX, OP_CODE_DECL (jmp_up, T_IDX,
opcode_count); opcode_count)
/** Unconditional JMP on opcode_count down */ /** Unconditional JMP on opcode_count down */
OP_CODE_DECL (jmp_down, T_IDX, OP_CODE_DECL (jmp_down, T_IDX,
opcode_count); opcode_count)
/** dst = L + R */ /** dst = L + R */
OP_CODE_DECL (addition, T_IDX_IDX_IDX, OP_CODE_DECL (addition, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
/** dst = L - R */ /** dst = L - R */
OP_CODE_DECL (substraction, T_IDX_IDX_IDX, OP_CODE_DECL (substraction, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
/** dst = L / R */ /** dst = L / R */
OP_CODE_DECL (division, T_IDX_IDX_IDX, OP_CODE_DECL (division, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
/** dst = L * R */ /** dst = L * R */
OP_CODE_DECL (multiplication, T_IDX_IDX_IDX, OP_CODE_DECL (multiplication, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
/** dst = L % R */ /** dst = L % R */
OP_CODE_DECL (remainder, T_IDX_IDX_IDX, OP_CODE_DECL (remainder, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
/** dst = L << R */ /** dst = L << R */
OP_CODE_DECL (b_shift_left, T_IDX_IDX_IDX, OP_CODE_DECL (b_shift_left, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
/** dst = L >> R */ /** dst = L >> R */
OP_CODE_DECL (b_shift_right, T_IDX_IDX_IDX, OP_CODE_DECL (b_shift_right, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
/** dst = L >>> R */ /** dst = L >>> R */
OP_CODE_DECL (b_shift_uright, T_IDX_IDX_IDX, OP_CODE_DECL (b_shift_uright, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
// Binary bitwise operators. // Binary bitwise operators.
// Operands is a set of 32 bits // Operands is a set of 32 bits
@ -164,19 +164,19 @@ OP_CODE_DECL (b_shift_uright, T_IDX_IDX_IDX,
OP_CODE_DECL (b_and, T_IDX_IDX_IDX, OP_CODE_DECL (b_and, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
/** dst = L | R */ /** dst = L | R */
OP_CODE_DECL (b_or, T_IDX_IDX_IDX, OP_CODE_DECL (b_or, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
/** dst = L ^ R */ /** dst = L ^ R */
OP_CODE_DECL (b_xor, T_IDX_IDX_IDX, OP_CODE_DECL (b_xor, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
// Binary logical operators. // Binary logical operators.
// Operands are booleans. // Operands are booleans.
@ -186,13 +186,13 @@ OP_CODE_DECL (b_xor, T_IDX_IDX_IDX,
OP_CODE_DECL (logical_and, T_IDX_IDX_IDX, OP_CODE_DECL (logical_and, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
/** dst = L || R */ /** dst = L || R */
OP_CODE_DECL (logical_or, T_IDX_IDX_IDX, OP_CODE_DECL (logical_or, T_IDX_IDX_IDX,
dst, dst,
var_left, var_left,
var_right); var_right)
// Assignment operators. // Assignment operators.
// Assign value to LEFT operand based on value of RIGHT operand. // Assign value to LEFT operand based on value of RIGHT operand.
@ -200,133 +200,133 @@ OP_CODE_DECL (logical_or, T_IDX_IDX_IDX,
/** L = R */ /** L = R */
OP_CODE_DECL (assignment, T_IDX_IDX, OP_CODE_DECL (assignment, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L *= R */ /** L *= R */
OP_CODE_DECL (assignment_multiplication, T_IDX_IDX, OP_CODE_DECL (assignment_multiplication, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L /= R */ /** L /= R */
OP_CODE_DECL (assignment_devision, T_IDX_IDX, OP_CODE_DECL (assignment_devision, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L %= R */ /** L %= R */
OP_CODE_DECL (assignment_remainder, T_IDX_IDX, OP_CODE_DECL (assignment_remainder, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L += R */ /** L += R */
OP_CODE_DECL (assignment_addition, T_IDX_IDX, OP_CODE_DECL (assignment_addition, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L -= R */ /** L -= R */
OP_CODE_DECL (assignment_substruction, T_IDX_IDX, OP_CODE_DECL (assignment_substruction, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L <<= R */ /** L <<= R */
OP_CODE_DECL (assignment_shift_left, T_IDX_IDX, OP_CODE_DECL (assignment_shift_left, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L >>= R */ /** L >>= R */
OP_CODE_DECL (assignment_shift_right, T_IDX_IDX, OP_CODE_DECL (assignment_shift_right, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L >>>= R */ /** L >>>= R */
OP_CODE_DECL (assignment_shift_uright, T_IDX_IDX, OP_CODE_DECL (assignment_shift_uright, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L &= R */ /** L &= R */
OP_CODE_DECL (assignment_b_and, T_IDX_IDX, OP_CODE_DECL (assignment_b_and, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L ^= R */ /** L ^= R */
OP_CODE_DECL (assignment_b_xor, T_IDX_IDX, OP_CODE_DECL (assignment_b_xor, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
/** L |= R */ /** L |= R */
OP_CODE_DECL (assignment_b_or, T_IDX_IDX, OP_CODE_DECL (assignment_b_or, T_IDX_IDX,
value_left, value_left,
value_right); value_right)
// Functions calls, declarations and argument handling // Functions calls, declarations and argument handling
/** name(arg1); */ /** name(arg1); */
OP_CODE_DECL (call_1, T_IDX_IDX, OP_CODE_DECL (call_1, T_IDX_IDX,
name_lit_idx, name_lit_idx,
arg1_lit_idx); arg1_lit_idx)
/** name(arg1, arg2); */ /** name(arg1, arg2); */
OP_CODE_DECL (call_2, T_IDX_IDX_IDX, OP_CODE_DECL (call_2, T_IDX_IDX_IDX,
name_lit_idx, name_lit_idx,
arg1_lit_idx, arg1_lit_idx,
arg2_lit_idx); arg2_lit_idx)
/** name(arg1, arg2, ... */ /** name(arg1, arg2, ... */
OP_CODE_DECL (call_n, T_IDX_IDX_IDX, OP_CODE_DECL (call_n, T_IDX_IDX_IDX,
name_lit_idx, name_lit_idx,
arg1_lit_idx, arg1_lit_idx,
arg2_lit_idx); arg2_lit_idx)
/** name(arg1); */ /** name(arg1); */
OP_CODE_DECL (func_decl_1, T_IDX_IDX, OP_CODE_DECL (func_decl_1, T_IDX_IDX,
name_lit_idx, name_lit_idx,
arg1_lit_idx); arg1_lit_idx)
/** name(arg1, arg2); */ /** name(arg1, arg2); */
OP_CODE_DECL (func_decl_2, T_IDX_IDX_IDX, OP_CODE_DECL (func_decl_2, T_IDX_IDX_IDX,
name_lit_idx, name_lit_idx,
arg1_lit_idx, arg1_lit_idx,
arg2_lit_idx); arg2_lit_idx)
/** name(arg1, arg2, ... */ /** name(arg1, arg2, ... */
OP_CODE_DECL (func_decl_n, T_IDX_IDX_IDX, OP_CODE_DECL (func_decl_n, T_IDX_IDX_IDX,
name_lit_idx, name_lit_idx,
arg1_lit_idx, arg1_lit_idx,
arg2_lit_idx); arg2_lit_idx)
/** ..., arg1, ... */ /** ..., arg1, ... */
OP_CODE_DECL (varg_1, T_IDX, OP_CODE_DECL (varg_1, T_IDX,
arg1_lit_idx); arg1_lit_idx)
/** ..., arg1); */ /** ..., arg1); */
OP_CODE_DECL (varg_1_end, T_IDX, OP_CODE_DECL (varg_1_end, T_IDX,
arg1_lit_idx); arg1_lit_idx)
/** ..., arg1, arg2, ... */ /** ..., arg1, arg2, ... */
OP_CODE_DECL (varg_2, T_IDX_IDX, OP_CODE_DECL (varg_2, T_IDX_IDX,
arg1_lit_idx, arg1_lit_idx,
arg2_lit_idx); arg2_lit_idx)
/** ..., arg1, arg2); */ /** ..., arg1, arg2); */
OP_CODE_DECL (varg_2_end, T_IDX_IDX, OP_CODE_DECL (varg_2_end, T_IDX_IDX,
arg1_lit_idx, arg1_lit_idx,
arg2_lit_idx); arg2_lit_idx)
/** arg1, arg2, arg3, ... */ /** arg1, arg2, arg3, ... */
OP_CODE_DECL (varg_3, T_IDX_IDX_IDX, OP_CODE_DECL (varg_3, T_IDX_IDX_IDX,
arg1_lit_idx, arg1_lit_idx,
arg2_lit_idx, arg2_lit_idx,
arg3_lit_idx); arg3_lit_idx)
/** arg1, arg2, arg3); */ /** arg1, arg2, arg3); */
OP_CODE_DECL (varg_3_end, T_IDX_IDX_IDX, OP_CODE_DECL (varg_3_end, T_IDX_IDX_IDX,
arg1_lit_idx, arg1_lit_idx,
arg2_lit_idx, arg2_lit_idx,
arg3_lit_idx); arg3_lit_idx)
/** return value; */ /** return value; */
OP_CODE_DECL (retval, T_IDX, OP_CODE_DECL (retval, T_IDX,
ret_value); ret_value)
OP_CODE_DECL_VOID (ret); OP_CODE_DECL_VOID (ret)
// LOOPS // LOOPS
// Lately, all loops should be translated into different JMPs in an optimizer. // Lately, all loops should be translated into different JMPs in an optimizer.
@ -334,7 +334,7 @@ OP_CODE_DECL_VOID (ret);
/** End of body of infinite loop should be ended with unconditional JMP /** End of body of infinite loop should be ended with unconditional JMP
* to loop_root (ie. next op after loop condition) */ * to loop_root (ie. next op after loop condition) */
OP_CODE_DECL (loop_inf, T_IDX, OP_CODE_DECL (loop_inf, T_IDX,
loop_root); loop_root)
/** Numeric loop initialization. /** Numeric loop initialization.
* for (start,stop,step) * for (start,stop,step)
@ -342,7 +342,7 @@ OP_CODE_DECL (loop_inf, T_IDX,
OP_CODE_DECL (loop_init_num, T_IDX_IDX_IDX, OP_CODE_DECL (loop_init_num, T_IDX_IDX_IDX,
start, start,
stop, stop,
step); step)
/** Check loop (condition). /** Check loop (condition).
* if (loop cond is true) * if (loop cond is true)
@ -352,7 +352,7 @@ OP_CODE_DECL (loop_init_num, T_IDX_IDX_IDX,
*/ */
OP_CODE_DECL (loop_precond_begin_num, T_IDX_IDX, OP_CODE_DECL (loop_precond_begin_num, T_IDX_IDX,
condition, condition,
after_loop_op); after_loop_op)
/** i++; /** i++;
* Increment iterator on step and JMP to PRECOND * Increment iterator on step and JMP to PRECOND
@ -360,33 +360,33 @@ OP_CODE_DECL (loop_precond_begin_num, T_IDX_IDX,
OP_CODE_DECL (loop_precond_end_num, T_IDX_IDX_IDX, OP_CODE_DECL (loop_precond_end_num, T_IDX_IDX_IDX,
iterator, iterator,
step, step,
precond_begin); precond_begin)
/** do {...} while (cond); /** do {...} while (cond);
* If condition is true, JMP to BODY_ROOT * If condition is true, JMP to BODY_ROOT
*/ */
OP_CODE_DECL (loop_postcond, T_IDX_IDX, OP_CODE_DECL (loop_postcond, T_IDX_IDX,
condition, condition,
body_root); body_root)
///** for vars...in iter, state, ctl */ ///** for vars...in iter, state, ctl */
//OP_CODE_DECL (loop_init, T_IDX_IDX_IDX, //OP_CODE_DECL (loop_init, T_IDX_IDX_IDX,
// start_idx, stop_idx, step_idx); // start_idx, stop_idx, step_idx)
///** loop (condition) */ ///** loop (condition) */
//OP_CODE_DECL (loop_cond_pre_begin, T_IDX_IDX, //OP_CODE_DECL (loop_cond_pre_begin, T_IDX_IDX,
// condition, body_root); // condition, body_root)
///** i++;*/ ///** i++;*/
//OP_CODE_DECL (loop_cond_pre_end, T_IDX, //OP_CODE_DECL (loop_cond_pre_end, T_IDX,
// iterator, body_root); // iterator, body_root)
// Property accessors (array, objects, strings) // Property accessors (array, objects, strings)
/** Array ops for ILMIR*/ /** Array ops for ILMIR*/
//OP_CODE_DECL (array_copy, T_IDX_IDX, /** L = R */ //OP_CODE_DECL (array_copy, T_IDX_IDX, /** L = R */
// var_left, var_right); // var_left, var_right)
//OP_CODE_DECL (array_set, T_IDX_IDX_IDX, /** array[index] = src */ //OP_CODE_DECL (array_set, T_IDX_IDX_IDX, /** array[index] = src */
// dst, var_left, var_right); // dst, var_left, var_right)
//OP_CODE_DECL (array_get, T_IDX_IDX_IDX, /** dst = array[index] */ //OP_CODE_DECL (array_get, T_IDX_IDX_IDX, /** dst = array[index] */
// dst, array, index); // dst, array, index)
//// TODO //// TODO