Implement think expressions.

This commit is contained in:
Bill Currie 2011-03-05 18:01:37 +09:00
parent 7209c61912
commit 8cfa80b5d4
3 changed files with 23 additions and 1 deletions

View file

@ -566,6 +566,7 @@ expr_t *build_for_statement (expr_t *init, expr_t *test, expr_t *next,
expr_t *statement,
expr_t *break_label, expr_t *continue_label);
expr_t *build_state_expr (expr_t *frame, expr_t *think, expr_t *step);
expr_t *think_expr (struct symbol_s *think_sym);
expr_t *assign_expr (expr_t *e1, expr_t *e2);
expr_t *cast_expr (struct type_s *t, expr_t *e);

View file

@ -2305,6 +2305,27 @@ build_state_expr (expr_t *frame, expr_t *think, expr_t *step)
return new_state_expr (frame, think, step);
}
expr_t *
think_expr (symbol_t *think_sym)
{
symbol_t *sym;
if (think_sym->table)
return new_symbol_expr (think_sym);
sym = symtab_lookup (current_symtab, "think");
if (sym && sym->sy_type == sy_var && sym->type
&& sym->type->type == ev_field
&& sym->type->t.fldptr.type->type == ev_func) {
think_sym->type = sym->type->t.fldptr.type;
} else {
think_sym->type = &type_function;
}
think_sym = function_symbol (think_sym, 0, 1);
make_function (think_sym, 0, current_symtab->space, current_storage);
return new_symbol_expr (think_sym);
}
static int
is_indirect (expr_t *e)
{

View file

@ -913,7 +913,7 @@ optional_state_expr
think
: identifier
{
internal_error (0, "FIXME");
$$ = think_expr ($1);
}
| '(' fexpr ')'
{