ANN struct Instr_* op_emit(const Emitter, const struct Op_Import*);
ANN m_bool operator_set_func(const struct Op_Import*);
ANN void free_op_map(Map map, struct Gwion_* gwion);
+
+ANN static inline void set_decl_ref(const Exp e) {
+ if(e->exp_type == ae_exp_decl) {
+ SET_FLAG(e->d.exp_decl.td, ref);
+ SET_FLAG(e->d.exp_decl.list->self->value, ref);
+ }
+}
#endif
CHECK_BB(emit_array_extend(emit, type->e->parent, cdef->base.ext->array->exp))
if(cdef->body)
CHECK_BB(scanx_body(emit->env, cdef, (_exp_func)emit_section, emit))
- emit_class_finish(emit, type->nspc);
+ emit_class_finish(emit, nspc);
SET_FLAG(type, emit);
return GW_OK;
}
#include "env.h"
#include "vm.h"
#include "gwion.h"
+#include "value.h"
#include "operator.h"
#include "import.h"
#include "gwi.h"
if(tuple_match(env, bin->rhs->type, bin->lhs->type) < 0)
return env->gwion->type[et_null];
bin->rhs->emit_var = 1;
+ set_decl_ref(bin->rhs);
return bin->rhs->type;
}
}
static INSTR(Tuple2Object) {
-// const M_Object o = *(M_Object*)(shred->reg - SZ_INT*2);
const M_Object o = *(M_Object*)(shred->reg - instr->m_val2);
const Type t = (Type)instr->m_val;
- if(isa(o->type_ref, t) < 0)
+ if(o && isa(o->type_ref, t) < 0)
// TODO: pass position by m_val2
// Except(shred, "can't cast %s to %s\n", o->type_ref->name, t->name);
Except(shred, _("can't cast\n"));
instr->m_val2 = SZ_INT; \
return instr; \
}
-static OP_EMIT(opem_at_tuple_object) { \
- const Exp_Binary *bin = (Exp_Binary*)data; \
- const Instr instr = emit_add_instr(emit, Tuple2Object); \
- instr->m_val = (m_uint)bin->rhs->type; \
- instr->m_val2 = SZ_INT*2; \
- return emit_add_instr(emit, ObjectAssign); \
+static OP_EMIT(opem_at_tuple_object) { \
+ const Exp_Binary *bin = (Exp_Binary*)data; \
+ const Instr instr = emit_add_instr(emit, Tuple2Object); \
+ instr->m_val = (m_uint)bin->rhs->type; \
+ instr->m_val2 = SZ_INT*2; \
+
+ const Instr assign = emit_add_instr(emit, ObjectAssign); \
+
+return assign;
}
mk_opem_tuple2object(cast, Exp_Cast *, exp_self(exp)->type)
const Symbol sym = insert_symbol(gwion->st, name);
const compilation_pass pass = (compilation_pass)map_get(&gwion->data->pass_map, (vtype)sym);
if(!pass) {
- gw_err("Failed to set compilation passes, back to default");
+ gw_err("Failed to set compilation passes, back to default\n");
pass_default(gwion);
return GW_ERROR;
}