#include"scf_operator_handler.h"
-scf_operator_handler_t* scf_operator_handler_alloc(int type,
- int src0_type, int src1_type, int ret_type,
- scf_operator_handler_pt func)
+scf_operator_handler_t* scf_operator_handler_alloc(int type, scf_operator_handler_pt func)
{
scf_operator_handler_t* h = calloc(1, sizeof(scf_operator_handler_t));
assert(h);
h->type = type;
- h->src0_type = src0_type;
- h->src1_type = src1_type;
- h->ret_type = ret_type;
-
h->func = func;
return h;
}
int type;
- int src0_type;
- int src1_type;
- int ret_type;
-
scf_operator_handler_pt func;
};
-scf_operator_handler_t* scf_operator_handler_alloc(int type,
- int src0_type, int src1_type, int ret_type,
- scf_operator_handler_pt func);
+scf_operator_handler_t* scf_operator_handler_alloc(int type, scf_operator_handler_pt func);
void scf_operator_handler_free(scf_operator_handler_t* h);
-scf_operator_handler_t* scf_find_3ac_operator_handler(const int type, const int src0_type, const int src1_type, const int ret_type);
+scf_operator_handler_t* scf_find_3ac_operator_handler(const int type);
int scf_function_to_3ac(scf_ast_t* ast, scf_function_t* f, scf_list_t* _3ac_list_head);
}
}
- scf_operator_handler_t* h = scf_find_3ac_operator_handler(node->op->type, -1, -1, -1);
+ scf_operator_handler_t* h = scf_find_3ac_operator_handler(node->op->type);
if (!h) {
scf_loge("\n");
return -1;
}
}
- scf_operator_handler_t* h = scf_find_3ac_operator_handler(node->op->type, -1, -1, -1);
+ scf_operator_handler_t* h = scf_find_3ac_operator_handler(node->op->type);
if (!h) {
scf_loge("op->type: %d, name: '%s'\n", node->op->type, node->op->name);
return -1;
}
}
- scf_operator_handler_t* h = scf_find_3ac_operator_handler(op->type, -1, -1, -1);
+ scf_operator_handler_t* h = scf_find_3ac_operator_handler(op->type);
if (!h) {
scf_loge("\n");
return -1;
}
}
- scf_operator_handler_t* h = scf_find_3ac_operator_handler(op->type, -1, -1, -1);
+ scf_operator_handler_t* h = scf_find_3ac_operator_handler(op->type);
if (!h) {
scf_loge("\n");
return -1;
SCF_OP_LOGIC(or)
scf_operator_handler_t _3ac_operator_handlers[] = {
- {{NULL, NULL}, SCF_OP_EXPR, -1, -1, -1, _scf_op_expr},
- {{NULL, NULL}, SCF_OP_CALL, -1, -1, -1, _scf_op_call},
- {{NULL, NULL}, SCF_OP_CREATE, -1, -1, -1, _scf_op_create},
-
- {{NULL, NULL}, SCF_OP_ARRAY_INDEX, -1, -1, -1, _scf_op_array_index},
- {{NULL, NULL}, SCF_OP_POINTER, -1, -1, -1, _scf_op_pointer},
-
- {{NULL, NULL}, SCF_OP_VA_START, -1, -1, -1, _scf_op_va_start},
- {{NULL, NULL}, SCF_OP_VA_ARG, -1, -1, -1, _scf_op_va_arg},
- {{NULL, NULL}, SCF_OP_VA_END, -1, -1, -1, _scf_op_va_end},
-
- {{NULL, NULL}, SCF_OP_TYPE_CAST, -1, -1, -1, _scf_op_type_cast},
- {{NULL, NULL}, SCF_OP_LOGIC_NOT, -1, -1, -1, _scf_op_logic_not},
- {{NULL, NULL}, SCF_OP_BIT_NOT, -1, -1, -1, _scf_op_bit_not},
- {{NULL, NULL}, SCF_OP_NEG, -1, -1, -1, _scf_op_neg},
- {{NULL, NULL}, SCF_OP_POSITIVE, -1, -1, -1, _scf_op_positive},
-
- {{NULL, NULL}, SCF_OP_INC, -1, -1, -1, _scf_op_inc},
- {{NULL, NULL}, SCF_OP_DEC, -1, -1, -1, _scf_op_dec},
-
- {{NULL, NULL}, SCF_OP_INC_POST, -1, -1, -1, _scf_op_inc_post},
- {{NULL, NULL}, SCF_OP_DEC_POST, -1, -1, -1, _scf_op_dec_post},
-
- {{NULL, NULL}, SCF_OP_DEREFERENCE, -1, -1, -1, _scf_op_dereference},
- {{NULL, NULL}, SCF_OP_ADDRESS_OF, -1, -1, -1, _scf_op_address_of},
-
- {{NULL, NULL}, SCF_OP_MUL, -1, -1, -1, _scf_op_mul},
- {{NULL, NULL}, SCF_OP_DIV, -1, -1, -1, _scf_op_div},
- {{NULL, NULL}, SCF_OP_MOD, -1, -1, -1, _scf_op_mod},
-
- {{NULL, NULL}, SCF_OP_ADD, -1, -1, -1, _scf_op_add},
- {{NULL, NULL}, SCF_OP_SUB, -1, -1, -1, _scf_op_sub},
-
- {{NULL, NULL}, SCF_OP_SHL, -1, -1, -1, _scf_op_shl},
- {{NULL, NULL}, SCF_OP_SHR, -1, -1, -1, _scf_op_shr},
-
- {{NULL, NULL}, SCF_OP_BIT_AND, -1, -1, -1, _scf_op_bit_and},
- {{NULL, NULL}, SCF_OP_BIT_OR, -1, -1, -1, _scf_op_bit_or},
-
- {{NULL, NULL}, SCF_OP_EQ, -1, -1, -1, _scf_op_eq},
- {{NULL, NULL}, SCF_OP_NE, -1, -1, -1, _scf_op_ne},
- {{NULL, NULL}, SCF_OP_GT, -1, -1, -1, _scf_op_gt},
- {{NULL, NULL}, SCF_OP_LT, -1, -1, -1, _scf_op_lt},
- {{NULL, NULL}, SCF_OP_GE, -1, -1, -1, _scf_op_ge},
- {{NULL, NULL}, SCF_OP_LE, -1, -1, -1, _scf_op_le},
-
- {{NULL, NULL}, SCF_OP_LOGIC_AND, -1, -1, -1, _scf_op_logic_and},
- {{NULL, NULL}, SCF_OP_LOGIC_OR, -1, -1, -1, _scf_op_logic_or},
-
- {{NULL, NULL}, SCF_OP_ASSIGN, -1, -1, -1, _scf_op_assign},
- {{NULL, NULL}, SCF_OP_ADD_ASSIGN, -1, -1, -1, _scf_op_add_assign},
- {{NULL, NULL}, SCF_OP_SUB_ASSIGN, -1, -1, -1, _scf_op_sub_assign},
- {{NULL, NULL}, SCF_OP_MUL_ASSIGN, -1, -1, -1, _scf_op_mul_assign},
- {{NULL, NULL}, SCF_OP_DIV_ASSIGN, -1, -1, -1, _scf_op_div_assign},
- {{NULL, NULL}, SCF_OP_MOD_ASSIGN, -1, -1, -1, _scf_op_mod_assign},
- {{NULL, NULL}, SCF_OP_SHL_ASSIGN, -1, -1, -1, _scf_op_shl_assign},
- {{NULL, NULL}, SCF_OP_SHR_ASSIGN, -1, -1, -1, _scf_op_shr_assign},
- {{NULL, NULL}, SCF_OP_AND_ASSIGN, -1, -1, -1, _scf_op_and_assign},
- {{NULL, NULL}, SCF_OP_OR_ASSIGN, -1, -1, -1, _scf_op_or_assign},
-
-
- {{NULL, NULL}, SCF_OP_BLOCK, -1, -1, -1, _scf_op_block},
- {{NULL, NULL}, SCF_OP_RETURN, -1, -1, -1, _scf_op_return},
- {{NULL, NULL}, SCF_OP_BREAK, -1, -1, -1, _scf_op_break},
- {{NULL, NULL}, SCF_OP_CONTINUE, -1, -1, -1, _scf_op_continue},
- {{NULL, NULL}, SCF_OP_GOTO, -1, -1, -1, _scf_op_goto},
- {{NULL, NULL}, SCF_LABEL, -1, -1, -1, _scf_op_label},
- {{NULL, NULL}, SCF_OP_ERROR, -1, -1, -1, _scf_op_error},
-
- {{NULL, NULL}, SCF_OP_IF, -1, -1, -1, _scf_op_if},
- {{NULL, NULL}, SCF_OP_WHILE, -1, -1, -1, _scf_op_while},
- {{NULL, NULL}, SCF_OP_REPEAT, -1, -1, -1, _scf_op_repeat},
- {{NULL, NULL}, SCF_OP_FOR, -1, -1, -1, _scf_op_for},
+ {{NULL, NULL}, SCF_OP_EXPR, _scf_op_expr},
+ {{NULL, NULL}, SCF_OP_CALL, _scf_op_call},
+ {{NULL, NULL}, SCF_OP_CREATE, _scf_op_create},
+
+ {{NULL, NULL}, SCF_OP_ARRAY_INDEX, _scf_op_array_index},
+ {{NULL, NULL}, SCF_OP_POINTER, _scf_op_pointer},
+
+ {{NULL, NULL}, SCF_OP_VA_START, _scf_op_va_start},
+ {{NULL, NULL}, SCF_OP_VA_ARG, _scf_op_va_arg},
+ {{NULL, NULL}, SCF_OP_VA_END, _scf_op_va_end},
+
+ {{NULL, NULL}, SCF_OP_TYPE_CAST, _scf_op_type_cast},
+ {{NULL, NULL}, SCF_OP_LOGIC_NOT, _scf_op_logic_not},
+ {{NULL, NULL}, SCF_OP_BIT_NOT, _scf_op_bit_not},
+ {{NULL, NULL}, SCF_OP_NEG, _scf_op_neg},
+ {{NULL, NULL}, SCF_OP_POSITIVE, _scf_op_positive},
+
+ {{NULL, NULL}, SCF_OP_INC, _scf_op_inc},
+ {{NULL, NULL}, SCF_OP_DEC, _scf_op_dec},
+
+ {{NULL, NULL}, SCF_OP_INC_POST, _scf_op_inc_post},
+ {{NULL, NULL}, SCF_OP_DEC_POST, _scf_op_dec_post},
+
+ {{NULL, NULL}, SCF_OP_DEREFERENCE, _scf_op_dereference},
+ {{NULL, NULL}, SCF_OP_ADDRESS_OF, _scf_op_address_of},
+
+ {{NULL, NULL}, SCF_OP_MUL, _scf_op_mul},
+ {{NULL, NULL}, SCF_OP_DIV, _scf_op_div},
+ {{NULL, NULL}, SCF_OP_MOD, _scf_op_mod},
+
+ {{NULL, NULL}, SCF_OP_ADD, _scf_op_add},
+ {{NULL, NULL}, SCF_OP_SUB, _scf_op_sub},
+
+ {{NULL, NULL}, SCF_OP_SHL, _scf_op_shl},
+ {{NULL, NULL}, SCF_OP_SHR, _scf_op_shr},
+
+ {{NULL, NULL}, SCF_OP_BIT_AND, _scf_op_bit_and},
+ {{NULL, NULL}, SCF_OP_BIT_OR, _scf_op_bit_or},
+
+ {{NULL, NULL}, SCF_OP_EQ, _scf_op_eq},
+ {{NULL, NULL}, SCF_OP_NE, _scf_op_ne},
+ {{NULL, NULL}, SCF_OP_GT, _scf_op_gt},
+ {{NULL, NULL}, SCF_OP_LT, _scf_op_lt},
+ {{NULL, NULL}, SCF_OP_GE, _scf_op_ge},
+ {{NULL, NULL}, SCF_OP_LE, _scf_op_le},
+
+ {{NULL, NULL}, SCF_OP_LOGIC_AND, _scf_op_logic_and},
+ {{NULL, NULL}, SCF_OP_LOGIC_OR, _scf_op_logic_or},
+
+ {{NULL, NULL}, SCF_OP_ASSIGN, _scf_op_assign},
+ {{NULL, NULL}, SCF_OP_ADD_ASSIGN, _scf_op_add_assign},
+ {{NULL, NULL}, SCF_OP_SUB_ASSIGN, _scf_op_sub_assign},
+ {{NULL, NULL}, SCF_OP_MUL_ASSIGN, _scf_op_mul_assign},
+ {{NULL, NULL}, SCF_OP_DIV_ASSIGN, _scf_op_div_assign},
+ {{NULL, NULL}, SCF_OP_MOD_ASSIGN, _scf_op_mod_assign},
+ {{NULL, NULL}, SCF_OP_SHL_ASSIGN, _scf_op_shl_assign},
+ {{NULL, NULL}, SCF_OP_SHR_ASSIGN, _scf_op_shr_assign},
+ {{NULL, NULL}, SCF_OP_AND_ASSIGN, _scf_op_and_assign},
+ {{NULL, NULL}, SCF_OP_OR_ASSIGN, _scf_op_or_assign},
+
+
+ {{NULL, NULL}, SCF_OP_BLOCK, _scf_op_block},
+ {{NULL, NULL}, SCF_OP_RETURN, _scf_op_return},
+ {{NULL, NULL}, SCF_OP_BREAK, _scf_op_break},
+ {{NULL, NULL}, SCF_OP_CONTINUE, _scf_op_continue},
+ {{NULL, NULL}, SCF_OP_GOTO, _scf_op_goto},
+ {{NULL, NULL}, SCF_LABEL, _scf_op_label},
+ {{NULL, NULL}, SCF_OP_ERROR, _scf_op_error},
+
+ {{NULL, NULL}, SCF_OP_IF, _scf_op_if},
+ {{NULL, NULL}, SCF_OP_WHILE, _scf_op_while},
+ {{NULL, NULL}, SCF_OP_REPEAT, _scf_op_repeat},
+ {{NULL, NULL}, SCF_OP_FOR, _scf_op_for},
};
-scf_operator_handler_t* scf_find_3ac_operator_handler(const int type, const int src0_type, const int src1_type, const int ret_type)
+scf_operator_handler_t* scf_find_3ac_operator_handler(const int type)
{
int i;
for (i = 0; i < sizeof(_3ac_operator_handlers) / sizeof(_3ac_operator_handlers[0]); i++) {
}
scf_operator_handler_t const_operator_handlers[] = {
- {{NULL, NULL}, SCF_OP_EXPR, -1, -1, -1, _scf_op_const_expr},
- {{NULL, NULL}, SCF_OP_CALL, -1, -1, -1, _scf_op_const_call},
-
- {{NULL, NULL}, SCF_OP_ARRAY_INDEX, -1, -1, -1, _scf_op_const_array_index},
- {{NULL, NULL}, SCF_OP_POINTER, -1, -1, -1, _scf_op_const_pointer},
- {{NULL, NULL}, SCF_OP_CREATE, -1, -1, -1, _scf_op_const_create},
-
- {{NULL, NULL}, SCF_OP_VA_START, -1, -1, -1, _scf_op_const_va_start},
- {{NULL, NULL}, SCF_OP_VA_ARG, -1, -1, -1, _scf_op_const_va_arg},
- {{NULL, NULL}, SCF_OP_VA_END, -1, -1, -1, _scf_op_const_va_end},
-
- {{NULL, NULL}, SCF_OP_SIZEOF, -1, -1, -1, _scf_op_const_sizeof},
- {{NULL, NULL}, SCF_OP_TYPE_CAST, -1, -1, -1, _scf_op_const_type_cast},
- {{NULL, NULL}, SCF_OP_LOGIC_NOT, -1, -1, -1, _scf_op_const_logic_not},
- {{NULL, NULL}, SCF_OP_BIT_NOT, -1, -1, -1, _scf_op_const_bit_not},
- {{NULL, NULL}, SCF_OP_NEG, -1, -1, -1, _scf_op_const_neg},
- {{NULL, NULL}, SCF_OP_POSITIVE, -1, -1, -1, _scf_op_const_positive},
-
- {{NULL, NULL}, SCF_OP_INC, -1, -1, -1, _scf_op_const_inc},
- {{NULL, NULL}, SCF_OP_DEC, -1, -1, -1, _scf_op_const_dec},
-
- {{NULL, NULL}, SCF_OP_INC_POST, -1, -1, -1, _scf_op_const_inc_post},
- {{NULL, NULL}, SCF_OP_DEC_POST, -1, -1, -1, _scf_op_const_dec_post},
-
- {{NULL, NULL}, SCF_OP_DEREFERENCE, -1, -1, -1, _scf_op_const_dereference},
- {{NULL, NULL}, SCF_OP_ADDRESS_OF, -1, -1, -1, _scf_op_const_address_of},
-
- {{NULL, NULL}, SCF_OP_MUL, -1, -1, -1, _scf_op_const_mul},
- {{NULL, NULL}, SCF_OP_DIV, -1, -1, -1, _scf_op_const_div},
- {{NULL, NULL}, SCF_OP_MOD, -1, -1, -1, _scf_op_const_mod},
-
- {{NULL, NULL}, SCF_OP_ADD, -1, -1, -1, _scf_op_const_add},
- {{NULL, NULL}, SCF_OP_SUB, -1, -1, -1, _scf_op_const_sub},
-
- {{NULL, NULL}, SCF_OP_SHL, -1, -1, -1, _scf_op_const_shl},
- {{NULL, NULL}, SCF_OP_SHR, -1, -1, -1, _scf_op_const_shr},
-
- {{NULL, NULL}, SCF_OP_BIT_AND, -1, -1, -1, _scf_op_const_bit_and},
- {{NULL, NULL}, SCF_OP_BIT_OR, -1, -1, -1, _scf_op_const_bit_or},
-
- {{NULL, NULL}, SCF_OP_EQ, -1, -1, -1, _scf_op_const_eq},
- {{NULL, NULL}, SCF_OP_NE, -1, -1, -1, _scf_op_const_ne},
- {{NULL, NULL}, SCF_OP_GT, -1, -1, -1, _scf_op_const_gt},
- {{NULL, NULL}, SCF_OP_LT, -1, -1, -1, _scf_op_const_lt},
- {{NULL, NULL}, SCF_OP_GE, -1, -1, -1, _scf_op_const_ge},
- {{NULL, NULL}, SCF_OP_LE, -1, -1, -1, _scf_op_const_le},
-
- {{NULL, NULL}, SCF_OP_LOGIC_AND, -1, -1, -1, _scf_op_const_logic_and},
- {{NULL, NULL}, SCF_OP_LOGIC_OR, -1, -1, -1, _scf_op_const_logic_or},
-
- {{NULL, NULL}, SCF_OP_ASSIGN, -1, -1, -1, _scf_op_const_assign},
- {{NULL, NULL}, SCF_OP_ADD_ASSIGN, -1, -1, -1, _scf_op_const_add_assign},
- {{NULL, NULL}, SCF_OP_SUB_ASSIGN, -1, -1, -1, _scf_op_const_sub_assign},
- {{NULL, NULL}, SCF_OP_MUL_ASSIGN, -1, -1, -1, _scf_op_const_mul_assign},
- {{NULL, NULL}, SCF_OP_DIV_ASSIGN, -1, -1, -1, _scf_op_const_div_assign},
- {{NULL, NULL}, SCF_OP_MOD_ASSIGN, -1, -1, -1, _scf_op_const_mod_assign},
- {{NULL, NULL}, SCF_OP_SHL_ASSIGN, -1, -1, -1, _scf_op_const_shl_assign},
- {{NULL, NULL}, SCF_OP_SHR_ASSIGN, -1, -1, -1, _scf_op_const_shr_assign},
- {{NULL, NULL}, SCF_OP_AND_ASSIGN, -1, -1, -1, _scf_op_const_and_assign},
- {{NULL, NULL}, SCF_OP_OR_ASSIGN, -1, -1, -1, _scf_op_const_or_assign},
-
- {{NULL, NULL}, SCF_OP_BLOCK, -1, -1, -1, _scf_op_const_block},
- {{NULL, NULL}, SCF_OP_RETURN, -1, -1, -1, _scf_op_const_return},
- {{NULL, NULL}, SCF_OP_BREAK, -1, -1, -1, _scf_op_const_break},
- {{NULL, NULL}, SCF_OP_CONTINUE, -1, -1, -1, _scf_op_const_continue},
- {{NULL, NULL}, SCF_OP_GOTO, -1, -1, -1, _scf_op_const_goto},
- {{NULL, NULL}, SCF_LABEL, -1, -1, -1, _scf_op_const_label},
- {{NULL, NULL}, SCF_OP_ERROR, -1, -1, -1, _scf_op_const_error},
-
- {{NULL, NULL}, SCF_OP_IF, -1, -1, -1, _scf_op_const_if},
- {{NULL, NULL}, SCF_OP_WHILE, -1, -1, -1, _scf_op_const_while},
- {{NULL, NULL}, SCF_OP_REPEAT, -1, -1, -1, _scf_op_const_repeat},
- {{NULL, NULL}, SCF_OP_FOR, -1, -1, -1, _scf_op_const_for},
+ {{NULL, NULL}, SCF_OP_EXPR, _scf_op_const_expr},
+ {{NULL, NULL}, SCF_OP_CALL, _scf_op_const_call},
+
+ {{NULL, NULL}, SCF_OP_ARRAY_INDEX, _scf_op_const_array_index},
+ {{NULL, NULL}, SCF_OP_POINTER, _scf_op_const_pointer},
+ {{NULL, NULL}, SCF_OP_CREATE, _scf_op_const_create},
+
+ {{NULL, NULL}, SCF_OP_VA_START, _scf_op_const_va_start},
+ {{NULL, NULL}, SCF_OP_VA_ARG, _scf_op_const_va_arg},
+ {{NULL, NULL}, SCF_OP_VA_END, _scf_op_const_va_end},
+
+ {{NULL, NULL}, SCF_OP_SIZEOF, _scf_op_const_sizeof},
+ {{NULL, NULL}, SCF_OP_TYPE_CAST, _scf_op_const_type_cast},
+ {{NULL, NULL}, SCF_OP_LOGIC_NOT, _scf_op_const_logic_not},
+ {{NULL, NULL}, SCF_OP_BIT_NOT, _scf_op_const_bit_not},
+ {{NULL, NULL}, SCF_OP_NEG, _scf_op_const_neg},
+ {{NULL, NULL}, SCF_OP_POSITIVE, _scf_op_const_positive},
+
+ {{NULL, NULL}, SCF_OP_INC, _scf_op_const_inc},
+ {{NULL, NULL}, SCF_OP_DEC, _scf_op_const_dec},
+
+ {{NULL, NULL}, SCF_OP_INC_POST, _scf_op_const_inc_post},
+ {{NULL, NULL}, SCF_OP_DEC_POST, _scf_op_const_dec_post},
+
+ {{NULL, NULL}, SCF_OP_DEREFERENCE, _scf_op_const_dereference},
+ {{NULL, NULL}, SCF_OP_ADDRESS_OF, _scf_op_const_address_of},
+
+ {{NULL, NULL}, SCF_OP_MUL, _scf_op_const_mul},
+ {{NULL, NULL}, SCF_OP_DIV, _scf_op_const_div},
+ {{NULL, NULL}, SCF_OP_MOD, _scf_op_const_mod},
+
+ {{NULL, NULL}, SCF_OP_ADD, _scf_op_const_add},
+ {{NULL, NULL}, SCF_OP_SUB, _scf_op_const_sub},
+
+ {{NULL, NULL}, SCF_OP_SHL, _scf_op_const_shl},
+ {{NULL, NULL}, SCF_OP_SHR, _scf_op_const_shr},
+
+ {{NULL, NULL}, SCF_OP_BIT_AND, _scf_op_const_bit_and},
+ {{NULL, NULL}, SCF_OP_BIT_OR, _scf_op_const_bit_or},
+
+ {{NULL, NULL}, SCF_OP_EQ, _scf_op_const_eq},
+ {{NULL, NULL}, SCF_OP_NE, _scf_op_const_ne},
+ {{NULL, NULL}, SCF_OP_GT, _scf_op_const_gt},
+ {{NULL, NULL}, SCF_OP_LT, _scf_op_const_lt},
+ {{NULL, NULL}, SCF_OP_GE, _scf_op_const_ge},
+ {{NULL, NULL}, SCF_OP_LE, _scf_op_const_le},
+
+ {{NULL, NULL}, SCF_OP_LOGIC_AND, _scf_op_const_logic_and},
+ {{NULL, NULL}, SCF_OP_LOGIC_OR, _scf_op_const_logic_or},
+
+ {{NULL, NULL}, SCF_OP_ASSIGN, _scf_op_const_assign},
+ {{NULL, NULL}, SCF_OP_ADD_ASSIGN, _scf_op_const_add_assign},
+ {{NULL, NULL}, SCF_OP_SUB_ASSIGN, _scf_op_const_sub_assign},
+ {{NULL, NULL}, SCF_OP_MUL_ASSIGN, _scf_op_const_mul_assign},
+ {{NULL, NULL}, SCF_OP_DIV_ASSIGN, _scf_op_const_div_assign},
+ {{NULL, NULL}, SCF_OP_MOD_ASSIGN, _scf_op_const_mod_assign},
+ {{NULL, NULL}, SCF_OP_SHL_ASSIGN, _scf_op_const_shl_assign},
+ {{NULL, NULL}, SCF_OP_SHR_ASSIGN, _scf_op_const_shr_assign},
+ {{NULL, NULL}, SCF_OP_AND_ASSIGN, _scf_op_const_and_assign},
+ {{NULL, NULL}, SCF_OP_OR_ASSIGN, _scf_op_const_or_assign},
+
+ {{NULL, NULL}, SCF_OP_BLOCK, _scf_op_const_block},
+ {{NULL, NULL}, SCF_OP_RETURN, _scf_op_const_return},
+ {{NULL, NULL}, SCF_OP_BREAK, _scf_op_const_break},
+ {{NULL, NULL}, SCF_OP_CONTINUE, _scf_op_const_continue},
+ {{NULL, NULL}, SCF_OP_GOTO, _scf_op_const_goto},
+ {{NULL, NULL}, SCF_LABEL, _scf_op_const_label},
+ {{NULL, NULL}, SCF_OP_ERROR, _scf_op_const_error},
+
+ {{NULL, NULL}, SCF_OP_IF, _scf_op_const_if},
+ {{NULL, NULL}, SCF_OP_WHILE, _scf_op_const_while},
+ {{NULL, NULL}, SCF_OP_REPEAT, _scf_op_const_repeat},
+ {{NULL, NULL}, SCF_OP_FOR, _scf_op_const_for},
};
scf_operator_handler_t* scf_find_const_operator_handler(const int type, const int src0_type, const int src1_type, const int ret_type)
scf_operator_handler_t expr_operator_handlers[] = {
- {{NULL, NULL}, SCF_OP_EXPR, -1, -1, -1, _scf_op_expr_expr},
+ {{NULL, NULL}, SCF_OP_EXPR, _scf_op_expr_expr},
- {{NULL, NULL}, SCF_OP_ARRAY_INDEX, -1, -1, -1, _scf_op_expr_array_index},
- {{NULL, NULL}, SCF_OP_POINTER, -1, -1, -1, _scf_op_expr_pointer},
+ {{NULL, NULL}, SCF_OP_ARRAY_INDEX, _scf_op_expr_array_index},
+ {{NULL, NULL}, SCF_OP_POINTER, _scf_op_expr_pointer},
- {{NULL, NULL}, SCF_OP_SIZEOF, -1, -1, -1, _scf_op_expr_sizeof},
- {{NULL, NULL}, SCF_OP_TYPE_CAST, -1, -1, -1, _scf_op_expr_type_cast},
- {{NULL, NULL}, SCF_OP_LOGIC_NOT, -1, -1, -1, _scf_op_expr_logic_not},
- {{NULL, NULL}, SCF_OP_BIT_NOT, -1, -1, -1, _scf_op_expr_bit_not},
- {{NULL, NULL}, SCF_OP_NEG, -1, -1, -1, _scf_op_expr_neg},
+ {{NULL, NULL}, SCF_OP_SIZEOF, _scf_op_expr_sizeof},
+ {{NULL, NULL}, SCF_OP_TYPE_CAST, _scf_op_expr_type_cast},
+ {{NULL, NULL}, SCF_OP_LOGIC_NOT, _scf_op_expr_logic_not},
+ {{NULL, NULL}, SCF_OP_BIT_NOT, _scf_op_expr_bit_not},
+ {{NULL, NULL}, SCF_OP_NEG, _scf_op_expr_neg},
- {{NULL, NULL}, SCF_OP_ADDRESS_OF, -1, -1, -1, _scf_op_expr_address_of},
+ {{NULL, NULL}, SCF_OP_ADDRESS_OF, _scf_op_expr_address_of},
- {{NULL, NULL}, SCF_OP_MUL, -1, -1, -1, _scf_op_expr_mul},
- {{NULL, NULL}, SCF_OP_DIV, -1, -1, -1, _scf_op_expr_div},
- {{NULL, NULL}, SCF_OP_MOD, -1, -1, -1, _scf_op_expr_mod},
+ {{NULL, NULL}, SCF_OP_MUL, _scf_op_expr_mul},
+ {{NULL, NULL}, SCF_OP_DIV, _scf_op_expr_div},
+ {{NULL, NULL}, SCF_OP_MOD, _scf_op_expr_mod},
- {{NULL, NULL}, SCF_OP_ADD, -1, -1, -1, _scf_op_expr_add},
- {{NULL, NULL}, SCF_OP_SUB, -1, -1, -1, _scf_op_expr_sub},
+ {{NULL, NULL}, SCF_OP_ADD, _scf_op_expr_add},
+ {{NULL, NULL}, SCF_OP_SUB, _scf_op_expr_sub},
- {{NULL, NULL}, SCF_OP_SHL, -1, -1, -1, _scf_op_expr_shl},
- {{NULL, NULL}, SCF_OP_SHR, -1, -1, -1, _scf_op_expr_shr},
+ {{NULL, NULL}, SCF_OP_SHL, _scf_op_expr_shl},
+ {{NULL, NULL}, SCF_OP_SHR, _scf_op_expr_shr},
- {{NULL, NULL}, SCF_OP_BIT_AND, -1, -1, -1, _scf_op_expr_bit_and},
- {{NULL, NULL}, SCF_OP_BIT_OR, -1, -1, -1, _scf_op_expr_bit_or},
+ {{NULL, NULL}, SCF_OP_BIT_AND, _scf_op_expr_bit_and},
+ {{NULL, NULL}, SCF_OP_BIT_OR, _scf_op_expr_bit_or},
- {{NULL, NULL}, SCF_OP_EQ, -1, -1, -1, _scf_op_expr_eq},
- {{NULL, NULL}, SCF_OP_NE, -1, -1, -1, _scf_op_expr_ne},
- {{NULL, NULL}, SCF_OP_GT, -1, -1, -1, _scf_op_expr_gt},
- {{NULL, NULL}, SCF_OP_LT, -1, -1, -1, _scf_op_expr_lt},
- {{NULL, NULL}, SCF_OP_GE, -1, -1, -1, _scf_op_expr_ge},
- {{NULL, NULL}, SCF_OP_LE, -1, -1, -1, _scf_op_expr_le},
+ {{NULL, NULL}, SCF_OP_EQ, _scf_op_expr_eq},
+ {{NULL, NULL}, SCF_OP_NE, _scf_op_expr_ne},
+ {{NULL, NULL}, SCF_OP_GT, _scf_op_expr_gt},
+ {{NULL, NULL}, SCF_OP_LT, _scf_op_expr_lt},
+ {{NULL, NULL}, SCF_OP_GE, _scf_op_expr_ge},
+ {{NULL, NULL}, SCF_OP_LE, _scf_op_expr_le},
- {{NULL, NULL}, SCF_OP_LOGIC_AND, -1, -1, -1, _scf_op_expr_logic_and},
- {{NULL, NULL}, SCF_OP_LOGIC_OR, -1, -1, -1, _scf_op_expr_logic_or},
+ {{NULL, NULL}, SCF_OP_LOGIC_AND, _scf_op_expr_logic_and},
+ {{NULL, NULL}, SCF_OP_LOGIC_OR, _scf_op_expr_logic_or},
- {{NULL, NULL}, SCF_OP_ASSIGN, -1, -1, -1, _scf_op_expr_assign},
+ {{NULL, NULL}, SCF_OP_ASSIGN, _scf_op_expr_assign},
};
scf_operator_handler_t* scf_find_expr_operator_handler(const int type, const int src0_type, const int src1_type, const int ret_type)
}
scf_operator_handler_t semantic_operator_handlers[] = {
- {{NULL, NULL}, SCF_OP_EXPR, -1, -1, -1, _scf_op_semantic_expr},
- {{NULL, NULL}, SCF_OP_CALL, -1, -1, -1, _scf_op_semantic_call},
-
- {{NULL, NULL}, SCF_OP_ARRAY_INDEX, -1, -1, -1, _scf_op_semantic_array_index},
- {{NULL, NULL}, SCF_OP_POINTER, -1, -1, -1, _scf_op_semantic_pointer},
- {{NULL, NULL}, SCF_OP_CREATE, -1, -1, -1, _scf_op_semantic_create},
-
- {{NULL, NULL}, SCF_OP_VA_START, -1, -1, -1, _scf_op_semantic_va_start},
- {{NULL, NULL}, SCF_OP_VA_ARG, -1, -1, -1, _scf_op_semantic_va_arg},
- {{NULL, NULL}, SCF_OP_VA_END, -1, -1, -1, _scf_op_semantic_va_end},
-
- {{NULL, NULL}, SCF_OP_CONTAINER, -1, -1, -1, _scf_op_semantic_container},
-
- {{NULL, NULL}, SCF_OP_SIZEOF, -1, -1, -1, _scf_op_semantic_sizeof},
- {{NULL, NULL}, SCF_OP_TYPE_CAST, -1, -1, -1, _scf_op_semantic_type_cast},
- {{NULL, NULL}, SCF_OP_LOGIC_NOT, -1, -1, -1, _scf_op_semantic_logic_not},
- {{NULL, NULL}, SCF_OP_BIT_NOT, -1, -1, -1, _scf_op_semantic_bit_not},
- {{NULL, NULL}, SCF_OP_NEG, -1, -1, -1, _scf_op_semantic_neg},
- {{NULL, NULL}, SCF_OP_POSITIVE, -1, -1, -1, _scf_op_semantic_positive},
-
- {{NULL, NULL}, SCF_OP_INC, -1, -1, -1, _scf_op_semantic_inc},
- {{NULL, NULL}, SCF_OP_DEC, -1, -1, -1, _scf_op_semantic_dec},
-
- {{NULL, NULL}, SCF_OP_INC_POST, -1, -1, -1, _scf_op_semantic_inc_post},
- {{NULL, NULL}, SCF_OP_DEC_POST, -1, -1, -1, _scf_op_semantic_dec_post},
-
- {{NULL, NULL}, SCF_OP_DEREFERENCE, -1, -1, -1, _scf_op_semantic_dereference},
- {{NULL, NULL}, SCF_OP_ADDRESS_OF, -1, -1, -1, _scf_op_semantic_address_of},
-
- {{NULL, NULL}, SCF_OP_MUL, -1, -1, -1, _scf_op_semantic_mul},
- {{NULL, NULL}, SCF_OP_DIV, -1, -1, -1, _scf_op_semantic_div},
- {{NULL, NULL}, SCF_OP_MOD, -1, -1, -1, _scf_op_semantic_mod},
-
- {{NULL, NULL}, SCF_OP_ADD, -1, -1, -1, _scf_op_semantic_add},
- {{NULL, NULL}, SCF_OP_SUB, -1, -1, -1, _scf_op_semantic_sub},
-
- {{NULL, NULL}, SCF_OP_SHL, -1, -1, -1, _scf_op_semantic_shl},
- {{NULL, NULL}, SCF_OP_SHR, -1, -1, -1, _scf_op_semantic_shr},
-
- {{NULL, NULL}, SCF_OP_BIT_AND, -1, -1, -1, _scf_op_semantic_bit_and},
- {{NULL, NULL}, SCF_OP_BIT_OR, -1, -1, -1, _scf_op_semantic_bit_or},
-
- {{NULL, NULL}, SCF_OP_EQ, -1, -1, -1, _scf_op_semantic_eq},
- {{NULL, NULL}, SCF_OP_NE, -1, -1, -1, _scf_op_semantic_ne},
- {{NULL, NULL}, SCF_OP_GT, -1, -1, -1, _scf_op_semantic_gt},
- {{NULL, NULL}, SCF_OP_LT, -1, -1, -1, _scf_op_semantic_lt},
- {{NULL, NULL}, SCF_OP_GE, -1, -1, -1, _scf_op_semantic_ge},
- {{NULL, NULL}, SCF_OP_LE, -1, -1, -1, _scf_op_semantic_le},
-
- {{NULL, NULL}, SCF_OP_LOGIC_AND, -1, -1, -1, _scf_op_semantic_logic_and},
- {{NULL, NULL}, SCF_OP_LOGIC_OR, -1, -1, -1, _scf_op_semantic_logic_or},
-
- {{NULL, NULL}, SCF_OP_ASSIGN, -1, -1, -1, _scf_op_semantic_assign},
- {{NULL, NULL}, SCF_OP_ADD_ASSIGN, -1, -1, -1, _scf_op_semantic_add_assign},
- {{NULL, NULL}, SCF_OP_SUB_ASSIGN, -1, -1, -1, _scf_op_semantic_sub_assign},
- {{NULL, NULL}, SCF_OP_MUL_ASSIGN, -1, -1, -1, _scf_op_semantic_mul_assign},
- {{NULL, NULL}, SCF_OP_DIV_ASSIGN, -1, -1, -1, _scf_op_semantic_div_assign},
- {{NULL, NULL}, SCF_OP_MOD_ASSIGN, -1, -1, -1, _scf_op_semantic_mod_assign},
- {{NULL, NULL}, SCF_OP_SHL_ASSIGN, -1, -1, -1, _scf_op_semantic_shl_assign},
- {{NULL, NULL}, SCF_OP_SHR_ASSIGN, -1, -1, -1, _scf_op_semantic_shr_assign},
- {{NULL, NULL}, SCF_OP_AND_ASSIGN, -1, -1, -1, _scf_op_semantic_and_assign},
- {{NULL, NULL}, SCF_OP_OR_ASSIGN, -1, -1, -1, _scf_op_semantic_or_assign},
-
- {{NULL, NULL}, SCF_OP_BLOCK, -1, -1, -1, _scf_op_semantic_block},
- {{NULL, NULL}, SCF_OP_RETURN, -1, -1, -1, _scf_op_semantic_return},
- {{NULL, NULL}, SCF_OP_BREAK, -1, -1, -1, _scf_op_semantic_break},
- {{NULL, NULL}, SCF_OP_CONTINUE, -1, -1, -1, _scf_op_semantic_continue},
- {{NULL, NULL}, SCF_OP_GOTO, -1, -1, -1, _scf_op_semantic_goto},
- {{NULL, NULL}, SCF_LABEL, -1, -1, -1, _scf_op_semantic_label},
- {{NULL, NULL}, SCF_OP_ERROR, -1, -1, -1, _scf_op_semantic_error},
-
- {{NULL, NULL}, SCF_OP_IF, -1, -1, -1, _scf_op_semantic_if},
- {{NULL, NULL}, SCF_OP_WHILE, -1, -1, -1, _scf_op_semantic_while},
- {{NULL, NULL}, SCF_OP_REPEAT, -1, -1, -1, _scf_op_semantic_repeat},
- {{NULL, NULL}, SCF_OP_FOR, -1, -1, -1, _scf_op_semantic_for},
+ {{NULL, NULL}, SCF_OP_EXPR, _scf_op_semantic_expr},
+ {{NULL, NULL}, SCF_OP_CALL, _scf_op_semantic_call},
+
+ {{NULL, NULL}, SCF_OP_ARRAY_INDEX, _scf_op_semantic_array_index},
+ {{NULL, NULL}, SCF_OP_POINTER, _scf_op_semantic_pointer},
+ {{NULL, NULL}, SCF_OP_CREATE, _scf_op_semantic_create},
+
+ {{NULL, NULL}, SCF_OP_VA_START, _scf_op_semantic_va_start},
+ {{NULL, NULL}, SCF_OP_VA_ARG, _scf_op_semantic_va_arg},
+ {{NULL, NULL}, SCF_OP_VA_END, _scf_op_semantic_va_end},
+
+ {{NULL, NULL}, SCF_OP_CONTAINER, _scf_op_semantic_container},
+
+ {{NULL, NULL}, SCF_OP_SIZEOF, _scf_op_semantic_sizeof},
+ {{NULL, NULL}, SCF_OP_TYPE_CAST, _scf_op_semantic_type_cast},
+ {{NULL, NULL}, SCF_OP_LOGIC_NOT, _scf_op_semantic_logic_not},
+ {{NULL, NULL}, SCF_OP_BIT_NOT, _scf_op_semantic_bit_not},
+ {{NULL, NULL}, SCF_OP_NEG, _scf_op_semantic_neg},
+ {{NULL, NULL}, SCF_OP_POSITIVE, _scf_op_semantic_positive},
+
+ {{NULL, NULL}, SCF_OP_INC, _scf_op_semantic_inc},
+ {{NULL, NULL}, SCF_OP_DEC, _scf_op_semantic_dec},
+
+ {{NULL, NULL}, SCF_OP_INC_POST, _scf_op_semantic_inc_post},
+ {{NULL, NULL}, SCF_OP_DEC_POST, _scf_op_semantic_dec_post},
+
+ {{NULL, NULL}, SCF_OP_DEREFERENCE, _scf_op_semantic_dereference},
+ {{NULL, NULL}, SCF_OP_ADDRESS_OF, _scf_op_semantic_address_of},
+
+ {{NULL, NULL}, SCF_OP_MUL, _scf_op_semantic_mul},
+ {{NULL, NULL}, SCF_OP_DIV, _scf_op_semantic_div},
+ {{NULL, NULL}, SCF_OP_MOD, _scf_op_semantic_mod},
+
+ {{NULL, NULL}, SCF_OP_ADD, _scf_op_semantic_add},
+ {{NULL, NULL}, SCF_OP_SUB, _scf_op_semantic_sub},
+
+ {{NULL, NULL}, SCF_OP_SHL, _scf_op_semantic_shl},
+ {{NULL, NULL}, SCF_OP_SHR, _scf_op_semantic_shr},
+
+ {{NULL, NULL}, SCF_OP_BIT_AND, _scf_op_semantic_bit_and},
+ {{NULL, NULL}, SCF_OP_BIT_OR, _scf_op_semantic_bit_or},
+
+ {{NULL, NULL}, SCF_OP_EQ, _scf_op_semantic_eq},
+ {{NULL, NULL}, SCF_OP_NE, _scf_op_semantic_ne},
+ {{NULL, NULL}, SCF_OP_GT, _scf_op_semantic_gt},
+ {{NULL, NULL}, SCF_OP_LT, _scf_op_semantic_lt},
+ {{NULL, NULL}, SCF_OP_GE, _scf_op_semantic_ge},
+ {{NULL, NULL}, SCF_OP_LE, _scf_op_semantic_le},
+
+ {{NULL, NULL}, SCF_OP_LOGIC_AND, _scf_op_semantic_logic_and},
+ {{NULL, NULL}, SCF_OP_LOGIC_OR, _scf_op_semantic_logic_or},
+
+ {{NULL, NULL}, SCF_OP_ASSIGN, _scf_op_semantic_assign},
+ {{NULL, NULL}, SCF_OP_ADD_ASSIGN, _scf_op_semantic_add_assign},
+ {{NULL, NULL}, SCF_OP_SUB_ASSIGN, _scf_op_semantic_sub_assign},
+ {{NULL, NULL}, SCF_OP_MUL_ASSIGN, _scf_op_semantic_mul_assign},
+ {{NULL, NULL}, SCF_OP_DIV_ASSIGN, _scf_op_semantic_div_assign},
+ {{NULL, NULL}, SCF_OP_MOD_ASSIGN, _scf_op_semantic_mod_assign},
+ {{NULL, NULL}, SCF_OP_SHL_ASSIGN, _scf_op_semantic_shl_assign},
+ {{NULL, NULL}, SCF_OP_SHR_ASSIGN, _scf_op_semantic_shr_assign},
+ {{NULL, NULL}, SCF_OP_AND_ASSIGN, _scf_op_semantic_and_assign},
+ {{NULL, NULL}, SCF_OP_OR_ASSIGN, _scf_op_semantic_or_assign},
+
+ {{NULL, NULL}, SCF_OP_BLOCK, _scf_op_semantic_block},
+ {{NULL, NULL}, SCF_OP_RETURN, _scf_op_semantic_return},
+ {{NULL, NULL}, SCF_OP_BREAK, _scf_op_semantic_break},
+ {{NULL, NULL}, SCF_OP_CONTINUE, _scf_op_semantic_continue},
+ {{NULL, NULL}, SCF_OP_GOTO, _scf_op_semantic_goto},
+ {{NULL, NULL}, SCF_LABEL, _scf_op_semantic_label},
+ {{NULL, NULL}, SCF_OP_ERROR, _scf_op_semantic_error},
+
+ {{NULL, NULL}, SCF_OP_IF, _scf_op_semantic_if},
+ {{NULL, NULL}, SCF_OP_WHILE, _scf_op_semantic_while},
+ {{NULL, NULL}, SCF_OP_REPEAT, _scf_op_semantic_repeat},
+ {{NULL, NULL}, SCF_OP_FOR, _scf_op_semantic_for},
};
scf_operator_handler_t* scf_find_semantic_operator_handler(const int type, const int src0_type, const int src1_type, const int ret_type)
scf_parse_t* parse = calloc(1, sizeof(scf_parse_t));
assert(parse);
- scf_list_init(&parse->word_list_head);
- scf_list_init(&parse->error_list_head);
-
- scf_list_init(&parse->code_list_head);
-
if (scf_ast_open(&parse->ast) < 0) {
scf_loge("\n");
return -1;
#define SCF_SHNDX_DEBUG_LINE 6
#define SCF_SHNDX_DEBUG_STR 7
-struct scf_parse_s {
- scf_list_t word_list_head; // word list head
- scf_list_t error_list_head; // error list head
-
- scf_list_t code_list_head; // 3ac code list head
-
+struct scf_parse_s
+{
scf_lex_t* lex;
scf_ast_t* ast;
scf_lex_word_t* current_async_w;
- // every dimention has a vector,
- // every vector has init exprs for this dimention
scf_vector_t* init_exprs;
int current_dim;
scf_vector_t* current_index;