WONKY



LOG | FILES | OVERVIEW


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
/*check if this is a function definition*/
if(parse_function_definitions && get_and_check(translation_data,KW_OPEN_CURLY))
{
- struct Type_Function *function_type;
- struct Denoted_Function *hold_function;
- struct AST_Compound_Statement *function_body;
-
- hold_function=(struct Denoted_Function*)hold;
- function_type=(struct Type_Function*)((struct Denoted_Function*)hold)->type;
-
-
- hold_function->function_scope=(struct Function_Scope*)get_function_scope(scope,hold_function);
-
- function_type->function_prototype_scope->parent=(struct Scope*)hold_function->function_scope;
-
- assert(is_valid_denoted_function(hold_function) && is_valid_type((struct Type*)function_type));
-
- function_body
- =
- (struct AST_Compound_Statement*)
- parse_finish_compound_statement(
- translation_data,
- (struct Scope*)function_type->function_prototype_scope,
- &(struct Parse_Statement_Data)
- {
- .break_statement_owner=NULL,
- .continue_statement_owner=NULL,
- .current_switch_statement=NULL,
- }
- );
-
- assert(is_valid_compound_statement(function_body));
-
- Queue_Push(where_to_push,get_function_definition_tree(scope,hold_function,function_body,translation_data));
- break;
+ parse_finish_function_definition(translation_data,scope,(struct Denoted_Function*)hold,where_to_push);
+ break; /*leave the declarator parser loop*/
+ }else
+ {
+ /*this is a function declaration*/
+ Queue_Push(where_to_push,get_function_declaration_tree(scope,(struct Denoted_Function*)hold));
}
- /*this is a function declaration*/
- Queue_Push(where_to_push,get_function_declaration_tree(scope,(struct Denoted_Function*)hold));
}else if(hold->denotation==DT_Typedef)
{
Queue_Push(where_to_push,get_type_definition_tree((struct Denoted_Type*)hold));
}
+ void parse_finish_function_definition(struct Translation_Data *translation_data,struct Scope *scope,struct Denoted_Function *function,struct Queue *where_to_push)
+ {
+ struct Type_Function *function_type;
+ struct AST_Compound_Statement *function_body;
+
+ function_type=(struct Type_Function*)function->type;
+
+
+ function->function_scope=(struct Function_Scope*)get_function_scope(scope,function);
+
+ function_type->function_prototype_scope->parent=(struct Scope*)function->function_scope;
+
+ assert(is_valid_denoted_function(function) && is_valid_type((struct Type*)function_type));
+
+ function_body
+ =
+ (struct AST_Compound_Statement*)
+ parse_finish_compound_statement(
+ translation_data,
+ (struct Scope*)function_type->function_prototype_scope,
+ &(struct Parse_Statement_Data)
+ {
+ .break_statement_owner=NULL,
+ .continue_statement_owner=NULL,
+ .current_switch_statement=NULL,
+ }
+ );
+
+ assert(is_valid_compound_statement(function_body));
+
+ Queue_Push(where_to_push,get_function_definition_tree(scope,function,function_body,translation_data));
+ }
struct Denotation_Prototype* parse_specifier_qualifier_list(struct Translation_Data *translation_data,struct Scope *scope)
{
return parse_declaration_specifiers_inner(translation_data,scope,0);
F diff --git a/src/frontend/parse/parse_declaration.h b/src/frontend/parse/parse_declaration.h --- a/src/frontend/parse/parse_declaration.h +++ b/src/frontend/parse/parse_declaration.h
void parse_declaration(struct Translation_Data *translation_data,struct Scope *scope,struct Queue *where_to_push,char parse_function_definitions);
+ void parse_finish_function_definition(struct Translation_Data *translation_data,struct Scope *scope,struct Denoted_Function *function,struct Queue *where_to_push);
struct Denotation_Prototype* parse_specifier_qualifier_list(struct Translation_Data *translation_data,struct Scope *scope);
struct Denotation_Prototype* parse_declaration_specifiers(struct Translation_Data *translation_data,struct Scope *scope);
struct Denotation_Prototype* parse_declaration_specifiers_inner(struct Translation_Data *translation_data,struct Scope *scope,char parse_storage_class);