diff options
author | Ori Bernstein <ori@eigenstate.org> | 2014-12-21 01:27:55 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2014-12-21 01:27:55 -0800 |
commit | 2956d456959512a3e8b550899465395e033f7929 (patch) | |
tree | 5c927334c41bceb87c130f5aa2bba3510d026ad6 /parse/node.c | |
parent | 419c0d34a9d401d97a740778625936c6c1464d41 (diff) | |
download | mc-2956d456959512a3e8b550899465395e033f7929.tar.gz |
Make our type ids more stable across files.
Some sort of id string based on the actual type, not the
hash of the string representation.
Diffstat (limited to 'parse/node.c')
-rw-r--r-- | parse/node.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/parse/node.c b/parse/node.c index fa9db7f..38f03ea 100644 --- a/parse/node.c +++ b/parse/node.c @@ -26,6 +26,24 @@ int lnum(Srcloc l) return l.line; } +/* + * Bah, this is going to need to know how to fold things. + * FIXME: teach it. + */ +uint64_t arraysz(Node *sz) +{ + Node *n; + + n = sz; + if (exprop(n) != Olit) + fatal(sz, "too many layers of indirection when finding intializer. (initialization loop?)"); + + n = n->expr.args[0]; + if (n->lit.littype != Lint) + fatal(sz, "initializer is not an integer"); + return n->lit.intval; +} + Node *mknode(Srcloc loc, Ntype nt) { Node *n; |