ref: fe0bcf756016bd8cad54c1af77f054b94fc8d11b
parent: 74b3aaed1a5a978a4d64ae4bdce9b0cdcf82860c
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jan 26 06:06:05 EST 2016
Remove the '$' shorthand for end of array.
--- a/6/isel.c
+++ b/6/isel.c
@@ -888,7 +888,7 @@
case Obandeq: case Obxoreq: case Obsleq: case Obsreq: case Omemb:
case Oslbase: case Osllen: case Ocast: case Outag: case Oudata:
case Oucon: case Otup: case Oarr: case Ostruct:
- case Oslice: case Oidx: case Osize: case Otupget: case Oidxlen:
+ case Oslice: case Oidx: case Osize: case Otupget:
case Obreak: case Ocontinue:
case Numops:
dump(n, stdout);
--- a/6/simp.c
+++ b/6/simp.c
@@ -35,10 +35,6 @@
int hasenv;
int isbigret;
- /* the array we're indexing for context within [] */
- Node **idxctx;
- size_t nidxctx;
-
/* pre/postinc handling */
Node **incqueue;
size_t nqueue;
@@ -781,9 +777,7 @@
Node *v, *a;
a = rval(s, arr, NULL);
- lappend(&s->idxctx, &s->nidxctx, a);
v = deref(idxaddr(s, a, idx), NULL);
- lpop(&s->idxctx, &s->nidxctx);
return v;
}
@@ -956,8 +950,6 @@
else
t = temp(s, n);
seq = rval(s, n->expr.args[0], NULL);
- if (tybase(exprtype(seq))->type != Typtr)
- lappend(&s->idxctx, &s->nidxctx, seq);
/* *(&slice) = (void*)base + off*sz */
base = slicebase(s, seq, n->expr.args[1]);
start = ptrsized(s, rval(s, n->expr.args[1], NULL));
@@ -975,8 +967,6 @@
stbase = set(deref(addr(s, t, tyintptr), NULL), base);
sz = addk(addr(s, t, tyintptr), Ptrsz);
}
- if (tybase(exprtype(seq))->type != Typtr)
- lpop(&s->idxctx, &s->nidxctx);
/* *(&slice + ptrsz) = len */
stlen = set(deref(sz, NULL), len);
append(s, stbase);
@@ -1507,9 +1497,7 @@
break;
case Oidx:
t = rval(s, n->expr.args[0], NULL);
- lappend(&s->idxctx, &s->nidxctx, t);
u = idxaddr(s, t, n->expr.args[1]);
- lpop(&s->idxctx, &s->nidxctx);
r = load(u);
break;
/* array.len slice.len are magic 'virtual' members.
@@ -1630,11 +1618,6 @@
case Ovar:
r = loadvar(s, n, dst);
break;;
- case Oidxlen:
- if (s->nidxctx == 0)
- fatal(n, "'$' undefined outside of index or slice expression");
- return seqlen(s, s->idxctx[s->nidxctx - 1], exprtype(n));
- break;
case Ogap:
fatal(n, "'_' may not be an rvalue");
break;
--- a/lib/inifile/parse.myr
+++ b/lib/inifile/parse.myr
@@ -108,7 +108,7 @@
-> false
;;
std.slfree(p.sect)
- p.sect = std.sldup(std.strstrip(ln[1:$-1]))
+ p.sect = std.sldup(std.strstrip(ln[1:]))
| `std.None:
p.err = `std.Some (`Parseerr p.line)
-> false
--- a/lib/std/slpop.myr
+++ b/lib/std/slpop.myr
@@ -8,7 +8,7 @@
generic slpop = {sl
var elt
- elt = sl[$ - 1]
+ elt = sl[sl.len - 1]
sl = slgrow(sl, sl.len - 1)
-> (elt, sl)
}
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -78,7 +78,6 @@
%token<tok> Tat /* @ */
%token<tok> Ttick /* ` */
%token<tok> Tderef /* # */
-%token<tok> Tidxlen /* $ */
%token<tok> Ttype /* type */
%token<tok> Tfor /* for */
@@ -597,13 +596,14 @@
| /* empty */ {$$ = NULL;}
;
-loopcond : exprln {$$ = $1;}
+loopcond: exprln {$$ = $1;}
| Tendln {$$ = mkboollit($1->loc, 1);}
;
-optexprln: exprln {$$ = $1;}
- | Tendln {$$ = NULL;}
- ;
+optexprln
+ : exprln {$$ = $1;}
+ | Tendln {$$ = NULL;}
+ ;
exprln : expr Tendln
;
@@ -737,8 +737,6 @@
{$$ = mkexpr($1->loc, Ovar, mkname($1->loc, $1->id), NULL);}
| Tgap
{$$ = mkexpr($1->loc, Ogap, NULL);}
- | Tidxlen
- {$$ = mkexpr($1->loc, Oidxlen, NULL);}
| literal
| Toparen expr Tcparen
{$$ = $2;}
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1583,12 +1583,6 @@
infersub(st, n, ret, sawret, &isconst);
settype(st, n, mktype(n->loc, Tyvoid));
break;
- case Oidxlen:
- t = mktyvar(n->loc);
- constrain(st, n, t, traittab[Tcnum]);
- constrain(st, n, t, traittab[Tcint]);
- settype(st, n, t);
- break;
case Odef:
case Odead: n->expr.type = mktype(n->loc, Tyvoid); break;
case Obad:
--- a/parse/ops.def
+++ b/parse/ops.def
@@ -55,7 +55,6 @@
O(Otup, 1, OTmisc, NULL)
O(Ostruct, 1, OTmisc, NULL)
O(Oarr, 1, OTmisc, NULL)
-O(Oidxlen, 1, OTmisc, "$")
/* all below this point are backend-only */
O(Odead, 0, OTmisc, "DEAD") /* dead code */
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -77,7 +77,9 @@
return t;
}
-static int identchar(int c) { return isalnum(c) || c == '_' || c == '$'; }
+static int identchar(int c) {
+ return isalnum(c) || c == '_' || c == '$';
+}
static void eatcomment(void)
{
@@ -160,7 +162,6 @@
char *kw;
int tt;
} kwmap[] = {
- {"$", Tidxlen},
{"$noret", Tattr},
{"_", Tgap},
{"break", Tbreak},
--- a/test/idxlen.myr
+++ /dev/null
@@ -1,7 +1,0 @@
-use std
-
-const main = {
- var a = [1,2,3,4]
- std.put("{} ", a[$-1])
- std.put("{}\n", a[$-2:])
-}
--- a/test/tests
+++ b/test/tests
@@ -60,7 +60,6 @@
B callbig E 42
B nestfn E 42
B foldidx P 123,456
-B idxlen P '4 [3, 4]'
B closure P 111555333666
B fncast P ok
B loop P 0123401236789