ref: 026b3393bd5d9456229de8a56b2da9486742e028
parent: d04113bab85d6d05617c0d4992c67ba5abd0e931
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Mar 2 17:27:44 EST 2015
Allow nonatomic constants in matches. Until this commit: const Foo = "abc" match x | Foo: ... ;; would fail. This makes us look through the const to find its initializer.
--- a/6/simp.c
+++ b/6/simp.c
@@ -512,7 +512,7 @@
static void matchpattern(Simp *s, Node *pat, Node *val, Type *t, Node *iftrue, Node *iffalse)
{
- Node *v, *x, *y;
+ Node *n, *v, *x, *y;
Node *deeper, *next;
Node **patarg, *lit, *idx;
char *str;
@@ -523,11 +523,18 @@
assert(pat->type == Nexpr);
t = tybase(t);
- if (exprop(pat) == Ovar && !decls[pat->expr.did]->decl.isconst) {
- v = assign(s, pat, val);
- append(s, v);
- jmp(s, iftrue);
- return;
+ if (exprop(pat) == Ovar) {
+ n = decls[pat->expr.did];
+ if (n->decl.isconst) {
+ pat = n->decl.init;
+ if (!pat)
+ die("decl has no init in this file: this is currently unsupported.");
+ } else {
+ v = assign(s, pat, val);
+ append(s, v);
+ jmp(s, iftrue);
+ return;
+ }
}
switch (t->type) {
/* Never supported */
--- a/libstd/sys+linux-x64.myr
+++ b/libstd/sys+linux-x64.myr
@@ -12,7 +12,7 @@
type fdopt = int64 /* fd options */
type fd = int32 /* fd */
type whence = uint64 /* seek from whence */
- type filemode = uint32 /*
+ type filemode = uint32 /* file open mode */
type mprot = int64 /* memory protection */
type mopt = int64 /* memory mapping options */
@@ -591,9 +591,6 @@
const execve : (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
/* wrappers to extract wait status */
const waitstatus : (st : int32 -> waitstatus)
-
- /* threading */
- const futex : (uaddr : int#, op : futexop, val : int, timeout : timespec#, uaddr2 : int#, val3 : int#)
/* file manipulation */
const open : (path:byte[:], opts:fdopt -> fd)