F diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
src/semantics/memory/object.c
src/semantics/value/type.c
src/semantics/value/evaluation.c
+ src/semantics/value/constant.c
src/semantics/identifiers/denoted.c
src/semantics/identifiers/scope.c
src/semantics/identifiers/linkage.c
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
case KW_WIDE_STRING:
return (struct AST*)get_string_literal_tree(hold_token);
case KW_CHAR_CONSTANT:
+ return (struct AST*)get_constant_tree(get_expression_value_constant(extract_literal_char(token,translation_data)));
case KW_WIDE_CHAR_CONSTANT:
+ return (struct AST*)get_constant_tree(get_expression_value_constant(extract_literal_wide_char(token,translation_data)));
case KW_HEXADECIMAL_CONSTANT:
+ case KW_UNSIGNED_LONG_HEXADECIMAL_CONSTANT:
+ case KW_UNSIGNED_LONG_LONG_HEXADECIMAL_CONSTANT:
+ case KW_UNSIGNED_HEXADECIMAL_CONSTANT:
+ case KW_LONG_HEXADECIMAL_CONSTANT:
+ case KW_LONG_LONG_HEXADECIMAL_CONSTANT:
+ return (struct AST*)get_constant_tree(get_expression_value_constant(extract_literal_integer_hex(token,translation_data)));
+
case KW_DECIMAL_CONSTANT:
- case KW_OCTAL_CONSTANT:
+ case KW_UNSIGNED_LONG_LONG_DECIMAL_CONSTANT:
+ case KW_UNSIGNED_LONG_DECIMAL_CONSTANT:
case KW_UNSIGNED_DECIMAL_CONSTANT:
+ case KW_LONG_DECIMAL_CONSTANT:
+ case KW_LONG_LONG_DECIMAL_CONSTANT:
+ return (struct AST*)get_constant_tree(get_expression_value_constant(extract_literal_integer_dec(token,translation_data)));
+
+ case KW_OCTAL_CONSTANT:
case KW_UNSIGNED_OCTAL_CONSTANT:
- case KW_UNSIGNED_HEXADECIMAL_CONSTANT:
- case KW_UNSIGNED_LONG_HEXADECIMAL_CONSTANT:
case KW_UNSIGNED_LONG_OCTAL_CONSTANT:
- case KW_UNSIGNED_LONG_DECIMAL_CONSTANT:
- case KW_UNSIGNED_LONG_LONG_DECIMAL_CONSTANT:
- case KW_UNSIGNED_LONG_LONG_HEXADECIMAL_CONSTANT:
case KW_UNSIGNED_LONG_LONG_OCTAL_CONSTANT:
- case KW_LONG_HEXADECIMAL_CONSTANT:
case KW_LONG_OCTAL_CONSTANT:
- case KW_LONG_DECIMAL_CONSTANT:
- case KW_LONG_LONG_HEXADECIMAL_CONSTANT:
case KW_LONG_LONG_OCTAL_CONSTANT:
- case KW_LONG_LONG_DECIMAL_CONSTANT:
+ assert(!"make octal constants");
+
case KW_DOUBLE_DECIMAL_CONSTANT:
case KW_LONG_DOUBLE_DECIMAL_CONSTANT:
case KW_FLOAT_DECIMAL_CONSTANT:
+ return (struct AST*)get_constant_tree(get_expression_value_constant(extract_literal_double_dec(token,translation_data)));
case KW_DOUBLE_HEXADECIMAL_CONSTANT:
case KW_LONG_DOUBLE_HEXADECIMAL_CONSTANT:
case KW_FLOAT_HEXADECIMAL_CONSTANT:
- return (struct AST*)get_constant_tree(hold_token);
+ return (struct AST*)get_constant_tree(get_expression_value_constant(extract_literal_double_hex(token,translation_data)));
case KW_ID:
- return (struct AST*)get_lvalue_expression_tree(hold_token,scope);
+ return (struct AST*)get_designator_tree(hold_token,scope,translation_data);
case KW_OPEN_NORMAL:
hold=parse_expression(translation_data,scope);
if(get_and_check(translation_data,KW_CLOSE_NORMAL))
F diff --git a/src/misc/gcc_string.c b/src/misc/gcc_string.c
--- a/src/misc/gcc_string.c
+++ b/src/misc/gcc_string.c
for(size_t i=0;(temp[i]=str[i])!='\0';++i);
return temp;
}
+ char* gstrncpy(char *str,size_t size)
+ {
+ size_t i;
+ char *temp=malloc(size+1);
+ for(i=0;i<size;++i)
+ temp[i]=str[i];
+ return temp;
+ }
char gstr_cmp(const char *a,const char *b)
{
while(*a==*b && *a)
F diff --git a/src/misc/gcc_string.h b/src/misc/gcc_string.h
--- a/src/misc/gcc_string.h
+++ b/src/misc/gcc_string.h
size_t gstrlen(char *str);
char* gstr_append(char *lead,char *follower);
char* gstrcpy(char *str);
+ char* gstrncpy(char *str,size_t size);
char gstr_cmp(const char *a,const char *b);
char gstrn_cmp(const char *a,const char *b,size_t size);
void strmv(char *target,char *source);
F diff --git a/src/program/program.h b/src/program/program.h
--- a/src/program/program.h
+++ b/src/program/program.h
struct Queue *errors;
/*
- we the type node structures from
+ the type node structures from
all the translation units are stored here
*/
struct Map *types;
F diff --git a/src/semantics/ast.c b/src/semantics/ast.c
--- a/src/semantics/ast.c
+++ b/src/semantics/ast.c
return ret;
}
- struct AST_Constant* get_constant_tree(struct token *constant)
+ struct AST_Constant* get_constant_tree(struct Expression_Value *value)
{
struct AST_Constant *ret;
ret=malloc(sizeof(struct AST_Constant));
ret->type=OP_CONSTANT;
- ret->value=NULL;
- ret->value_type=NULL;
- /*TODO*/
-
- free(constant);
+ ret->value=value;
return ret;
}
- struct AST_String_Literal* get_string_literal_tree(struct token *string)
+ struct AST_String_Literal* get_string_literal_tree(struct Expression_Value *value)
{
struct AST_String_Literal *ret;
ret=malloc(sizeof(struct AST_Constant));
ret->type=OP_STRING_LITERAL;
- ret->string=string;
+ ret->value=value;
return ret;
}
- struct AST_Lvalue_Expression* get_lvalue_expression_tree(struct token *id,struct Scope* scope)
+ struct AST_Designator* get_designator_tree(struct token *id,struct Scope* scope,struct Translation_Data *translation_data)
{
- struct AST_Lvalue_Expression *ret;
+ struct AST_Designator *ret;
+ struct Denote *hold_denoted;
+
+
+
ret=malloc(sizeof(struct AST_Lvalue_Expression));
- ret->type=OP_LVALUE;
- ret->lvalue=NULL;
- return ret;
- }
+ ret->type=OP_DESIGNATOR;
+ hold_denoted=check_ordinary(scope,id);
+ if(hold_denoted==NULL)
+ {
+ push_translation_error("using undeclared id in expression",translation_data);
+ free(ret);
+ return NULL;
+ }else
+ {
+ switch(hold_denoted->denotation)
+ {
+ case DT_Enum_Constant:
+ ret->value=get_expression_value_constant(extract_enum_constant((struct Denoted_Enum_Const*)denoted));
+ break;
+ case DT_Object:
+ ret->value=get_expression_value_lvalue( ((struct Denoted_Object*)hold_denoted)->object );
+ break;
+ case DT_Function:
+ ret->value=get_expression_value_function_designator((struct Denoted_Function*)hold_denoted);
+ break;
+ }
+ }
+ return ret;
+ }
struct AST_Labeled_Statement* get_labeled_statement_tree(struct token *label,struct AST* statement,enum AST_Type type)
free(function_expression);
}
- void delete_ast_lvalue_expression(struct AST_Lvalue_Expression *lval_expression)
+ void delete_ast_designator_expression(struct AST_Designator *designator)
{
- free(lval_expression);
+ free(designator);
}
void delete_ast_unary_expression(struct AST_Unary_Expression *unary_expression)
{
F diff --git a/src/semantics/ast.h b/src/semantics/ast.h
--- a/src/semantics/ast.h
+++ b/src/semantics/ast.h
{
enum AST_Type type;
};
+ struct AST_Expression
+ {
+ enum AST_Type type;
+ struct Expression_Value *value;
+ };
struct AST_Error
{
enum AST_Type type;
struct AST_Binary_Expression
{
enum AST_Type type;
+ struct Expression_Value *value;
- struct Type *value_type;
struct AST *left;
struct AST *right;
struct AST_Conditional_Expression
{
enum AST_Type type;
-
- struct Type *value_type;
+ struct Expression_Value *value;
struct AST *left;
struct AST *center;
struct AST *right;
-
};
struct AST_Function_Expression
{
enum AST_Type type;
- struct Type *value_type;
+ struct Expression_Value *value;
struct AST *id;
/*queue of astrees*/
struct AST_Constant
{
enum AST_Type type;
-
- struct Type *value_type;
- void *value;
+ struct Expression_Value *value;
};
- /*TODO correct this*/
+
struct AST_String_Literal
{
enum AST_Type type;
- struct token *string;
+ struct Expression_Value *value;
};
- struct AST_Lvalue_Expression
+ struct AST_Designator
{
enum AST_Type type;
- struct Denoted *lvalue;
+ struct Expression_Value *value;
};
+
struct AST_Unary_Expression
{
enum AST_Type type;
- struct Type *value_type;
+ struct Expression_Value *value;
+
struct AST *operand;
};
struct AST_Conditional_Expression* get_conditional_expression_tree(struct AST *left,struct AST *center,struct AST *right);
struct AST_Function_Expression* get_function_expression_tree(struct AST* id,struct Scope *scope);
struct AST_Unary_Expression* get_unary_expression_tree(struct AST *operand,enum AST_Type type);
- struct AST_Constant* get_constant_tree(struct token *constant);
- struct AST_String_Literal* get_string_literal_tree(struct token *string);
- struct AST_Lvalue_Expression* get_lvalue_expression_tree(struct token *id,struct Scope* scope);
+
+
+
+
+
+ struct AST_Constant* get_constant_tree(struct Expression_Value *value);
+ struct AST_String_Literal* get_string_literal_tree(struct Expression_Value *value);
+ struct AST_Designator* get_designator_tree(struct token *id,struct Scope* scope,struct Translation_Data *translation_data);
+
+
+
struct AST_Labeled_Statement* get_labeled_statement_tree(struct token *label,struct AST* statement,enum AST_Type type);
struct AST_Compound_Statement* get_compound_statement_tree(struct Scope *parent_scope);
struct AST_If_Statement* get_if_statement_tree();
void delete_ast_function_expression(struct AST_Function_Expression *function_expression);
void delete_ast_constant(struct AST_Constant *constant);
void delete_ast_string_literal(struct AST_String_Literal *string);
- void delete_ast_lvalue_expression(struct AST_Lvalue_Expression *lval_expression);
+ void delete_ast_designator_expression(struct AST_Designator *designator);
void delete_ast_unary_expression(struct AST_Unary_Expression *unary_expression);
void delete_ast_labeled_statement(struct AST_Labeled_Statement *labeled_statement);
void delete_ast_compound_statement(struct AST_Compound_Statement *compound_statement);
F diff --git a/src/semantics/ast.hh b/src/semantics/ast.hh
--- a/src/semantics/ast.hh
+++ b/src/semantics/ast.hh
,OP_LESS_EQ,OP_GREATER_EQ
,OP_LESS,OP_GREATER
,OP_EQUAL,OP_NOT_EQUAL
- ,OP_LVALUE,OP_CONSTANT,OP_STRING_LITERAL
+ ,OP_DESIGNATOR,OP_CONSTANT,OP_STRING_LITERAL
,ST_COMPOUND,ST_EXPRESSION,ST_SWITCH,ST_IF,ST_WHILE,ST_DO_WHILE,ST_GOTO,ST_LABEL,ST_CASE,ST_DEFAULT
,ST_CONTINUE,ST_BREAK,ST_RETURN,ST_FOR
,ST_OBJECT_DECLARATION,ST_TYPE_DEFINITION,ST_FUNCTION_DEFINITION
,ERROR,ERROR_DECLARATION
};
struct AST;
+ struct AST_Expression;
struct AST_Error;
struct AST_Declaration_Error;
struct AST_Binary_Expression;
struct AST_Function_Expression;
struct AST_Constant;
struct AST_String_Literal;
- struct AST_Lvalue_Expression;
+ struct AST_Designator;
struct AST_Unary_Expression;
struct AST_Labeled_Statement;
struct AST_Compound_Statement;
F diff --git a/src/semantics/value/constant.c b/src/semantics/value/constant.c
new file mode 100644
--- /dev/null
+++ b/src/semantics/value/constant.c
+ #ifndef WONKY_CONSTANT_C
+ #define WONKY_CONSTANT_C WONKY_CONSTANT_C
+ #include <constant.h>
+
+
+ void delete_constant(struct Constant *constant)
+ {
+ free(constant->value);
+ free(constant);
+ }
+
+ struct Constant* extract_literal_integer_dec(struct token *token,struct Translation_Data *translation_data)
+ {
+ /*the sign is acounted for during parsing*/
+ unsigned long long int cache=0;
+ unsigned long long int *ret_component;
+ struct Constant *ret;
+ size_t i;
+
+ ret_component=malloc(sizeof(unsigned long long int));
+ ret=malloc(sizeof(struct Constant));
+
+ for(i=0;i<token->data_size;++i)
+ cache*=10 , cache+=token->data[i]-'0';
+
+ *ret_component=cache;
+ ret->value=ret_component;
+ ret->type=get_type_insecure(TS_INT,TSIGN_NONE,TC_NONE,INT_SIZE,translation_data);
+
+ return ret;
+
+ }
+
+ struct Constant* extract_literal_integer_hex(struct token *token,struct Translation_Data *translation_data)
+ {
+ unsigned long long int cache=0;
+ unsigned char digit;
+ unsigned long long int *ret_component;
+ size_t i;
+ struct Constant *ret;
+
+
+ ret_component=malloc(sizeof(unsigned long long int));
+ ret=malloc(sizeof(struct Constant));
+
+ /* skip the leading 0x */
+ for(i=2;i<token->data_size;++i)
+ {
+ if(token->data[i]<='9')
+ digit=token->data[i]-'0';
+ else if(token->data[i]<='f' && token->data[i]>='a')
+ digit=10+(token->data[i]-'a');
+ else
+ digit=10+(token->data[i]-'A');
+ cache|=digit,cache<<=4;
+ }
+
+ *ret_component=cache;
+ ret->value=ret_component;
+ ret->type=get_type_insecure(TS_INT,TSIGN_NONE,TC_NONE,INT_SIZE,translation_data);
+ return ret;
+ }
+
+ /*Various flavours of TODO*/
+ struct Constant* extract_literal_double_dec(struct token *token,struct Translation_Data *translation_data)
+ {
+ long double *ret_component;
+ struct Constant *ret;
+
+ ret_component=malloc(sizeof(double));
+ ret=malloc(sizeof(struct Constant));
+
+ *ret_component=.0l;
+ ret->value=ret_component;
+ ret->type=get_type_insecure(TS_INT,TSIGN_NONE,TC_NONE,INT_SIZE,translation_data);
+
+ return ret;
+ }
+ struct Constant* extract_literal_double_hex(struct token *token,struct Translation_Data *translation_data)
+ {
+ long double *ret_component;
+ struct Constant *ret;
+
+ ret_component=malloc(sizeof(double));
+ ret=malloc(sizeof(struct Constant));
+
+ *ret_component=.0l;
+ ret->value=ret_component;
+ ret->type=get_type_insecure(TS_DOUBLE,TSIGN_NONE,TC_NONE,DOUBLE_SIZE,translation_data);
+
+ 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=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=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)
+ {
+ char *ret_component;
+ struct Constant *ret;
+
+ ret_component=malloc(sizeof(char));
+ ret=malloc(sizeof(struct Constant));
+
+ *ret_component=token->data[1];
+ ret->value=ret_component;
+ ret->type=get_type_insecure(TS_CHAR,TSIGN_NONE,TC_NONE,CHAR_SIZE,translation_data);
+ return ret;
+
+ }
+ /*TODO make wide*/
+ struct Constant* extract_literal_wide_char(struct token *token,struct Translation_Data *translation_data)
+ {
+ char *ret_component;
+ struct Constant *ret;
+
+ ret_component=malloc(sizeof(char));
+ ret=malloc(sizeof(struct Constant));
+
+ *ret_component=token->data[1];
+ ret->value=ret_component;
+ ret->type=get_type_insecure(TS_CHAR,TSIGN_NONE,TC_NONE,CHAR_SIZE,translation_data);
+ return ret;
+ }
+ struct Constant* extract_enum_constant(struct Denoted_Enum_Const *const)
+ {
+ struct Constant *ret;
+
+ ret=malloc(sizeof(struct Constant));
+ ret->value=malloc(sizeof(int));
+ *(ret->value)=const->value;
+ ret->type=get_type_insecure(INT_SIZE,TSIGN_NONE,TC_NONE,INT_SIZE,translation_data);
+
+
+ return ret;
+ }
+
+ struct Constant* resolve_char_escape_sequence(struct token *token,struct Translation_Data *translation_data)
+ {
+ return L'a';
+ }
+ #endif
F diff --git a/src/semantics/value/constant.h b/src/semantics/value/constant.h
new file mode 100644
--- /dev/null
+++ b/src/semantics/value/constant.h
+ #ifndef WONKY_CONSTANT_H
+ #define WONKY_CONSTANT_H WONKY_CONSTANT_H
+ #include <constant.hh>
+ #include <type.h>
+
+ struct Constant
+ {
+ struct Type *type;
+ void *value;
+ };
+
+ struct Constant* extract_literal_integer_dec(struct token *token,struct Translation_Data *translation_data);
+ 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* resolve_char_escape_sequence(struct token *token,struct Translation_Data *translation_data);
+ struct Constant* extract_enum_constant(struct Denoted_Enum_Const *const);
+
+
+
+ void delete_constant(struct Constant *constant);
+ #endif
F diff --git a/src/semantics/value/constant.hh b/src/semantics/value/constant.hh
new file mode 100644
--- /dev/null
+++ b/src/semantics/value/constant.hh
+ #ifndef WONKY_CONSTANT_HH
+ #define WONKY_CONSTANT_HH WONKY_CONSTANT_HH
+
+
+ struct Constant;
+
+ #endif
F diff --git a/src/semantics/value/evaluation.c b/src/semantics/value/evaluation.c
--- a/src/semantics/value/evaluation.c
+++ b/src/semantics/value/evaluation.c
}
- unsigned long long int evaluate_literal_integer_dec(struct token *token,struct Translation_Data *translation_data)
- {
- unsigned long long int accumulate=0;
- size_t i;
- for(i=0;i<token->data_size;++i)
- accumulate*=10 , accumulate+=token->data[i]-'0';
- return accumulate;
-
- }
-
- unsigned long long int evaluate_literal_integer_hex(struct token *token,struct Translation_Data *translation_data)
- {
- unsigned long long int accumulate=0;
- unsigned char digit;
- size_t i;
- /* skip the leading 0x */
- for(i=2;i<token->data_size;++i)
- {
- if(token->data[i]<='9')
- digit=token->data[i]-'0';
- else if(token->data[i]<='f' && token->data[i]>='a')
- digit=10+(token->data[i]-'a');
- else
- digit=10+(token->data[i]-'A');
- accumulate|=digit,accumulate<<=4;
- }
- return accumulate;
- }
-
- /*Various flavours of TODO*/
- long double evaluate_literal_double_dec(struct token *token,struct Translation_Data *translation_data)
- {
- return .0l;
- }
- long double evaluate_literal_double_hex(struct token *token,struct Translation_Data *translation_data)
- {
- return .0l;
- }
-
- char* evaluate_literal_string(struct token *token,struct Translation_Data *translation_data)
- {
- char *hold_data;
- hold_data=token->data+1;
- token->data[token->data_size]='\0';
- return hold_data;
- }
- wchar_t* evaluate_literal_wide_string(struct token *token,struct Translation_Data *translation_data)
- {
- wchar_t *hold_data;
- hold_data=(wchar_t*)(token->data+1);
- token->data[token->data_size]='\0';
- return hold_data;
- }
-
- char evaluate_literal_char(struct token *token,struct Translation_Data *translation_data)
- {
- return token->data[1];
- }
- wchar_t evaluate_literal_wide_char(struct token *token,struct Translation_Data *translation_data)
- {
- return *(wchar_t*)(token->data+1);
- }
-
- wchar_t resolve_char_escape_sequence(struct token *token,struct Translation_Data *translation_data)
- {
- return L'a';
- }
- /*TODO */
- unsigned long long int evaluate_integer_constant(struct token *token,struct Translation_Data *translation_data)
- {
- return evaluate_literal_integer_dec(token,translation_data);
- }
#endif
F diff --git a/src/semantics/value/evaluation.h b/src/semantics/value/evaluation.h
--- a/src/semantics/value/evaluation.h
+++ b/src/semantics/value/evaluation.h
long long int evaluate_const_expression_integer(struct AST *expression,struct Translation_Data *translation_data);
- unsigned long long int evaluate_integer_constant(struct token *token,struct Translation_Data *translation_data);
-
- unsigned long long int evaluate_literal_integer_dec(struct token *token,struct Translation_Data *translation_data);
- unsigned long long int evaluate_literal_integer_hex(struct token *token,struct Translation_Data *translation_data);
-
-
- long double evaluate_literal_double_dec(struct token *token,struct Translation_Data *translation_data);
- long double evaluate_literal_double_hex(struct token *token,struct Translation_Data *translation_data);
-
- char* evaluate_literal_string(struct token *token,struct Translation_Data *translation_data);
- wchar_t* evaluate_literal_wide_string(struct token *token,struct Translation_Data *translation_data);
-
- char evaluate_literal_char(struct token *token,struct Translation_Data *translation_data);
- wchar_t evaluate_literal_wide_char(struct token *token,struct Translation_Data *translation_data);
-
- wchar_t resolve_char_escape_sequence(struct token *token,struct Translation_Data *translation_data);
#endif
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
free(type);
}
}
+
+
+
+ struct Type* get_type_insecure(enum Type_Specifier type_specifier,enum Type_Signedness sign,enum Type_Constraint constraint,size_t type_size,struct Translation_Data *translation_data)
+ {
+ struct Type_Basic *ret;
+ ret=calloc(1,sizeof(struct Type_Basic));
+
+ ret->specifier=type_specifier;
+ ret->size=type_size;
+ ret->constraint=constraint;
+ ret->sign=sign;
+
+ ret=(struct Type_Basic*)type_check_and_push((struct Type*)ret,translation_data->types,sizeof(struct Type_Basic));
+ return (struct Type*)ret;
+ }
+ /*TODO !!!*/
char types_are_identical(struct Type *a,struct Type *b)
{
return 1;
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_type_bitfield(struct Type *base,struct AST* number_of_bits,struct Translation_Data *translation_data);
struct Type* get_function_type(struct Type *return_type,struct Queue *parameters,struct Normal_Scope* function_prototype_scope);
+
+ struct Type* get_type_insecure(enum Type_Specifier type_specifier,enum Type_Signedness sign,enum Type_Constraint length,struct Translation_Data *translation_data);
+
+
+
+
void delete_enum(struct Enum *enumeration);
void delete_struct_union(struct Struct_Union *su);
void delete_type(void *type);
F diff --git a/src/semantics/value/type.hh b/src/semantics/value/type.hh
--- a/src/semantics/value/type.hh
+++ b/src/semantics/value/type.hh
#define PTR_SIZE 4
#define INT_SIZE 4
#define CHAR_SIZE 1
+ #define WCHAR_SIZE 4
#define FLOAT_SIZE 4
#define DOUBLE_SIZE 8
F diff --git a/src/semantics/value/value.c b/src/semantics/value/value.c
new file mode 100644
--- /dev/null
+++ b/src/semantics/value/value.c
+ #ifndef WONKY_VALUE_C
+ #define WONKY_VALUE_C WONKY_VALUE_C
+ #include <value.h>
+
+
+ struct Expression_Value* get_expression_value_void()
+ {
+ struct Expression_Value *ret;
+ ret=malloc(sizeof(struct Expression_Value));
+ ret->type=VALUE_VOID;
+
+ return ret;
+ }
+ struct Expression_Value* get_expression_value_lvalue(struct Object *object)
+ {
+ struct Expression_Value_LValue *ret;
+ ret=malloc(sizeof(struct Expression_Value_LValue));
+ ret->type=VALUE_LVALUE;
+ ret->object=object;
+
+ return (struct Expression_Value*)ret;
+ }
+ struct Expression_Value* get_expression_value_constant(struct Constant *constant)
+ {
+ struct Expression_Value_Constant *ret;
+ ret=malloc(sizeof(struct Expression_Value_Constant));
+ ret->type=VALUE_CONSTANT;
+ ret->constant=constant;
+
+ return (struct Expression_Value*)ret;
+ }
+ struct Expression_Value* get_expression_value_temp_value(struct Object *temp_object)
+ {
+ struct Expression_Value_Temp_Value *ret;
+ ret=malloc(sizeof(struct Expression_Value_Temp_Value));
+ ret->temp_object=temp_object;
+
+ return (struct Expression_Value*)ret;
+ }
+ struct Expression_Value* get_expression_value_function_designator(struct Denoted_Function *function)
+ {
+ struct Expression_Value_Function_Designator *ret;
+ ret=malloc(sizeof(struct Expression_Value_Function_Designator));
+ ret->function=function;
+
+ return (struct Expression_Value*)ret;
+ }
+
+
+
+
+
+ void delete_expression_value(struct Expression_Value *expression_value)
+ {
+ switch(expression_value->type)
+ {
+ case VALUE_LVALUE:
+ delete_expression_value_lvalue((struct Expression_Value_LValue*)expression_value);
+ return;
+ case VALUE_TEMP:
+ delete_expression_value_temp_value((struct Expression_Value_Temp_Value*)expression_value);
+ return;
+ case VALUE_FUNCTION_DESIGNATOR:
+ delete_expression_value_function_designator((struct Expression_Value_Function_Designator*)expression_value);
+ return;
+ case VALUE_CONSTANT:
+ delete_expression_value_constant((struct Expression_Value_Constant*)expression_value);
+ return;
+ case VALUE_VOID:
+ delete_expression_value_void(expression_value);
+ return;
+ }
+ assert(0);
+ }
+ void delete_expression_value_void(struct Expression_Value *void_expression_value)
+ {
+ free(void_expression_value);
+ }
+ void delete_expression_value_lvalue(struct Expression_Value_LValue *lvalue)
+ {
+ free(lvalue);
+ }
+ void delete_expression_value_constant(struct Expression_Value_Constant *constant_expression_value)
+ {
+ delete_constant(constant_expression_value->constant);
+ free(constant_expression_value);
+ }
+ void delete_expression_value_temp_value(struct Expression_Value_Temp_Value *temp_value)
+ {
+ delete_object(temp_value->temp_object);
+ free(temp_value);
+ }
+ void delete_expression_value_function_designator(struct Expression_Value_Function_Designator *function_designator)
+ {
+ free(function_designator);
+ }
+ #endif
+
F diff --git a/src/semantics/value/value.h b/src/semantics/value/value.h
new file mode 100644
--- /dev/null
+++ b/src/semantics/value/value.h
+ #ifndef WONKY_VALUE_H
+ #define WONKY_VALUE_H WONKY_VALUE_H
+ #include <value.hh>
+ #include <object.h>
+ #include <constant.h>
+
+ struct Expression_Value
+ {
+ enum Expression_Value_Type type;
+ };
+
+ struct Expression_Value_LValue
+ {
+ enum Expression_Value_Type type;
+ struct Object *object;
+ };
+
+ struct Expression_Value_Constant
+ {
+ enum Expression_Value_Type type;
+ struct Constant *constant;
+ };
+
+ struct Expression_Value_Temp_Value
+ {
+ enum Expression_Value_Type type;
+ struct Object *temp_object;
+ };
+
+ struct Expression_Value_Function_Designator
+ {
+ enum Expression_Value_Type type;
+ struct Denoted_Function *function;
+ };
+
+
+ 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* get_expression_value_temp_value(struct Object *temp_object);
+ struct Expression_Value* get_expression_value_function_designator(struct Denoted_Function *function);
+
+
+ void delete_expression_value(struct Expression_Value *expression_value);
+ void delete_expression_value_void(struct Expression_Value *void_expression_value);
+ void delete_expression_value_lvalue(struct Expression_Value_LValue *lvalue);
+ void delete_expression_value_constant(struct Expression_Value_Constant *constant_expression_value);
+ void delete_expression_value_temp_value(struct Expression_Value_Temp_Value *temp_value);
+ void delete_expression_value_function_designator(struct Expression_Value_Function_Designator *function_designator);
+
+
+ #endif
F diff --git a/src/semantics/value/value.hh b/src/semantics/value/value.hh
new file mode 100644
--- /dev/null
+++ b/src/semantics/value/value.hh
+ #ifndef WONKY_VALUE_HH
+ #define WONKY_VALUE_HH WONKY_VALUE_HH
+
+ enum Expression_Value_Type
+ {
+ VALUE_LVALUE,
+ VALUE_TEMP,
+ VALUE_FUNCTION_DESIGNATOR,
+ VALUE_CONSTANT,
+ VALUE_VOID
+ };
+
+ struct Expression_Value;
+ struct Expression_Value_LValue;
+ struct Expression_Value_Temp_Value
+ struct Expression_Value_Constant;
+ struct Expression_Value_Function_Designator;
+
+ #endif
+
+
+
+
+
+