ref: 84393ead97a2e189b6057420ad7d94170b9aa00f
parent: 92840bc1ade4d670ce1b6cd3dc7be48b16148a5e
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jun 9 09:47:28 EDT 2018
Consistently and corretly add Oundef.
--- a/6/simp.c
+++ b/6/simp.c
@@ -790,6 +790,7 @@
u = addr(s, u, exprtype(lhs));
v = disp(lhs->loc, size(lhs));
r = mkexpr(lhs->loc, Oblit, t, u, v, NULL);
+ r->expr.type = exprtype(lhs);
} else {
r = set(t, u);
}
--- a/lib/std/bigint.myr
+++ b/lib/std/bigint.myr
@@ -192,8 +192,9 @@
die("invalid base in bigbfmt\n")
;;
+ n = 0
if bigiszero(x)
- n
+ n += encode(buf[n:], '0')
;;
if base == 0
@@ -201,7 +202,6 @@
else
b = mkbigint(base)
;;
- n = 0
val = bigdup(x)
/* generate the digits in reverse order */
while !bigiszero(val)
--- a/lib/std/fltfmt.myr
+++ b/lib/std/fltfmt.myr
@@ -65,6 +65,8 @@
/* initialize */
roundup = false
+ low = false
+ high = false
u = mkbigint(0)
r = bigshli(mkbigint(f), max(e, 0))
s = bigshli(mkbigint(1), max(0, -e))
--- a/lib/thread/spawn+openbsd.myr
+++ b/lib/thread/spawn+openbsd.myr
@@ -51,10 +51,11 @@
.tid = &ret,
.stk = (tos : byte#),
]
- if sys.__tfork_thread(&tfp, \
- sizeof(sys.tforkparams), \
- (startthread : void#), \
- (0 : void#)) < 0
+ ret = sys.__tfork_thread(&tfp,
+ sizeof(sys.tforkparams),
+ (startthread : void#),
+ (0 : void#))
+ if ret < 0
-> `std.Err "couldn't spawn thread"
;;
-> `std.Ok (ret : tid)
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -35,6 +35,7 @@
static void setattrs(Node *dcl, char **attrs, size_t nattrs);
static void setwith(Type *ty, Traitspec **spec, size_t nspec);
static void setupinit(Node *n);
+static void addinit(Node *blk, Node *dcl);
%}
@@ -1064,19 +1065,11 @@
blkbody : decl {
size_t i;
- Node *n, *d, *u;
$$ = mkblock($1.loc, mkstab(0));
for (i = 0; i < $1.nn; i++) {
- d = $1.nl[i];
- putdcl($$->block.scope, d);
- if (!d->decl.init) {
- n = mkexpr(d->loc, Ovar, d->decl.name, NULL);
- u = mkexpr(n->loc, Oundef, n, NULL);
- n->expr.did = d->decl.did;
- lappend(&$$->block.stmts, &$$->block.nstmts, u);
- }
- lappend(&$$->block.stmts, &$$->block.nstmts, d);
+ putdcl($$->block.scope, $1.nl[i]);
+ addinit($$, $1.nl[i]);
}
}
| stmt {
@@ -1098,7 +1091,7 @@
size_t i;
for (i = 0; i < $3.nn; i++){
putdcl($$->block.scope, $3.nl[i]);
- lappend(&$1->block.stmts, &$1->block.nstmts, $3.nl[i]);
+ addinit($$, $3.nl[i]);
}
}
| blkbody Tendln tydef {
@@ -1117,6 +1110,19 @@
;
%%
+
+static void
+addinit(Node *blk, Node *dcl)
+{
+ Node *n, *u;
+ if (!dcl->decl.init) {
+ n = mkexpr(dcl->loc, Ovar, dcl->decl.name, NULL);
+ u = mkexpr(n->loc, Oundef, n, NULL);
+ n->expr.did = dcl->decl.did;
+ lappend(&blk->block.stmts, &blk->block.nstmts, u);
+ }
+ lappend(&blk->block.stmts, &blk->block.nstmts, dcl);
+}
static void
setupinit(Node *n)
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -2108,7 +2108,7 @@
t = type(n->iterstmt.seq);
constrain(n, t, traittab[Tciter]);
b = basetype(t);
- if (b)
+ if (b && t->type != Typtr)
unify(n, e, b);
else
t->seqaux = e;