Get qfcc running again.

It segs when it tries to link, but that's because a real object file has
not been created yet. However, I can get my tree and flow diagrams :)
This commit is contained in:
Bill Currie 2011-01-22 15:52:57 +09:00
parent 55d3d17807
commit 4ac80c2932
4 changed files with 32 additions and 13 deletions

View file

@ -363,7 +363,7 @@ keyword_or_id (char *token)
yylval.symbol = sym; yylval.symbol = sym;
if (sym->sy_type == sy_type) if (sym->sy_type == sy_type)
return TYPE_NAME; return TYPE_NAME;
if (is_class (sym->type)) if (sym->type && is_class (sym->type))
return CLASS_NAME; return CLASS_NAME;
return NAME; return NAME;
} }

View file

@ -93,10 +93,8 @@ int yylex (void);
%union { %union {
int op; int op;
void *pointer; // for ensuring pointer values are null void *pointer; // for ensuring pointer values are null
struct def_s *def;
struct hashtab_s *def_list; struct hashtab_s *def_list;
struct type_s *type; struct type_s *type;
struct typedef_s *typename;
struct expr_s *expr; struct expr_s *expr;
struct function_s *function; struct function_s *function;
struct switch_block_s *switch_block; struct switch_block_s *switch_block;
@ -160,10 +158,10 @@ int yylex (void);
%type <type> ivar_decl ivar_declarator def_item def_list %type <type> ivar_decl ivar_declarator def_item def_list
%type <type> ivars func_type non_func_type %type <type> ivars func_type non_func_type
%type <type> code_func func_defs func_def_list %type <type> code_func func_defs func_def_list
%type <def> fdef_name cfunction_def func_def %type <symbol> fdef_name cfunction_def func_def
%type <param> function_decl %type <param> function_decl
%type <param> param param_list %type <param> param param_list
%type <def> opt_initializer methoddef var_initializer %type <symbol> opt_initializer methoddef var_initializer
%type <expr> opt_expr fexpr expr element_list element_list1 element %type <expr> opt_expr fexpr expr element_list element_list1 element
%type <expr> opt_state_expr think opt_step array_decl texpr %type <expr> opt_state_expr think opt_step array_decl texpr
%type <expr> statement statements statement_block %type <expr> statement statements statement_block
@ -241,6 +239,9 @@ check_undefined (symbol_t *sym)
defs defs
: /* empty */ : /* empty */
{
current_symtab = pr.symtab;
}
| defs def | defs def
| defs obj_def | defs obj_def
| error END { current_class = 0; yyerrok; } | error END { current_class = 0; yyerrok; }
@ -450,8 +451,8 @@ function_decl
; ;
param_list param_list
: param { $$ = $<param>0; } : param { $$ = $1; }
| param_list ',' { $<param>$ = $<param>0; } param { $$ = $<param>0; } | param_list ',' { $<param>$ = $<param>1; } param { $$ = $4; }
; ;
param param
@ -484,9 +485,6 @@ def_list
def_item def_item
: def_name opt_initializer : def_name opt_initializer
{ {
if ($2 && !$2->local
&& $2->type->type != ev_func)
def_initialized ($2);
} }
; ;
@ -512,9 +510,17 @@ fdef_name
func_def func_def
: identifier : identifier
{ {
$$ = $1;
$$->params = current_params;
$$->type = $<type>0;
$$ = function_symbol ($$, 0, 1);
} }
| OVERLOAD identifier | OVERLOAD identifier
{ {
$$ = $2;
$$->params = current_params;
$$->type = $<type>0;
$$ = function_symbol ($$, 1, 1);
} }
; ;
@ -525,11 +531,24 @@ func_init
non_code_func non_code_func
: '=' '#' fexpr : '=' '#' fexpr
{
build_builtin_function ($<symbol>0, $3);
}
| /* emtpy */ | /* emtpy */
; ;
code_func code_func
: '=' opt_state_expr statement_block {} : '='
{
$<symtab>$ = current_symtab;
current_func = begin_function ($<symbol>0, 0, current_symtab);
current_symtab = current_func->symtab;
}
opt_state_expr statement_block
{
build_code_function ($<symbol>0, $3, $4);
current_symtab = $<symtab>2;
}
; ;
def_name def_name
@ -788,7 +807,7 @@ unary_expr
; ;
primary primary
: NAME { $$ = new_symbol_expr ($1); } : NAME { $$ = new_symbol_expr (check_undefined ($1)); }
| BREAK %prec BREAK_PRIMARY { $$ = new_name_expr (save_string ("break")); } | BREAK %prec BREAK_PRIMARY { $$ = new_name_expr (save_string ("break")); }
| ARGS { $$ = new_name_expr (".args"); } | ARGS { $$ = new_name_expr (".args"); }
| SELF { $$ = new_self_expr (); } | SELF { $$ = new_self_expr (); }

View file

@ -717,6 +717,7 @@ compile_to_obj (const char *file, const char *obj)
return !options.preprocess_only; return !options.preprocess_only;
InitData (); InitData ();
setup_param_block ();
clear_frame_macros (); clear_frame_macros ();
clear_classes (); clear_classes ();
clear_defs (); clear_defs ();

View file

@ -138,7 +138,6 @@ symtab_t *current_symtab;
function_t *current_func; function_t *current_func;
struct class_type_s *current_class; struct class_type_s *current_class;
expr_t *local_expr; expr_t *local_expr;
struct scope_s *current_scope;
param_t *current_params; param_t *current_params;
%} %}