WONKY



LOG | FILES | OVERVIEW


F diff --git a/src/backend/asm/intel/intel_compile.c b/src/backend/asm/intel/intel_compile.c --- a/src/backend/asm/intel/intel_compile.c +++ b/src/backend/asm/intel/intel_compile.c
[OP_MULTIPLY_ASSIGN]=(map_entry)compile_mul_assign_to_intel_asm,
[OP_REMAINDER_ASSIGN]=(map_entry)compile_rem_assign_to_intel_asm,
[OP_DIV_ASSIGN]=(map_entry)compile_div_assign_to_intel_asm,
- [OP_SHIFT_LEFT_ASSIGN]=(map_entry)compile_shift_left_to_intel_asm,
- [OP_SHIFT_RIGHT_ASSIGN]=(map_entry)compile_shift_right_to_intel_asm,
+ [OP_SHIFT_LEFT_ASSIGN]=(map_entry)compile_shift_left_assign_to_intel_asm,
+ [OP_SHIFT_RIGHT_ASSIGN]=(map_entry)compile_shift_right_assign_to_intel_asm,
[OP_AND_ASSIGN]=(map_entry)compile_and_assign_to_intel_asm,
[OP_XOR_ASSIGN]=(map_entry)compile_xor_assign_to_intel_asm,
[OP_PIPE_ASSIGN]=(map_entry)compile_pipe_assign_to_intel_asm,
{
if(type_is_scalar(extract_expresion_value_type(bin->left->value)))
{
- enum Intel_Asm_Registers ax;
- enum Intel_Asm_Registers dx;
-
- compile_ast_to_intel_asm(compile_data,(struct AST*)bin->left);
- compile_ast_to_intel_asm(compile_data,(struct AST*)bin->right);
-
- dx=rvalue_to_dx(compile_data,bin->right->value);
- lvalue_to_rax(compile_data,bin->left->value);
-
- ax=get_ax_with_size(get_expression_value_size(bin->left->value));
-
- push_intel_asm_instruction(compile_data,
- get_intel_asm_binary_instruction(
- get_intel_asm_by_register(INTEL_ASM_REGISTER_RAX,get_expression_value_size(bin->left->value)),
- get_intel_asm_register(dx),
- INTEL_ASM_OP_MOV)
- );
-
- push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RAX));
+ compile_op_assign_inner(compile_data,bin,INTEL_ASM_OP_MOV);
}else
{
push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
}
void compile_rem_assign_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ enum Intel_Asm_Registers ax;
+ enum Intel_Asm_Registers dx;
+ int left_size;
+
+ left_size=get_expression_value_size(bin->left->value);
+ compile_ast_to_intel_asm(compile_data,(struct AST*)bin->left);
+ compile_ast_to_intel_asm(compile_data,(struct AST*)bin->right);
+
+ dx=rvalue_to_dx(compile_data,bin->right->value);
+ lvalue_to_rax(compile_data,bin->left->value);
+ ax=get_ax_with_size(left_size);
+
+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(get_intel_asm_register(INTEL_ASM_REGISTER_R11),
+ get_intel_asm_register(INTEL_ASM_REGISTER_RAX),
+ INTEL_ASM_OP_MOV));
+
+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(get_intel_asm_register(ax),
+ get_intel_asm_by_register(INTEL_ASM_REGISTER_RAX,left_size),
+ INTEL_ASM_OP_MOV));
+
+ push_intel_asm_instruction(compile_data,get_intel_asm_unary_instruction(get_intel_asm_register(dx),
+ INTEL_ASM_OP_DIV));
+
+ if(left_size!=1)
+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(get_intel_asm_by_register(INTEL_ASM_REGISTER_R11,left_size),
+ get_intel_asm_register(dx),
+ INTEL_ASM_OP_MOV));
+ else
+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(get_intel_asm_by_register(INTEL_ASM_REGISTER_R11,left_size),
+ get_intel_asm_register(INTEL_ASM_REGISTER_AL),
+ INTEL_ASM_OP_MOV));
+
+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_R11));
}
void compile_div_assign_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ enum Intel_Asm_Registers ax;
+ enum Intel_Asm_Registers dx;
+ int left_size;
+
+ left_size=get_expression_value_size(bin->left->value);
+ compile_ast_to_intel_asm(compile_data,(struct AST*)bin->left);
+ compile_ast_to_intel_asm(compile_data,(struct AST*)bin->right);
+
+ dx=rvalue_to_dx(compile_data,bin->right->value);
+ lvalue_to_rax(compile_data,bin->left->value);
+ ax=get_ax_with_size(left_size);
+
+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(get_intel_asm_register(INTEL_ASM_REGISTER_R11),
+ get_intel_asm_register(INTEL_ASM_REGISTER_RAX),
+ INTEL_ASM_OP_MOV));
+
+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(get_intel_asm_register(ax),
+ get_intel_asm_by_register(INTEL_ASM_REGISTER_RAX,left_size),
+ INTEL_ASM_OP_MOV));
+
+ push_intel_asm_instruction(compile_data,get_intel_asm_unary_instruction(get_intel_asm_register(dx),
+ INTEL_ASM_OP_DIV));
+
+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(get_intel_asm_by_register(INTEL_ASM_REGISTER_R11,left_size),
+ get_intel_asm_register(ax),
+ INTEL_ASM_OP_MOV));
+
+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_R11));
+
}
void compile_shift_left_assign_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ compile_shift_assign_inner(compile_data,bin,INTEL_ASM_OP_SAL);
}
void compile_shift_right_assign_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ compile_shift_assign_inner(compile_data,bin,INTEL_ASM_OP_SAR);
}
void compile_and_assign_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ compile_op_assign_inner(compile_data,bin,INTEL_ASM_OP_AND);
}
void compile_xor_assign_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ compile_op_assign_inner(compile_data,bin,INTEL_ASM_OP_XOR);
}
void compile_pipe_assign_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ compile_op_assign_inner(compile_data,bin,INTEL_ASM_OP_OR);
}
void compile_nop_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,void *dummy)
{
push_intel_asm_instruction(compile_data,(struct Intel_Asm_Instruction*)end);
}
+ void compile_op_assign_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin,enum Intel_Asm_Instruction_Type op)
+ {
+ enum Intel_Asm_Registers dx;
+
+ compile_ast_to_intel_asm(compile_data,(struct AST*)bin->left);
+ compile_ast_to_intel_asm(compile_data,(struct AST*)bin->right);
+
+ dx=rvalue_to_dx(compile_data,bin->right->value);
+ lvalue_to_rax(compile_data,bin->left->value);
+
+ push_intel_asm_instruction(compile_data,
+ get_intel_asm_binary_instruction(
+ get_intel_asm_by_register(INTEL_ASM_REGISTER_RAX,get_expression_value_size(bin->left->value)),
+ get_intel_asm_register(dx),
+ op)
+ );
+
+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RAX));
+ }
+ void compile_shift_assign_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin,enum Intel_Asm_Instruction_Type op)
+ {
+ enum Intel_Asm_Registers dx;
+
+ compile_ast_to_intel_asm(compile_data,(struct AST*)bin->left);
+ compile_ast_to_intel_asm(compile_data,(struct AST*)bin->right);
+
+ dx=rvalue_to_dx(compile_data,bin->right->value);
+ lvalue_to_rax(compile_data,bin->left->value);
+
+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(get_intel_asm_register(INTEL_ASM_REGISTER_CL),get_intel_asm_register(INTEL_ASM_REGISTER_DL),INTEL_ASM_OP_MOV));
+ push_intel_asm_instruction(compile_data,
+ get_intel_asm_binary_instruction(
+ get_intel_asm_by_register(INTEL_ASM_REGISTER_RAX,get_expression_value_size(bin->left->value)),
+ get_intel_asm_register(INTEL_ASM_REGISTER_CL),
+ op)
+ );
+
+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RAX));
+ }
#endif
F diff --git a/src/backend/asm/intel/intel_compile.h b/src/backend/asm/intel/intel_compile.h --- a/src/backend/asm/intel/intel_compile.h +++ b/src/backend/asm/intel/intel_compile.h
void compile_simple_bin_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin,enum Intel_Asm_Instruction_Type op);
void compile_mul_div_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin,enum Intel_Asm_Instruction_Type op);
void compile_logical_and_or_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin,enum Intel_Asm_Instruction_Type cmp);
+ void compile_op_assign_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin,enum Intel_Asm_Instruction_Type op);
+ void compile_shift_assign_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin,enum Intel_Asm_Instruction_Type op);
#endif
F diff --git a/src/debug/debug_ast.c b/src/debug/debug_ast.c --- a/src/debug/debug_ast.c +++ b/src/debug/debug_ast.c
[OP_REMAINDER_ASSIGN]=(debug_ast_function_ptr)is_valid_ast_expression,
[OP_DIV_ASSIGN]=(debug_ast_function_ptr)is_valid_ast_expression,
[OP_SHIFT_RIGHT_ASSIGN]=(debug_ast_function_ptr)is_valid_ast_expression,
+ [OP_SHIFT_LEFT_ASSIGN]=(debug_ast_function_ptr)is_valid_ast_expression,
[OP_AND_ASSIGN]=(debug_ast_function_ptr)is_valid_ast_expression,
[OP_XOR_ASSIGN]=(debug_ast_function_ptr)is_valid_ast_expression,
[OP_PIPE_ASSIGN]=(debug_ast_function_ptr)is_valid_ast_expression,
if(ast==NULL || !is_valid_ast_enum(ast->type) || debug_ast_vector[ast->type]==NULL)
return 0;
else
- return debug_ast_vector[ast->type];
+ return debug_ast_vector[ast->type](ast);
}
_Bool is_valid_ast_expression(struct AST_Expression *expression)
if(expression==NULL || !is_valid_ast_expression_enum(expression->type))
return 0;
else
- return is_valid_ast((struct AST*)expression);
+ return 1;
}
_Bool is_valid_ast_error(struct AST_Error *error)
{
F diff --git a/src/frontend/parse/parse_expression.c b/src/frontend/parse/parse_expression.c --- a/src/frontend/parse/parse_expression.c +++ b/src/frontend/parse/parse_expression.c
if(operation_type==OP_ASSIGN)
return (struct AST_Expression*)get_simple_assignment_expression_tree(hold_left_expression,hold_right_expression,translation_data);
else
- return (struct AST_Expression*)get_compound_assignment_expression_tree(hold_right_expression,hold_right_expression,operation_type,translation_data);
+ return (struct AST_Expression*)get_compound_assignment_expression_tree(hold_left_expression,hold_right_expression,operation_type,translation_data);
}
/*
F diff --git a/src/wonky.c b/src/wonky.c --- a/src/wonky.c +++ b/src/wonky.c
}
if(command_arguments->print_tokens && !command_arguments->is_quiet)
{
- wonky_memory_delete();
- return print_tokens_of_program(stdout,command_arguments->source_names);
+ if(print_tokens_of_program(stdout,command_arguments->source_names))
+ {
+ return 0;
+ wonky_memory_delete();
+ }else
+ {
+ return 0;
+ wonky_memory_delete();
+ }
}else
{
program=parse_program(command_arguments->source_names);