Commit b39e9196 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Delay the code generation of the set action

First, gather everything needed, then generate the C code. This avoids a
bit of code duplication and makes the error handling more natural, right
after the attempt at generating a matching expression.

Refs #3100
parent 24455b70
...@@ -106,8 +106,7 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) ...@@ -106,8 +106,7 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym)
return; return;
} }
vcc_AddUses(tl, t, tl->t, sym->w_methods, "Cannot be set"); vcc_AddUses(tl, t, tl->t, sym->w_methods, "Cannot be set");
Fb(tl, 1, "%s\n", sym->lname); t = NULL;
tl->indent += INDENT;
type = sym->type; type = sym->type;
for (ap = arith; ap->type != VOID; ap++) { for (ap = arith; ap->type != VOID; ap++) {
if (ap->type != type) if (ap->type != type)
...@@ -115,22 +114,24 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) ...@@ -115,22 +114,24 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym)
if (ap->oper != tl->t->tok) if (ap->oper != tl->t->tok)
continue; continue;
if (ap->oper != '=') if (ap->oper != '=')
Fb(tl, 1, "%s %c ", sym->rname, *tl->t->b); t = tl->t;
vcc_NextToken(tl); vcc_NextToken(tl);
type = ap->want; type = ap->want;
break; break;
} }
if (ap->type == VOID) if (ap->type == VOID)
SkipToken(tl, ap->oper); SkipToken(tl, ap->oper);
if (type == HEADER) {
vcc_Expr(tl, STRING_LIST); if (type == HEADER || type == STRING || type == BODY) {
} else if (type == STRING) { type = STRING_LIST;
vcc_Expr(tl, STRING_LIST);
} else if (type == BODY) {
vcc_Expr(tl, STRING_LIST);
} else {
vcc_Expr(tl, type);
} }
Fb(tl, 1, "%s\n", sym->lname);
tl->indent += INDENT;
if (t != NULL)
Fb(tl, 1, "%s %c ", sym->rname, *t->b);
vcc_Expr(tl, type);
ERRCHK(tl); ERRCHK(tl);
tl->indent -= INDENT; tl->indent -= INDENT;
Fb(tl, 1, ");\n"); Fb(tl, 1, ");\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment