WONKY



LOG | FILES | OVERVIEW


F diff --git a/src/backend/asm/intel/intel_asm.c b/src/backend/asm/intel/intel_asm.c --- a/src/backend/asm/intel/intel_asm.c +++ b/src/backend/asm/intel/intel_asm.c
data=get_compile_data_for_intel_asm();
+
for(it=program->translation_units->first;it!=NULL;it=it->prev)
compile_translation_unit_to_intel_asm(data,it->data);
- struct Intel_Asm_Instruction* intel_asm_get_push_ax()
+ struct Intel_Asm_Instruction* intel_asm_get_push_rax()
{
return get_intel_asm_unary_instruction(intel_asm_get_ax_register(),INTEL_ASM_OP_PUSH);
}
- struct Intel_Asm_Instruction* intel_asm_get_pop_ax()
+ struct Intel_Asm_Instruction* intel_asm_get_pop_rax()
{
return get_intel_asm_unary_instruction(intel_asm_get_ax_register(),INTEL_ASM_OP_POP);
}
- struct Intel_Asm_Instruction* intel_asm_get_pop_dx()
+ struct Intel_Asm_Instruction* intel_asm_get_pop_rdx()
{
return get_intel_asm_unary_instruction(intel_asm_get_dx_register(),INTEL_ASM_OP_POP);
}
-
void push_intel_asm_instruction(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Instruction *instruction)
{
Queue_Push(compile_data->instructions,instruction);
}
+ void reserve_stack_space(struct Compile_Data_Intel_Asm *compile_data,int size)
+ {
+ push_intel_asm_instruction(compile_data,
+ get_intel_asm_binary_instruction(
+ get_intel_asm_register(INTEL_ASM_REGISTER_SP),
+ get_intel_asm_in_instruction_number(size),
+ INTEL_ASM_OP_SUB
+ )
+ );
+ }
+ void release_stack_space(struct Compile_Data_Intel_Asm *compile_data,int size)
+ {
+ push_intel_asm_instruction(compile_data,
+ get_intel_asm_binary_instruction(
+ get_intel_asm_register(INTEL_ASM_REGISTER_SP),
+ get_intel_asm_in_instruction_number(size),
+ INTEL_ASM_OP_ADD
+ )
+ );
+ }
+ struct Intel_Asm_Memory_Location* reserve_static_space_for_object(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Label *label,int size)
+ {
+
+ }
+ struct Intel_Asm_Memory_Location* reserve_static_space_for_string(struct Compile_Data_Intel_Asm *compile_data,struct Constant *string)
+ {
+ struct Intel_Asm_Instruction *label;
+ struct Intel_Asm_Instruction *db;
+ struct Type_Array *string_type;
+
+ wonky_assert(string->type->specifier==TS_ARRAY && string->value!=NULL);
+
+ string_type=(struct Type_Array*)string->type;
+ db=get_intel_asm_define_bytes(string->value,string_type->size);
+ label=get_intel_asm_new_unique_label(compile_data);
+
+ Queue_Push_Front(compile_data->instructions,db);
+ Queue_Push_Front(compile_data->instructions,label);
+
+ return get_intel_asm_label_location((struct Intel_Asm_Label*)label);
+ }
+ struct Intel_Asm_Memory_Location* push_declaration_on_stack_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Object_Declaration *declaration)
+ {
+ int size;
+ size=get_type_size(declaration->object->object->type);
+ reserve_stack_space(compile_data,size);
+ return get_intel_asm_stack_offset(size);
+ }
+ void release_stack_space_for_whole_block_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Normal_Scope *scope)
+ {
+ int whole_size=0;
+ struct Queue_Node *it;
+ for(it=scope->object_order->first;it!=NULL;it=it->prev)
+ whole_size+=get_type_size(((struct Denoted_Object*)it->data)->object->type);
+ release_stack_space(compile_data,whole_size);
+ }
+ void intel_asm_memory_location_to_rax(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Memory_Location *location)
+ {
+ switch(location->type)
+ {
+ case INTEL_ASM_MEMORY_LOCATION_REGISTER:
+ case INTEL_ASM_MEMORY_LOCATION_BY_LABEL:
+ case INTEL_ASM_MEMORY_LOCATION_BY_REGISTER:
+ case INTEL_ASM_MEMORY_LOCATION_IN_INSTRUCTION_NUMBER:
+ push_intel_asm_instruction(
+ compile_data,
+ get_intel_asm_binary_instruction(get_intel_asm_register(INTEL_ASM_REGISTER_RAX),location,INTEL_ASM_OP_MOV)
+ );
+ break;
+ case INTEL_ASM_MEMORY_LOCATION_BY_STACK_OFFSET:
+ push_intel_asm_instruction(
+ compile_data,
+ get_intel_asm_binary_instruction(get_intel_asm_register(INTEL_ASM_REGISTER_RAX),location,INTEL_ASM_OP_MOV)
+ );
+ push_intel_asm_instruction(
+ compile_data,
+ get_intel_asm_binary_instruction(
+ get_intel_asm_register(INTEL_ASM_REGISTER_RAX),
+ get_intel_asm_in_instruction_number(
+ ((struct Intel_Asm_Memory_Location_By_Stack_Offset*)location)->offset
+ ),
+ INTEL_ASM_OP_ADD
+ )
+ );
+ break;
+ default:
+ wonky_assert(SHOULD_NOT_REACH_HERE);
+ }
+ }
+ struct Intel_Asm_Memory_Location* reserve_space_for_value_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value)
+ {
+ int size;
+ size=get_expression_value_size(value);
+ reserve_stack_space(compile_data,size);
+ return get_intel_asm_stack_offset(size);
+ }
+ void release_value_from_stack(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value)
+ {
+ release_stack_space(compile_data,get_expression_value_size(value));
+ }
+ struct Intel_Asm_Memory_Location* get_location_of_value(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value)
+ {
+ switch(value->type)
+ {
+ case VALUE_LVALUE:
+ return (struct Intel_Asm_Memory_Location*)((struct Expression_Value_LValue*)value)->object->location;
+ case VALUE_TEMP:
+ return (struct Intel_Asm_Memory_Location*)((struct Expression_Value_RValue*)value)->temp_object->location;
+ case VALUE_FUNCTION_DESIGNATOR:
+ return (struct Intel_Asm_Memory_Location*)((struct Expression_Value_Function_Designator*)value)->function->location;
+ case VALUE_CONSTANT:
+ return get_location_of_constant(compile_data,((struct Expression_Value_Constant*)value)->constant);
+ case VALUE_VOID:
+ default:
+ wonky_assert(SHOULD_NOT_REACH_HERE);
+ }
+ }
+ struct Intel_Asm_Memory_Location* get_location_of_constant(struct Compile_Data_Intel_Asm *compile_data,struct Constant *constant)
+ {
+ wonky_assert(constant->type->specifier==TS_INT);
+ return get_intel_asm_in_instruction_number(*(int*)constant->value);
+ }
+ void intel_asm_anotate_denoted(struct Denoted *denoted,struct Compile_Data_Intel_Asm *compile_data)
+ {
+ if(denoted->denotation==DT_Function)
+ {
+ intel_asm_anotate_function(compile_data,(struct Denoted_Function*)denoted);
+ }
+ //wonky_assert(SHOULD_NOT_REACH_HERE);
+ }
+ void intel_asm_anotate_function(struct Compile_Data_Intel_Asm *compile_data,struct Denoted_Function *function)
+ {
+ struct token *id;
+ struct Intel_Asm_Memory_Location_By_Label *location;
+ id=function->id;
+ location=(struct Intel_Asm_Memory_Location_By_Label*)
+ get_intel_asm_label_location(
+ (struct Intel_Asm_Label*)get_intel_asm_label(gstr_dup(id->data,id->data+id->data_size,1024))
+ );
+
+ function->location=(struct Location*)location;
+ }
#endif
F diff --git a/src/backend/asm/intel/intel_asm.h b/src/backend/asm/intel/intel_asm.h --- a/src/backend/asm/intel/intel_asm.h +++ b/src/backend/asm/intel/intel_asm.h
#include <queue.h>
#include <ast.h>
#include <value.h>
-
+ #include <constant.h>
struct Compile_Data_Intel_Asm
{
struct Compiled_Object_Intel_Asm* compile_program_to_intel_asm(struct Program *program);
+ void compile_program_static_objects(struct Compile_Data *obj,struct Program *program);
+
void save_compiled_intel_asm(struct Compiled_Object_Intel_Asm *object,FILE *out);
struct Compile_Data_Intel_Asm* get_compile_data_for_intel_asm();
void push_intel_asm_instruction(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Instruction *instruction);
- struct Intel_Asm_Memory_Location* reserve_space_for_value_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value);
void free_space_taken_for_value_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Memory_Location *location);
void memcpy_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Memory_Location *destination,struct Intel_Asm_Memory_Location *source);
- void extract_value_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Memory_Location *location);
- void push_declaration_on_stack_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Object_Declaration *declaration);
- void release_stack_space_for_whole_block_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Scope *scope);
+ void reserve_stack_space(struct Compile_Data_Intel_Asm *compile_data,int size);
+ void release_stack_space(struct Compile_Data_Intel_Asm *compile_data,int size);
+
+ struct Intel_Asm_Memory_Location* reserve_static_space_for_object(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Label *label,int size);
+ struct Intel_Asm_Memory_Location* reserve_static_space_for_string(struct Compile_Data_Intel_Asm *compile_data,struct Constant *string);
+
+ struct Intel_Asm_Memory_Location* push_declaration_on_stack_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Object_Declaration *declaration);
+ void release_stack_space_for_whole_block_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Normal_Scope *scope);
+
+
+ void intel_asm_memory_location_to_rax(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Memory_Location *location);
+
+ struct Intel_Asm_Memory_Location* reserve_space_for_value_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value);
+ void release_value_from_stack(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value);
+
+ struct Intel_Asm_Memory_Location* get_location_of_value(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value);
+ struct Intel_Asm_Memory_Location* get_location_of_constant(struct Compile_Data_Intel_Asm *compile_data,struct Constant *constant);
- void enter_function_intel_asm(struct Compile_Data_Intel_Asm *compile_data);
- void leave_function_intel_asm(struct Compile_Data_Intel_Asm *compile_data);
+ void intel_asm_anotate_denoted(struct Denoted *denoted,struct Compile_Data_Intel_Asm *compile_data);
+ void intel_asm_anotate_function(struct Compile_Data_Intel_Asm *compile_data,struct Denoted_Function *func);
#endif
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
compile_ast_to_intel_asm(compile_data,(struct AST*)expression->left);
- push_intel_asm_instruction(compile_data,intel_asm_get_pop_ax());
+ push_intel_asm_instruction(compile_data,intel_asm_get_pop(INTEL_ASM_REGISTER_RAX));
push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(ax_register,ax_register,INTEL_ASM_OP_TEST));
push_intel_asm_instruction(compile_data,get_intel_asm_jump_instruction(second,INTEL_ASM_OP_JZ));
}
void compile_function_expression_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Function_Expression *call)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ /*the x64 abi is a little more complex TODO*/
+ static const enum Intel_Asm_Registers register_order[6]
+ =
+ {
+ [0]=INTEL_ASM_REGISTER_RDI,
+ [1]=INTEL_ASM_REGISTER_RSI,
+ [2]=INTEL_ASM_REGISTER_RDX,
+ [3]=INTEL_ASM_REGISTER_RCX,
+ [4]=INTEL_ASM_REGISTER_R8,
+ [5]=INTEL_ASM_REGISTER_R9,
+ };
+ int current_register=0;
+ size_t i;
+
+
+ for(i=0;i<call->number_of_arguments;++i)
+ {
+ compile_ast_to_intel_asm(compile_data,(struct AST*)call->arg_list[i]);
+ if(get_expression_value_size(call->arg_list[i]->value)<=8 && current_register<6)
+ {
+ push_intel_asm_instruction(compile_data,intel_asm_get_pop(register_order[current_register]));
+ ++current_register;
+ }
+ }
+ compile_ast_to_intel_asm(compile_data,(struct AST*)call->id);
+ push_intel_asm_instruction(compile_data,intel_asm_get_pop(INTEL_ASM_REGISTER_RAX));
+
+ push_intel_asm_instruction(compile_data,get_intel_asm_unary_instruction(get_intel_asm_register(INTEL_ASM_REGISTER_RAX),INTEL_ASM_OP_CALL));
}
void compile_constant_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Constant *constant)
{
}
void compile_string_literal_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_String_Literal *literal)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ struct Intel_Asm_Memory_Location *string_location;
+ string_location=reserve_static_space_for_string(compile_data,literal->value->constant);
+ push_intel_asm_instruction(compile_data,
+ get_intel_asm_binary_instruction(
+ get_intel_asm_register(INTEL_ASM_REGISTER_RAX),
+ string_location,
+ INTEL_ASM_OP_MOV
+ )
+ );
+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RAX));
}
void compile_designator_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Designator *designator)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ intel_asm_memory_location_to_rax(compile_data,get_location_of_value(compile_data,designator->value));
+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RAX));
}
void compile_labeled_statement_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Labeled_Statement *labeled)
{
}
void compile_return_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Return_Statement *ret)
{
- push_intel_asm_instruction(compile_data,intel_asm_get_pop_ax());
+ push_intel_asm_instruction(compile_data,intel_asm_get_pop(INTEL_ASM_REGISTER_RAX));
push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_RET));
}
void compile_object_declaration_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Object_Declaration *objd)
}
void compile_function_definition_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Function_Definition *def)
{
- struct token *id;
- id=def->function->id;
- push_intel_asm_instruction(compile_data,get_intel_asm_label(gstr_dup(id->data,id->data+id->data_size,1024)));
+ push_intel_asm_instruction(compile_data,((struct Intel_Asm_Instruction*)def->function->location));
compile_compound_statement_to_intel_asm(compile_data,def->body);
/*if there are no returns we return jiberrish*/
void compile_translation_unit_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Translation_Unit *unit)
{
struct Queue_Node *it;
+ Map_Map_Extended(&((struct Normal_Scope*)unit->file_scope)->ordinary,(void (*)(void*,void*))intel_asm_anotate_denoted,compile_data);
for(it=unit->function_definitions->first;it!=NULL;it=it->prev)
compile_ast_to_intel_asm(compile_data,it->data);
}
{
compile_ast_to_intel_asm(compile_data,(struct AST*)bin->left);
compile_ast_to_intel_asm(compile_data,(struct AST*)bin->right);
- push_intel_asm_instruction(compile_data,intel_asm_get_pop_ax());
- push_intel_asm_instruction(compile_data,intel_asm_get_pop_dx());
+ push_intel_asm_instruction(compile_data,intel_asm_get_pop(INTEL_ASM_REGISTER_RAX));
+ push_intel_asm_instruction(compile_data,intel_asm_get_pop(INTEL_ASM_REGISTER_DX));
push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(intel_asm_get_ax_register(),intel_asm_get_dx_register(),INTEL_ASM_OP_ADD));
- push_intel_asm_instruction(compile_data,intel_asm_get_push_ax());
+ push_intel_asm_instruction(compile_data,intel_asm_get_pop(INTEL_ASM_REGISTER_RAX));
}
void compile_pointer_addition_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin)
{
}
void compile_get_address_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ intel_asm_memory_location_to_rax(compile_data,get_location_of_value(compile_data,unary->operand->value));
+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RAX));
}
void compile_dereference_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ intel_asm_memory_location_to_rax(compile_data,get_location_of_value(compile_data,unary->operand->value));
+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RAX));
}
void compile_member_from_ptr_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin)
{
}
void compile_cast_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary)
{
- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));
+ compile_ast_to_intel_asm(compile_data,(struct AST*)unary->operand);
}
void compile_shift_left_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin)
{
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
#include <intel_asm.h>
#include <ast.h>
+ #include <map.h>
void compile_binary_expression(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin);
void compile_unary_expression(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary);
F diff --git a/src/backend/asm/intel/intel_instruction.c b/src/backend/asm/intel/intel_instruction.c --- a/src/backend/asm/intel/intel_instruction.c +++ b/src/backend/asm/intel/intel_instruction.c
return (struct Intel_Asm_Instruction*)ret;
}
-
struct Intel_Asm_Instruction* get_intel_asm_simple_instruction(enum Intel_Asm_Instruction_Type type)
{
struct Intel_Asm_Instruction *ret;
return ret;
}
+ struct Intel_Asm_Instruction* get_intel_asm_define_bytes(unsigned char *bytes,int number_of_bytes)
+ {
+ struct Intel_Asm_Instruction_Define_Bytes *ret;
+ int i;
+ ret=malloc(sizeof(struct Intel_Asm_Instruction_Define_Bytes));
+ ret->type=INTEL_ASM_OP_DEFINE_BYTES;
+ ret->number_of_bytes=number_of_bytes;
+ ret->bytes=malloc(number_of_bytes);
+
+ for(i=0;i<number_of_bytes;++i)
+ ret->bytes[i]=bytes[i];
+
+ return (struct Intel_Asm_Instruction*)ret;
+ }
+ struct Intel_Asm_Instruction* intel_asm_get_pop(enum Intel_Asm_Memory_Location_Type reg)
+ {
+ return get_intel_asm_unary_instruction(get_intel_asm_register(reg),INTEL_ASM_OP_POP);
+ }
+ struct Intel_Asm_Instruction* intel_asm_get_push(enum Intel_Asm_Memory_Location_Type reg)
+ {
+ return get_intel_asm_unary_instruction(get_intel_asm_register(reg),INTEL_ASM_OP_PUSH);
+ }
void save_intel_asm_instruction(struct Intel_Asm_Instruction *instruction,FILE *out)
{
typedef void (*map_entry)(void *,FILE *out);
[INTEL_ASM_OP_JNZ]=(map_entry)save_intel_asm_jump_instruction,
[INTEL_ASM_OP_JZ]=(map_entry)save_intel_asm_jump_instruction,
[INTEL_ASM_OP_RET]=(map_entry)save_intel_asm_simple_instruction,
- [INTEL_ASM_OP_CALL]=(map_entry)save_intel_asm_jump_instruction,
+ [INTEL_ASM_OP_CALL]=(map_entry)save_intel_asm_unary_instruction,
[INTEL_ASM_OP_AND]=(map_entry)save_intel_asm_binary_instruction,
[INTEL_ASM_OP_XOR]=(map_entry)save_intel_asm_binary_instruction,
[INTEL_ASM_OP_OR]=(map_entry)save_intel_asm_binary_instruction,
[INTEL_ASM_OP_LABEL]=(map_entry)save_intel_asm_label,
[INTEL_ASM_OP_POP]=(map_entry)save_intel_asm_unary_instruction,
[INTEL_ASM_OP_PUSH]=(map_entry)save_intel_asm_unary_instruction,
+ [INTEL_ASM_OP_DEFINE_BYTES]=(map_entry)save_intel_asm_define_bytes,
};
wonky_assert(map[instruction->type]!=NULL);
map[instruction->type](instruction,out);
{
[INTEL_ASM_OP_POP]="POP",
[INTEL_ASM_OP_PUSH]="PUSH",
+ [INTEL_ASM_OP_CALL]="CALL",
};
wonky_assert(map[unary->type]!=NULL);
fprintf(out,"%s ",map[unary->type]);
[INTEL_ASM_OP_JL]="JL",
[INTEL_ASM_OP_JNZ]="JNZ",
[INTEL_ASM_OP_JZ]="JZ",
- [INTEL_ASM_OP_CALL]="CALL",
};
wonky_assert(map[jmp->type]!=NULL);
fprintf(out,"%s ",map[jmp->type]);
fprintf(out,"%s\n",map[instruction->type]);
}
+ void save_intel_asm_define_bytes(struct Intel_Asm_Instruction_Define_Bytes *instruction,FILE *out)
+ {
+ int i;
+
+ fprintf(out,"db ");
+ for(i=0;i<instruction->number_of_bytes;++i)
+ {
+ fprintf(out,"0x%x",instruction->bytes[i]);
+ if(i<instruction->number_of_bytes-1)
+ fprintf(out,", ");
+ }
+ fprintf(out,"\n");
+ }
#endif
F diff --git a/src/backend/asm/intel/intel_instruction.h b/src/backend/asm/intel/intel_instruction.h --- a/src/backend/asm/intel/intel_instruction.h +++ b/src/backend/asm/intel/intel_instruction.h
#define WONKY_INTEL_ASM_INSTRUCTION_H WONKY_INTEL_ASM_INSTRUCTION_H
#include <intel_instruction.hh>
+ #include <intel_location.h>
#include <intel_asm.h>
#include <stdio.h>
#include <stdlib.h>
struct Intel_Asm_Label *where_to;
};
+ struct Intel_Asm_Instruction_Define_Bytes
+ {
+ enum Intel_Asm_Instruction_Type type;
+
+ int number_of_bytes;
+ unsigned char *bytes;
+
+ };
struct Intel_Asm_Instruction* get_intel_asm_label(char *label);
struct Intel_Asm_Instruction* get_intel_asm_new_unique_label(struct Compile_Data_Intel_Asm *compile_data);
struct Intel_Asm_Instruction* get_intel_asm_unary_instruction(struct Intel_Asm_Memory_Location *operand,enum Intel_Asm_Instruction_Type type);
struct Intel_Asm_Instruction* get_intel_asm_jump_instruction(struct Intel_Asm_Label *where_to,enum Intel_Asm_Instruction_Type type);
struct Intel_Asm_Instruction* get_intel_asm_simple_instruction(enum Intel_Asm_Instruction_Type type);
+ struct Intel_Asm_Instruction* get_intel_asm_define_bytes(unsigned char *bytes,int number_of_bytes);
- struct Intel_Asm_Instruction* intel_asm_get_push_ax();
- struct Intel_Asm_Instruction* intel_asm_get_pop_ax();
- struct Intel_Asm_Instruction* intel_asm_get_pop_dx();
+ struct Intel_Asm_Instruction* intel_asm_get_pop(enum Intel_Asm_Memory_Location_Type reg);
+ struct Intel_Asm_Instruction* intel_asm_get_push(enum Intel_Asm_Memory_Location_Type reg);
void save_intel_asm_instruction(struct Intel_Asm_Instruction *instruction,FILE *out);
void save_intel_asm_label(struct Intel_Asm_Label *label,FILE *out);
void save_intel_asm_unary_instruction(struct Intel_Asm_Instruction_Unary *unary,FILE *out);
void save_intel_asm_jump_instruction(struct Intel_Asm_Instruction_Jump *jmp,FILE *out);
void save_intel_asm_simple_instruction(struct Intel_Asm_Instruction *instruction,FILE *out);
+ void save_intel_asm_define_bytes(struct Intel_Asm_Instruction_Define_Bytes *instruction,FILE *out);
#endif
F diff --git a/src/backend/asm/intel/intel_instruction.hh b/src/backend/asm/intel/intel_instruction.hh --- a/src/backend/asm/intel/intel_instruction.hh +++ b/src/backend/asm/intel/intel_instruction.hh
INTEL_ASM_OP_LABEL,
INTEL_ASM_OP_POP,
INTEL_ASM_OP_PUSH,
+ INTEL_ASM_OP_DEFINE_BYTES,
INTEL_ASM_OP_END
};
struct Intel_Asm_Instruction_Binary;
struct Intel_Asm_Instruction_Unary;
struct Intel_Asm_Instruction_Jump;
-
+ struct Intel_Asm_Instruction_Define_Bytes;
#endif
F diff --git a/src/backend/asm/intel/intel_location.c b/src/backend/asm/intel/intel_location.c --- a/src/backend/asm/intel/intel_location.c +++ b/src/backend/asm/intel/intel_location.c
#ifndef WONKY_INTEL_ASM_LOCATION_C
#define WONKY_INTEL_ASM_LOCATION_C WONKY_INTEL_ASM_LOCATION_C
#include <intel_location.h>
+ static const char *register_map[INTEL_ASM_REGISTER_END]
+ =
+ {
+ [INTEL_ASM_REGISTER_AX]="AX",
+ [INTEL_ASM_REGISTER_BX]="BX",
+ [INTEL_ASM_REGISTER_DX]="DX",
+ [INTEL_ASM_REGISTER_DI]="DI",
+ [INTEL_ASM_REGISTER_SI]="SI",
+ [INTEL_ASM_REGISTER_CX]="CX",
+ [INTEL_ASM_REGISTER_SP]="SP",
+ [INTEL_ASM_REGISTER_RDI]="RDI",
+ [INTEL_ASM_REGISTER_RSI]="RSI",
+ [INTEL_ASM_REGISTER_RDX]="RDX",
+ [INTEL_ASM_REGISTER_RCX]="RCX",
+ [INTEL_ASM_REGISTER_R8]="R8",
+ [INTEL_ASM_REGISTER_R9]="R9",
+ [INTEL_ASM_REGISTER_RAX]="RAX",
+ };
struct Intel_Asm_Memory_Location* get_intel_by_asm_register(enum Intel_Asm_Registers reg)
{
}
void save_intel_asm_by_register_location(struct Intel_Asm_Memory_Location_By_Register *reg,FILE *out)
{
- static const char *map[INTEL_ASM_REGISTER_END]
- =
- {
- [INTEL_ASM_REGISTER_AX]="AX",
- [INTEL_ASM_REGISTER_BX]="BX",
- [INTEL_ASM_REGISTER_DX]="DX",
- [INTEL_ASM_REGISTER_DI]="DI",
- [INTEL_ASM_REGISTER_SI]="SI",
- [INTEL_ASM_REGISTER_CX]="CX",
- [INTEL_ASM_REGISTER_SP]="SP",
- };
- wonky_assert(map[reg->reg]!=NULL);
- fprintf(out,"[%s]",map[reg->reg]);
+ wonky_assert(register_map[reg->reg]!=NULL);
+ fprintf(out,"[%s]",register_map[reg->reg]);
}
void save_intel_asm_register_location(struct Intel_Asm_Memory_Location_Register *reg,FILE *out)
{
- static const char *map[INTEL_ASM_REGISTER_END]
- =
- {
- [INTEL_ASM_REGISTER_AX]="AX",
- [INTEL_ASM_REGISTER_BX]="BX",
- [INTEL_ASM_REGISTER_DX]="DX",
- [INTEL_ASM_REGISTER_DI]="DI",
- [INTEL_ASM_REGISTER_SI]="SI",
- [INTEL_ASM_REGISTER_CX]="CX",
- [INTEL_ASM_REGISTER_SP]="SP",
- };
-
- wonky_assert(map[reg->reg]!=NULL);
- fprintf(out,"%s",map[reg->reg]);
+ wonky_assert(register_map[reg->reg]!=NULL);
+ fprintf(out,"%s",register_map[reg->reg]);
}
void save_intel_asm_location(struct Intel_Asm_Memory_Location *location,FILE *out)
{
F diff --git a/src/backend/asm/intel/intel_location.hh b/src/backend/asm/intel/intel_location.hh --- a/src/backend/asm/intel/intel_location.hh +++ b/src/backend/asm/intel/intel_location.hh
INTEL_ASM_REGISTER_SI,
INTEL_ASM_REGISTER_CX,
INTEL_ASM_REGISTER_SP,
+
+ INTEL_ASM_REGISTER_RDI,
+ INTEL_ASM_REGISTER_RSI,
+ INTEL_ASM_REGISTER_RDX,
+ INTEL_ASM_REGISTER_RCX,
+ INTEL_ASM_REGISTER_R8,
+ INTEL_ASM_REGISTER_R9,
+
+ INTEL_ASM_REGISTER_RAX,
+
INTEL_ASM_REGISTER_END
};
F diff --git a/src/backend/text/print/print.c b/src/backend/text/print/print.c --- a/src/backend/text/print/print.c +++ b/src/backend/text/print/print.c
}
ret=0;
- hold_translation_data=get_translation_data(NULL,get_linkage(),get_linkage());
+ hold_translation_data=get_translation_data(NULL,get_linkage(),get_linkage());
do
{
base_file=get_source_file(*base_source_names,this_directory);
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
for(it=unit->function_definitions->first;it!=NULL;it=it->prev)
if(!is_valid_ast(it->data))
return 0;
- for(it=unit->static_objects->first;it!=NULL;it=it->prev)
- if(!is_valid_ast(it->data))
- return 0;
if(!is_valid_scope(unit->file_scope))
return 0;
F diff --git a/src/frontend/parse/parse_declaration.c b/src/frontend/parse/parse_declaration.c --- a/src/frontend/parse/parse_declaration.c +++ b/src/frontend/parse/parse_declaration.c
void parse_external_definition(struct Translation_Data *translation_data,struct AST_Translation_Unit *unit)
{
- parse_declaration_inner(translation_data,unit->file_scope,unit->static_objects,unit->function_definitions,1);
+ parse_declaration_inner(translation_data,unit->file_scope,unit->object_declarations,unit->function_definitions,1);
}
void parse_declaration(struct Translation_Data *translation_data,struct Scope *scope,struct Queue *where_to_push_declarations)
{
F diff --git a/src/semantics/ast.c b/src/semantics/ast.c --- a/src/semantics/ast.c +++ b/src/semantics/ast.c
return operand;
}
+ struct AST_Expression* get_promoted_expression_for_function_call(struct AST_Expression *operand,struct Translation_Data *translation_data)
+ {
+ struct Type *operand_type;
+
+ operand_type=extract_expresion_value_type(operand->value,translation_data);
+ if(operand_type->specifier==TS_FLOAT)
+ {
+ return get_cast_expression_tree(operand,(struct Type*)get_type_insecure(TS_DOUBLE,TSIGN_NONE,TC_NONE,DOUBLE_SIZE,translation_data),translation_data);
+ }else
+ {
+ return get_promoted_expression(operand,translation_data);
+ }
+ }
+
struct AST_Expression* get_cast_expression_tree(struct AST_Expression *operand,struct Type *type,struct Translation_Data *translation_data)
{
struct Type *operand_type;
for(i=0;i<ret->number_of_arguments;++i)
{
wonky_assert(arg_list->size>0);
- ret->arg_list[i]=(struct AST_Expression*)Queue_Pop(arg_list);
+ if(i>=id_type->number_of_arguments)
+ ret->arg_list[i]=get_promoted_expression_for_function_call((struct AST_Expression*)Queue_Pop(arg_list),translation_data);
+ else
+ ret->arg_list[i]=get_cast_expression_tree((struct AST_Expression*)Queue_Pop(arg_list),id_type->arguments[i]->object->type,translation_data);
}
wonky_assert(arg_list->size==0);
{
return (struct AST_Unary_Expression*)get_error_tree(NULL);
}
- struct AST_Constant* get_constant_tree(struct Expression_Value *value)
+ struct AST_Constant* get_constant_tree(struct Expression_Value_Constant *value)
{
struct AST_Constant *ret;
ret=malloc(sizeof(struct AST_Constant));
return ret;
}
- struct AST_String_Literal* get_string_literal_tree(struct Expression_Value *value)
+ struct AST_String_Literal* get_string_literal_tree(struct Expression_Value_Constant *value)
{
struct AST_String_Literal *ret;
ret=malloc(sizeof(struct AST_Constant));
ret->type=OP_STRING_LITERAL;
ret->value=value;
-
return ret;
+
}
struct AST_Expression* get_designator_tree(struct token *id,struct Scope* scope,struct Translation_Data *translation_data)
{
switch(hold_denoted->denotation)
{
case DT_Enum_Constant:
- ret->value=get_expression_value_constant(extract_enum_constant((struct Denoted_Enum_Const*)hold_denoted,translation_data));
+ ret->value=(struct Expression_Value*)get_expression_value_constant(extract_enum_constant((struct Denoted_Enum_Const*)hold_denoted,translation_data));
break;
case DT_Object:
ret->value=get_expression_value_lvalue( ((struct Denoted_Object*)hold_denoted)->object );
struct AST* get_nop_tree()
{
- struct AST* ret;
- ret=malloc(sizeof(struct AST*));
+ struct AST_Expression* ret;
+ ret=malloc(sizeof(struct AST_Expression*));
ret->type=OP_NOP;
- return ret;
+ ret->value=get_expression_value_void();
+ return (struct AST*)ret;
}
//ret->components=malloc(sizeof(struct Queue));
- ret->static_objects=malloc(sizeof(struct Queue));
+ ret->object_declarations=malloc(sizeof(struct Queue));
ret->function_definitions=malloc(sizeof(struct Queue));
ret->internal_linkage=get_linkage();
ret->file_scope=get_normal_scope(NULL,FILE_SCOPE);
- Queue_Init(ret->static_objects);
+ Queue_Init(ret->object_declarations);
Queue_Init(ret->function_definitions);
return ret;
{
while(translation_unit->function_definitions->size>0)
delete_ast((struct AST*)Queue_Pop(translation_unit->function_definitions));
- while(translation_unit->static_objects->size>0)
- delete_ast((struct AST*)Queue_Pop(translation_unit->static_objects));
+ while(translation_unit->object_declarations->size>0)
+ delete_ast((struct AST*)Queue_Pop(translation_unit->object_declarations));
if(translation_unit->file_scope!=NULL)
delete_scope(translation_unit->file_scope);
delete_linkage(translation_unit->internal_linkage);
F diff --git a/src/semantics/ast.h b/src/semantics/ast.h --- a/src/semantics/ast.h +++ b/src/semantics/ast.h
struct AST_Constant
{
enum AST_Type type;
- struct Expression_Value *value;
+ struct Expression_Value_Constant *value;
};
struct AST_String_Literal
{
enum AST_Type type;
- struct Expression_Value *value;
+ struct Expression_Value_Constant *value;
};
struct AST_Designator
{
enum AST_Type type;
//struct Queue *components; /*Queue of external declarations*/
- struct Queue *static_objects;
struct Queue *function_definitions;
+ struct Queue *object_declarations;
struct Scope *file_scope;
struct Linkage *internal_linkage;
struct AST_Error* get_error_tree(struct AST *error);
struct AST_Declaration_Error* get_declaration_error_tree(struct Denoted *error);
struct AST_Expression* get_promoted_expression(struct AST_Expression *operand,struct Translation_Data *translation_data);
+ struct AST_Expression* get_promoted_expression_for_function_call(struct AST_Expression *operand,struct Translation_Data *translation_data);
struct AST_Expression* get_cast_expression_tree(struct AST_Expression *operand,struct Type *type,struct Translation_Data *translation_data);
- struct AST_Constant* get_constant_tree(struct Expression_Value *value);
- struct AST_String_Literal* get_string_literal_tree(struct Expression_Value *value);
+ struct AST_Constant* get_constant_tree(struct Expression_Value_Constant *value);
+ struct AST_String_Literal* get_string_literal_tree(struct Expression_Value_Constant *value);
struct AST_Expression* get_designator_tree(struct token *id,struct Scope* scope,struct Translation_Data *translation_data);
struct AST_Designator* get_designator_tree_from_denoted_object(struct Denoted_Object *object,struct Translation_Data *translation_data);
struct AST_Designator* get_struct_union_member_tree_designator(struct token *id,struct Normal_Scope *inner_scope,struct Translation_Data *translation_data);
F diff --git a/src/semantics/memory/object.c b/src/semantics/memory/object.c --- a/src/semantics/memory/object.c +++ b/src/semantics/memory/object.c
return (struct Object*)ret;
}
-
#endif
F diff --git a/src/semantics/memory/object.h b/src/semantics/memory/object.h --- a/src/semantics/memory/object.h +++ b/src/semantics/memory/object.h
#include <type.h>
#include <location.h>
#include <common.h>
+ #include <lexer.h>
/*
todo : delete this if nothing subtle breaks
struct Object* retype_object(struct Object *object,struct Type *new_type);
struct Object* get_temp_object(struct Type *type);
struct Object* convert_object_to_bitfield(struct Object *object,struct AST_Expression* number_of_bits_expression,struct Translation_Data *translation_data);
-
+ struct Object_String* get_wide_string_object(struct token *token,struct Translation_Data *translation_data);
#endif
F diff --git a/src/semantics/memory/object.hh b/src/semantics/memory/object.hh --- a/src/semantics/memory/object.hh +++ b/src/semantics/memory/object.hh
{
OBJECT_KIND_NORMAL,
OBJECT_KIND_BITFIELD,
+ OBJECT_KIND_STRING,/*hack*/
};
enum Storage_Class_Specifier
{
F diff --git a/src/semantics/program/program.c b/src/semantics/program/program.c --- a/src/semantics/program/program.c +++ b/src/semantics/program/program.c
}
program=get_program();
- hold_translation_data=get_translation_data(program->types,get_linkage(),program->external_linkage);
+ hold_translation_data=get_translation_data(program->types,get_linkage(),program->external_linkage);
do
{
base_file=get_source_file(*base_source_names,this_directory);
/*TODO*/
void find_functions_without_definitions(struct Program *program)
{
-
+
}
/*TODO*/
void find_external_objects_without_an_initialiser(struct Program *program)
F diff --git a/src/semantics/program/program.h b/src/semantics/program/program.h --- a/src/semantics/program/program.h +++ b/src/semantics/program/program.h
struct Linkage *external_linkage;
+
struct Queue *functions_without_a_definition;
struct Queue *external_objects_without_an_initialiser;
};
F diff --git a/src/semantics/value/constant.c b/src/semantics/value/constant.c --- a/src/semantics/value/constant.c +++ b/src/semantics/value/constant.c
return ret;
}
- struct Constant* extract_literal_string(struct token *token,struct Translation_Data *translation_data)
- {
- char *ret_component;
- struct Constant *ret;
-
- ret=malloc(sizeof(struct Constant));
-
- ret_component=gstrncpy(token->data+1,token->data_size-2);
-
- ret->value=ret_component;
- ret->type=(struct Type*)get_type_insecure(TS_CHAR,TSIGN_NONE,TC_NONE,CHAR_SIZE,translation_data);
- ret->type=get_pointer_type(ret->type,1,0);
-
- return ret;
- }
- /*TODO*/
- struct Constant* extract_literal_wide_string(struct token *token,struct Translation_Data *translation_data)
- {
- char *ret_component;
- struct Constant *ret;
-
- ret=malloc(sizeof(struct Constant));
-
- ret_component=gstrncpy(token->data+1,token->data_size-2);
-
- ret->value=ret_component;
- ret->type=(struct Type*)get_type_insecure(TS_CHAR,TSIGN_NONE,TC_NONE,CHAR_SIZE,translation_data);
- ret->type=get_pointer_type(ret->type,1,0);
-
- return ret;
- }
struct Constant* extract_literal_char(struct token *token,struct Translation_Data *translation_data)
{
return tree->type==OP_CONSTANT &&
constant_is_null_pointer(AS_EXPRESSION_VALUE_CONSTANT(AS_AST_CONSTANT(tree)->value)->constant);
}
+ struct Constant* extract_literal_string(struct token *token,struct Translation_Data *translation_data)
+ {
+ char *ret_component;
+ struct Constant *ret;
+
+ ret=malloc(sizeof(struct Constant));
+
+ ret_component=gstrncpy(token->data+1,token->data_size-2);
+
+ ret->value=ret_component;
+ ret->type=(struct Type*)get_type_insecure(TS_CHAR,TSIGN_NONE,TC_NONE,CHAR_SIZE,translation_data);
+ ret->type=get_array_type_raw(ret->type,token->data_size,translation_data);
+
+ return ret;
+ }
+ /*TODO*/
+ struct Constant* extract_literal_wide_string(struct token *token,struct Translation_Data *translation_data)
+ {
+ char *ret_component;
+ struct Constant *ret;
+
+ ret=malloc(sizeof(struct Constant));
+
+ ret_component=gstrncpy(token->data+1,token->data_size-2);
+
+ ret->value=ret_component;
+ ret->type=(struct Type*)get_type_insecure(TS_CHAR,TSIGN_NONE,TC_NONE,CHAR_SIZE,translation_data);
+ ret->type=get_array_type_raw(ret->type,token->data_size,translation_data);
+
+ return ret;
+ }
#endif
F diff --git a/src/semantics/value/constant.h b/src/semantics/value/constant.h --- a/src/semantics/value/constant.h +++ b/src/semantics/value/constant.h
struct Constant* extract_literal_integer_hex(struct token *token,struct Translation_Data *translation_data);
struct Constant* extract_literal_double_dec(struct token *token,struct Translation_Data *translation_data);
struct Constant* extract_literal_double_hex(struct token *token,struct Translation_Data *translation_data);
- struct Constant* extract_literal_string(struct token *token,struct Translation_Data *translation_data);
- struct Constant* extract_literal_wide_string(struct token *token,struct Translation_Data *translation_data);
struct Constant* extract_literal_char(struct token *token,struct Translation_Data *translation_data);
struct Constant* extract_literal_wide_char(struct token *token,struct Translation_Data *translation_data);
struct Constant* extract_enum_constant(struct Denoted_Enum_Const *constant,struct Translation_Data *translation_data);
+ struct Constant* extract_literal_string(struct token *token,struct Translation_Data *translation_data);
+ struct Constant* extract_literal_wide_string(struct token *token,struct Translation_Data *translation_data);
F diff --git a/src/semantics/value/type.c b/src/semantics/value/type.c --- a/src/semantics/value/type.c +++ b/src/semantics/value/type.c
}
+ struct Type* get_array_type_raw(struct Type *array_of,size_t size,struct Translation_Data *translation_data)
+ {
+ struct Type_Array *ret;
+ ret=calloc(1,sizeof(struct Type_Array));
+ ret->specifier=TS_ARRAY;
+ ret->size=size;
+ ret->is_array_of=array_of;
+ ret=(struct Type_Array*)type_check_and_push((struct Type*)ret,array_of->node,sizeof(struct Type_Array));
+
+ wonky_assert(is_valid_type_array(ret));
+ return (struct Type*)ret;
+ }
struct Type* get_enum_type(struct Denotation_Prototype *prototype)
{
struct Type_Enum *ret;
F diff --git a/src/semantics/value/type.h b/src/semantics/value/type.h --- a/src/semantics/value/type.h +++ b/src/semantics/value/type.h
struct Type* get_basic_type(struct Denotation_Prototype *prototype);
struct Type* get_pointer_type(struct Type *points_to,_Bool is_const,_Bool is_volatile);
struct Type* get_array_type(struct Type *array_of,struct AST* number_of_elements,struct Translation_Data *translation_data);
+ struct Type* get_array_type_raw(struct Type *array_of,size_t size,struct Translation_Data *translation_data);
struct Type* get_enum_type(struct Denotation_Prototype *prototype);
struct Type* get_function_type(struct Type *return_type,struct Queue *parameters,struct Normal_Scope* function_prototype_scope,_Bool is_variadic,struct Translation_Data *translation_data);
F diff --git a/src/semantics/value/value.c b/src/semantics/value/value.c --- a/src/semantics/value/value.c +++ b/src/semantics/value/value.c
wonky_assert(is_valid_lvalue(ret));
return (struct Expression_Value*)ret;
}
- struct Expression_Value* get_expression_value_constant(struct Constant *constant)
+ struct Expression_Value_Constant* get_expression_value_constant(struct Constant *constant)
{
struct Expression_Value_Constant *ret;
ret=malloc(sizeof(struct Expression_Value_Constant));
ret->constant=constant;
wonky_assert(is_valid_value_constant(ret));
- return (struct Expression_Value*)ret;
+ return ret;
}
struct Expression_Value* get_expression_value_rvalue(struct Object *temp_object)
{
wonky_assert(SHOULD_NOT_REACH_HERE);
}
+ size_t get_expression_value_size(struct Expression_Value *expression_value)
+ {
+ switch(expression_value->type)
+ {
+ case VALUE_LVALUE:
+ return get_type_size(((struct Expression_Value_LValue*)expression_value)->object->type);
+ case VALUE_TEMP:
+ return get_type_size(((struct Expression_Value_RValue*)expression_value)->temp_object->type);
+ case VALUE_FUNCTION_DESIGNATOR:
+ return get_type_size(((struct Expression_Value_Function_Designator*)expression_value)->function->type);
+ case VALUE_CONSTANT:
+ return get_type_size(((struct Expression_Value_Constant*)expression_value)->constant->type);
+ case VALUE_VOID:
+ return 0;
+ }
+ wonky_assert(SHOULD_NOT_REACH_HERE);
+ }
void delete_expression_value(struct Expression_Value *expression_value)
{
F diff --git a/src/semantics/value/value.h b/src/semantics/value/value.h --- a/src/semantics/value/value.h +++ b/src/semantics/value/value.h
enum Expression_Value_Type type;
struct Constant *constant;
};
-
struct Expression_Value_RValue
{
enum Expression_Value_Type type;
struct Expression_Value* get_expression_value_void();
struct Expression_Value* get_expression_value_lvalue(struct Object *object);
- struct Expression_Value* get_expression_value_constant(struct Constant *constant);
+ struct Expression_Value_Constant* get_expression_value_constant(struct Constant *constant);
struct Expression_Value* get_expression_value_rvalue(struct Object *temp_object);
struct Expression_Value* get_expression_value_function_designator(struct Denoted_Function *function);
struct Type* extract_expresion_value_type(struct Expression_Value *expression_value,struct Translation_Data *translation_data);
+ size_t get_expression_value_size(struct Expression_Value *expression_value);
char expression_value_is_modifiable(struct Expression_Value *expression_value);
F diff --git a/src/semantics/value/value.hh b/src/semantics/value/value.hh --- a/src/semantics/value/value.hh +++ b/src/semantics/value/value.hh
VALUE_TEMP,
VALUE_FUNCTION_DESIGNATOR,
VALUE_CONSTANT,
+ VALUE_STRING,
VALUE_VOID,
EXPRESSION_VALUE_TYPE_END
};