diff options
Diffstat (limited to 'pez.c')
| -rw-r--r-- | pez.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -538,7 +538,7 @@ newfn(PezContext *cx, Proto *pr, Val *args, Val *locals, Fn *parent) } fn->upval[i] = up; } else { - assert(fn && upinfo->idx < parent->nupval); + assert(fn && parent && upinfo->idx < parent->nupval); fn->upval[i] = parent->upval[upinfo->idx]; } } @@ -2111,7 +2111,6 @@ static int peekchr(Comp *cm); static bool compconst(Comp *cm, Val v) { - int t; if (isvoid(v)) { TRY(compop(cm, Ovoid)); return 1; @@ -2148,7 +2147,7 @@ compconst(Comp *cm, Val v) TRY(compbytes(cm, s, n)); return 1; } - if (isobj(v) && (t = objtag(v)) == PEZ_TString) { + if (isobj_of(v, PEZ_TString)) { uint8_t idx = cm->con.len; for (uint i = 0; i < cm->con.len; ++i) { if (cm->con.at[i].r == v.r) { @@ -2590,6 +2589,7 @@ primaryexpr(Comp *cm) if (cm->stash_local) { local = cm->stash_local; cm->stash_local = NULL; + *buf = cm->spool.at[local->sref]; goto Local; } eatspaces(cm); @@ -3206,7 +3206,7 @@ logicexpr(Comp *cm) char kind, chr; int op, op2; TRY(cmpexpr(cm)); - op = getbinop(&kind, &chr, cm), op2 = op; + op = getbinop(&kind, &chr, cm); if (kind != 'L') { stashbinop(cm, op, kind, chr); return 1; @@ -3858,7 +3858,9 @@ pez_new(PezAllocFn *alloc, void *userdata, size_t stacksize) return cx; Err: - cx->err = PEZ_ENoMem; + if (cx) { + cx->err = PEZ_ENoMem; + } if (cx && cx->stack) { cxfree(cx, cx->stack, sizeof(Val) * stacksize); } @@ -4067,7 +4069,7 @@ pez_checksig(PezContext *cx, int argc, const char *fn, const char *sig) int thisn; int typ; typ = 1 << pez_typeof(cx, -argc + arg); - while (*sig && *sig != ',') { + do { const char *t = sigget(&sig); if (!strncmp(t, "any", 3)) mask |= ~0u; else if (!strncmp(t, "void", 4)) mask |= 1 << PEZ_TVoid; @@ -4098,7 +4100,7 @@ pez_checksig(PezContext *cx, int argc, const char *fn, const char *sig) assert(!*sig || *sig == '|' || *sig == ','); sig += *sig == '|'; skipspaces(&sig); - } + } while (*sig && *sig != ','); if ((typ & mask) == 0) { pez_error(cx, fn, "arg #%d mismatch: expected %.*s, got %s", arg, thisn, this, pez_typename(cx, -argc + arg)); |