From 398cfeb6702a23c39bd3c0fc58959fc47f3332fe Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 10 Oct 2019 22:06:15 +0200 Subject: [PATCH] :art: Cpy_ast --- src/emit/emit.c | 7 +++++-- src/parse/check.c | 2 ++ src/parse/cpy_ast.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index d67c6558..5709a02c 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1135,7 +1135,10 @@ ANN static m_bool emit_lambda(const Emitter emit, const Exp_Lambda * lambda) { } ANN static m_bool emit_exp_lambda(const Emitter emit, const Exp_Lambda * lambda) { - assert(lambda->def); + if(!lambda->def) { + regpushi(emit, SZ_INT); + return GW_OK; + } const m_uint scope = !lambda->owner ? emit->env->scope->depth : emit_push_type(emit, lambda->owner); const m_bool ret = emit_lambda(emit, lambda); @@ -1452,7 +1455,7 @@ ANN static m_bool emit_case_head(const Emitter emit, const Exp base, e->next = next; CHECK_BB(ret) const Exp_Binary bin = { .lhs=base, .rhs=e, .op=op }; - struct Exp_ ebin = { .d={.exp_binary=bin}, .nspc=emit->env->curr}; + struct Exp_ ebin = { .d={.exp_binary=bin}, .nspc=e->nspc}; struct Op_Import opi = { .op=op, .lhs=base->type, .rhs=e->type, .data=(uintptr_t)&ebin.d.exp_binary, .pos=e->pos }; CHECK_BB(op_emit_bool(emit, &opi)) const Instr instr = emit_add_instr(emit, BranchEqInt); diff --git a/src/parse/check.c b/src/parse/check.c index 43b97164..ffc0065b 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1189,6 +1189,8 @@ ANN static m_bool match_case_exp(const Env env, Exp e) { struct Exp_ ebin = { .d={.exp_binary=bin}, .nspc=env->curr}; struct Op_Import opi = { .op=op, .lhs=base->type, .rhs=e->type, .data=(uintptr_t)&ebin.d.exp_binary, .pos=e->pos }; CHECK_OB(op_check(env, &opi)) + e->nspc= ebin.nspc; + return GW_OK; } } if(e) diff --git a/src/parse/cpy_ast.c b/src/parse/cpy_ast.c index 3a7937af..13a28484 100644 --- a/src/parse/cpy_ast.c +++ b/src/parse/cpy_ast.c @@ -335,10 +335,11 @@ ANN static void cpy_stmt_match(MemPool p, Stmt_Match a, const Stmt_Match src) { } ANN static Enum_Def cpy_enum_def(MemPool p, const Enum_Def src) { - Enum_Def a = mp_calloc(p, Func_Base); + Enum_Def a = mp_calloc(p, Enum_Def); a->list = cpy_id_list(p, src->list); a->xid = src->xid; a->flag = src->flag; + vector_init(&a->values); return a; } -- 2.43.0