ref: dbd4b72dbcee6e002a61b8a15634be2e595dd487
parent: 503c566fb9c0e3bb4aac69d36873fc6c1e113f22
author: Ori Bernstein <[email protected]>
date: Tue Aug 28 19:36:26 EDT 2012
Rename the match params.
--- a/6/simp.c
+++ b/6/simp.c
@@ -443,14 +443,24 @@
return load(addk(addr(n, t), off));
}
-static void umatch(Simp *s, Node *a, Node *b, Type *t, size_t off, Node *iftrue, Node *iffalse)
+static void umatch(Simp *s, Node *pat, Node *val, Type *t, size_t off, Node *iftrue, Node *iffalse)
{
Node *v, *x, *y;
Node *next;
Ucon *uc;
- assert(a->type == Nexpr);
+ assert(pat->type == Nexpr);
t = tybase(t);
+#if 0
+ printf("PAT IS -------\n");
+ dump(pat, stdout);
+ printf("VAL IS -------\n");
+ dump(val, stdout);
+ if (exprop(pat) == Ovar) {
+ printf("DECL IS -------\n");
+ dump(decls[pat->expr.did], stdout);
+ }
+#endif
switch (t->type) {
case Tyvoid: case Tybad: case Tyvalist: case Tyvar:
case Typaram: case Tyunres: case Tyname: case Ntypes:
@@ -463,26 +473,26 @@
case Tyint8: case Tyint16: case Tyint32: case Tyint:
case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint:
case Typtr: case Tyfunc:
- x = uval(a, off, t);
- y = uval(b, off, t);
- v = mkexpr(a->line, Oeq, x, y, NULL);
+ x = uval(pat, off, t);
+ y = uval(val, off, t);
+ v = mkexpr(pat->line, Oeq, x, y, NULL);
cjmp(s, v, iftrue, iffalse);
break;
case Tyunion:
- x = uconid(a, off);
- y = uconid(b, off);
- uc = finducon(a);
+ x = uconid(pat, off);
+ y = uconid(val, off);
+ uc = finducon(pat);
if (!uc)
- uc = finducon(b);
+ uc = finducon(val);
next = genlbl();
- v = mkexpr(a->line, Oeq, x, y, NULL);
+ v = mkexpr(pat->line, Oeq, x, y, NULL);
v->expr.type = tyintptr;
cjmp(s, v, next, iffalse);
append(s, next);
if (uc->etype) {
off += Wordsz;
- umatch(s, a, b, uc->etype, off, iftrue, iffalse);
+ umatch(s, pat, val, uc->etype, off, iftrue, iffalse);
}
break;
}
@@ -508,7 +518,7 @@
/* check pattern */
cur = genlbl();
next = genlbl();
- umatch(s, val, m->match.pat, val->expr.type, 0, cur, next);
+ umatch(s, m->match.pat, val, val->expr.type, 0, cur, next);
/* do the action if it matches */
append(s, cur);
--- a/parse/node.c
+++ b/parse/node.c
@@ -12,8 +12,10 @@
#include "parse.h"
-int maxnid;
-int maxdid;
+size_t maxnid;
+size_t maxdid;
+Node **decls;
+size_t ndecls;
Node *mknode(int line, Ntype nt)
{
@@ -269,6 +271,7 @@
n->decl.did = maxdid++;
n->decl.name = name;
n->decl.type = ty;
+ lappend(&decls, &ndecls, n);
return n;
}
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -257,8 +257,10 @@
extern size_t ntypes;
extern Cstr **cstrtab; /* int -> cstr map */
extern size_t ncstrs;
-extern int maxnid; /* the maximum node id generated so far */
-extern int maxdid; /* the maximum decl id generated so far */
+extern Node **decls; /* decl id -> decl map */
+extern size_t ndecls;
+extern size_t maxnid; /* the maximum node id generated so far */
+extern size_t maxdid; /* the maximum decl id generated so far */
extern int ispureop[];