ANN static Instr _flow(const Emitter emit, const Exp e, const m_bool b) {
CHECK_BO(emit_exp_pop_next(emit, e));
- emit_exp_addref1(emit, e, -exp_size(e)); // ????
+// emit_exp_addref1(emit, e, -exp_size(e)); // ????
struct Op_Import opi = {
.op = insert_symbol(b ? "@conditional" : "@unconditional"),
.rhs = e->type,
ANN static m_bool emit_case_head(const Emitter emit, const Exp base,
const Exp e, const Symbol op, const Vector v) {
CHECK_BB(emit_exp1(emit, base));
- emit_exp_addref1(emit, base, -exp_size(base));
+// emit_exp_addref1(emit, base, -exp_size(base));
CHECK_BB(emit_exp1(emit, e));
- emit_exp_addref1(emit, e, -exp_size(e));
+// emit_exp_addref1(emit, e, -exp_size(e));
const Exp_Binary bin = {.lhs = base, .rhs = e, .op = op};
struct Exp_ ebin = {
.d = {.exp_binary = bin},
if (!nspc_lookup_value1(emit->env->curr, e->d.prim.d.var)) {
if (!n) {
CHECK_BO(emit_exp(emit, base));
- emit_exp_addref(emit, base, -exp_totalsize(base));
+// emit_exp_addref(emit, base, -exp_totalsize(base));
regpop(emit, base->type->size);
}
CHECK_BO(case_value(emit, base, e));
const Func func) {
if(!strcmp(s_name(func->def->base->xid), "new"))
emit_add_instr(emit, RegPushMem);
+ if (fbflag(func->def->base, fbflag_variadic)) {
+ Instr instr = emit_add_instr(emit, ObjectRelease);
+ instr->m_val = func->def->stack_depth - SZ_INT;
+ }
return !fbflag(func->def->base, fbflag_internal) ? finalyze(emit, FuncReturn)
: emit_internal(emit, func);
}
SET_FLAG(bin->rhs->d.exp_decl.list->self->value, late);
exp_setvar(bin->rhs, 1);
CHECK_BO(isa(bin->lhs->type, bin->rhs->type));
+ bin->lhs->ref = bin->rhs;
+// bin->rhs-> = bin->lhs;
return bin->rhs->type;
}
/*
// !strcmp(s_name(exp->d.exp_call.func->type->info->func->def->base->xid), "new"):
}
*/
+
+ANN void unset_local(const Emitter emit, void *const l);
static OP_EMIT(opem_object_at) {
-// const Exp_Binary *bin = (Exp_Binary *)data;
-// if(!exp_func(bin->lhs)) {
- const Instr addref = emit_add_instr(emit, RegAddRef);
- addref->m_val = -SZ_INT * 2;
-// }
- (void)emit_add_instr(emit, ObjectAssign);
+ const Exp_Binary *bin = (Exp_Binary *)data;
+
+ if(!bin->rhs->data) {
+ const Instr addref = emit_add_instr(emit, RegAddRef);
+ addref->m_val = -SZ_INT * 2;
+ } else unset_local(emit, bin->rhs->data);
+ if (bin->rhs->exp_type != ae_exp_decl)
+ (void)emit_add_instr(emit, ObjectAssign);
+ else
+ (void)emit_add_instr(emit, Assign);
return GW_OK;
}
_("cannot access member '%s.%s' without object instance..."),
the_base->name, str);
if (GET_FLAG(value, const)) exp_setmeta(exp_self(member), 1);
+ exp_self(member)->acquire = 1;
return value->type;
}
vm->parent = parent;
const M_Object o = sh->info->me = fork_object(shred, t);
ME(o) = sh;
- ++o->ref;
+// ++o->ref;
shreduler_add(vm->shreduler, sh);
return o;
}
static MFUN(mfun_vararg_cpy) {
struct Vararg_ *src = *(struct Vararg_ **)o->data;
struct Vararg_ *arg = mp_calloc(shred->info->mp, Vararg);
- vector_copy2(&src->t, &arg->t);
- arg->d = (m_bit *)xmalloc(round2szint(*(m_uint *)(o->data + SZ_INT * 2)));
+ if(*(m_uint*)(o->data + SZ_INT * 2)) {
+ vector_copy2(&src->t, &arg->t);
+ arg->d = (m_bit *)xmalloc(round2szint(*(m_uint *)(o->data + SZ_INT * 2)));
m_uint offset = 0;
for (m_uint i = 0; i < vector_size(&arg->t); ++i) {
const Type t = (Type)vector_at(&arg->t, *(m_uint *)(o->data + SZ_INT * 4));
++(*(M_Object *)(arg->d + offset))->ref;
offset += t->size;
}
+ }
const M_Object obj = new_object(shred->info->mp, o->type_ref);
*(struct Vararg_ **)obj->data = arg;
*(m_uint *)(obj->data + SZ_INT * 2) = *(m_uint *)(o->data + SZ_INT * 2);
*(m_uint *)(obj->data + SZ_INT * 3) = *(m_uint *)(o->data + SZ_INT * 3);
*(m_uint *)(obj->data + SZ_INT * 4) = *(m_uint *)(o->data + SZ_INT * 4);
- *(m_uint *)(obj->data + SZ_INT * 4) = vector_size(&arg->t); // can we copy?
+ *(m_uint *)(obj->data + SZ_INT * 4) = arg->t.ptr ? vector_size(&arg->t) : 0; // can we copy?
*(M_Object *)RETURN = obj;
}
*(m_uint *)(o->data + SZ_INT * 5) = vector_size(kinds);
}
*(M_Object *)REG(-SZ_INT) = o;
+// ++o->ref;
}
static INSTR(VarargEnd) {
ERR_B(stmt_self(stmt)->pos,
_("empty for loop condition..."
"...(note: explicitly use 'true' if it's the intent)"
- "...(e.g., 'for(; true;{{ /*...*/ }')"))
+ "...(e.g., 'for(; true;){{ /*...*/ }')"))
return GW_OK;
}
// tgt : t;
v->type : t;
-printf("%s %s\n", first->name, second->name);
-
if(first != second) {
const Map m1 = &first->info->value->from->owner->info->type->map;
map_remove(m1, (m_uint)insert_symbol(first->name));
const m_uint line = vector_at(&shred->info->line, size - 1);
m_uint i;
bool can_skip = false;
-//printf("size %lu\n", size);
-if(!size)return;
+ if(!size)return;
for (i = size; --i;) {
const m_uint val = VPTR(&shred->info->line, i - 1);
if (!val)
GWION_IMPORT(enum_test) {
GWI_BB(gwi_enum_ini(gwi, "test"))
GWI_BB(gwi_enum_add(gwi, "adc", 0))
- GWI_BB(gwi_enum_ini(gwi, NULL))
+ GWI_BB(gwi_enum_ini(gwi, "error"))
return GW_OK;
}
static SFUN(func_tmpl_xfun) {}
GWION_IMPORT(func_tmpl) {
- GWI_BB(gwi_func_ini(gwi, "int[]", "test:[A]"))
+ GWI_BB(gwi_func_ini(gwi, "int", "test:[A]"))
GWI_BB(gwi_func_arg(gwi, "A", "i"))
GWI_BB(gwi_func_end(gwi, func_tmpl_xfun, ae_flag_none))
return GW_OK;