-Subproject commit 317a4623e5e4cd1ca5c46d84d9b53b23a5159678
+Subproject commit e46922eb0cc11d718e4d50431ac45fbe1f5d386b
const m_bool);
ANN m_uint emit_code_offset(const Emitter emit);
ANN m_uint emit_local(const Emitter emit, const Type t);
+ANN void* emit_localx(const Emitter emit, const Type t);
ANN m_bool emit_exp_spork(const Emitter, const Exp_Unary *);
ANN m_bool emit_exp(const Emitter, const Exp);
-ANN static inline void emit_gc(const Emitter emit, const m_int offset) {
- const Instr gc = emit_add_instr(emit, GcAdd);
- gc->m_val = offset;
-}
ANN Instr emit_object_addref(const Emitter emit, const m_int size,
const bool emit_var);
OP_CHECK(opck_new);
OP_EMIT(opem_new);
-ANN2(1, 3)
-static inline M_Object new_object_str(const Gwion gwion, const VM_Shred shred,
- const m_str str) {
+ANN
+static inline M_Object new_object_str(const Gwion gwion, const m_str str) {
struct loc_t_ loc = {};
DECL_OO(const Type, t, = str2type(gwion, str, loc));
- return new_object(gwion->mp, shred, t);
+ return new_object(gwion->mp, t);
}
#endif
ANN void instantiate_object(const VM_Shred, const Type);
ANN void free_object(MemPool p, const M_Object);
-ANEW M_Object new_object(MemPool, const VM_Shred, const Type);
+ANEW M_Object new_object(MemPool, const Type);
ANEW struct UGen_ *new_UGen(MemPool);
ANEW M_Object new_M_UGen(const struct Gwion_ *);
ANN void fork_clean(const VM_Shred, const Vector);
ANN ANEW M_Object new_array(MemPool, const Type t, const m_uint length);
-ANEW M_Object new_string(MemPool, const VM_Shred, const m_str);
-ANEW M_Object new_string2(const struct Gwion_ *, const VM_Shred, const m_str);
+ANEW M_Object new_string(const struct Gwion_ *, const m_str);
ANEW M_Object new_shred(const VM_Shred);
ANN void fork_launch(const M_Object, const m_uint);
ANN void __release(const M_Object, const VM_Shred);
eUpvalueOther,
eUpvalueAddr,
eDotFunc,
- eGcIni,
- eGcAdd,
- eGcEnd,
eGackType,
eGackEnd,
eGack,
#define UpvalueOther (f_instr)eUpvalueOther
#define UpvalueAddr (f_instr)eUpvalueAddr
#define DotFunc (f_instr)eDotFunc
-#define GcIni (f_instr)eGcIni
-#define GcAdd (f_instr)eGcAdd
-#define GcEnd (f_instr)eGcEnd
#define GackType (f_instr)eGackType
#define GackEnd (f_instr)eGackEnd
#define Gack (f_instr)eGack
gw_out(" {-M}%-14"UINT_F"{0}", instr->m_val2);
gw_out("\n");
break;
- case eGcIni:
- gw_out("{Y}┃{0}{-}% 4lu{0}: GcIni ", j);
- gw_out("\n");
- break;
- case eGcAdd:
- gw_out("{Y}┃{0}{-}% 4lu{0}: GcAdd ", j);
- gw_out(" {-R}%-14"INT_F"{0}", instr->m_val);
- gw_out("\n");
- break;
- case eGcEnd:
- gw_out("{Y}┃{0}{-}% 4lu{0}: GcEnd ", j);
- gw_out("\n");
- break;
case eGackType:
gw_out("{Y}┃{0}{-}% 4lu{0}: GackType ", j);
gw_out("\n");
m_bit * mem;
m_bit * base;
size_t pc;
- struct Vector_ gc;
struct ShredTick_ *tick;
struct ShredInfo_ *info;
};
UpvalueOther~u~u
UpvalueAddr~u
DotFunc~u~u
-GcIni
-GcAdd~i
-GcEnd
GackType
GackEnd~u
Gack
typedef struct Local_ {
Type type;
m_uint offset;
+ Instr instr;
bool skip;
bool is_compound;
} Local;
return l->offset;
}
+ANN void* emit_localx(const Emitter emit, const Type t) {
+ Local *const l = frame_local(emit->gwion->mp, emit->code->frame, t);
+ l->is_compound = true;
+ VMValue vmval = {
+ .t = t, .offset = l->offset, .start = emit_code_size(emit)};
+ m_vector_add(&emit->code->live_values, &vmval);
+ ++emit->code->frame->value_count;
+ l->instr = emit_add_instr(emit, Reg2Mem);
+ l->instr->m_val = l->offset;
+ l->instr->m_val2 = -SZ_INT;
+ return l;
+}
+
+ANN void emit_local_exp(const Emitter emit, const Exp e) {
+ Local *const l = emit_localx(emit, e->type);
+ if(e->ref)
+ e->ref->data = l;
+}
+
ANN m_uint emit_localn(const Emitter emit, const Type t) {
Local *const l = frame_local(emit->gwion->mp, emit->code->frame, t);
l->skip = true;
const Instr instr = emit_add_instr(emit, ArrayInit);
instr->m_val = (m_uint)type;
instr->m_val2 = array_base_simple(type)->size;
- emit_gc(emit, -SZ_INT);
+ emit_local_exp(emit, prim_exp(data));
emit_notpure(emit);
return GW_OK;
}
.pos = e->pos,
.data = (uintptr_t)prim_exp(data)};
CHECK_BB(op_emit(emit, &opi));
- emit_gc(emit, -SZ_INT);
+ emit_local_exp(emit, prim_exp(data));
return GW_OK;
}
.rhs = range->base->type,
.pos = e->pos,
.data = (uintptr_t)exp_self(range)};
- return op_emit(emit, &opi);
+ CHECK_BB(op_emit(emit, &opi));
+ emit_local_exp(emit, exp_self(range));
+ return GW_OK;
}
ANN static inline Instr specialid_instr(const Emitter emit,
struct SpecialId_ *spid = specialid_get(emit->gwion, *data);
if (spid)
return specialid_instr(emit, spid, prim_self(data)) ? GW_OK : GW_ERROR;
+
+ if(vflag(prim->value, vflag_fglobal)) exp_self(prim)->acquire = 1;
return emit_symbol(emit, prim_self(data));
}
CHECK_BB(escape_str(emit, c, prim_pos(str)));
} else
c[0] = '\0';
- v->d.obj = new_string2(emit->gwion, NULL, c);
+ v->d.obj = new_string(emit->gwion, c);
}
regpushi(emit, (m_uint)v->d.obj);
- emit_object_addref(emit, -SZ_INT, 0);
+// emit_object_addref(emit, -SZ_INT, 0);
return GW_OK;
}
CHECK_BB(emit_interp(emit, e));
const Instr instr = emit_add_instr(emit, GackEnd);
instr->m_val = 1;
+ emit_localx(emit, emit->gwion->type[et_string]);
return GW_OK;
}
return instr;
}
+ANN void unset_local(const Emitter emit, Local *const l) {
+ l->instr->opcode = eNoOp;
+// l->is_compound = false;
+// l-> = false;
+ for(m_uint i = m_vector_size(&emit->code->live_values) + 1; --i;) {
+ VMValue vmval = *(VMValue*)(ARRAY_PTR((&emit->code->live_values)) + (i-1) * sizeof(VMValue));
+ if(vmval.offset != l->offset) continue;
+ m_vector_rem(&emit->code->live_values, i-1);
+ break;
+ }
+ --emit->code->frame->value_count;
+}
+
+ANN static m_uint decl_non_static_offset(const Emitter emit, const Exp_Decl *decl, const Type t) {
+ if(!exp_self(decl)->data)
+ return emit_local(emit, t);
+ Local *const l = exp_self(decl)->data;
+ return l->offset;
+}
+
ANN static m_bool emit_exp_decl_non_static(const Emitter emit,
const Exp_Decl *decl,
const Var_Decl var_decl,
f_instr *exec = (f_instr *)allocmember;
if (!emit->env->scope->depth) emit_debug(emit, v);
if (!vflag(v, vflag_member)) {
- v->from->offset = emit_local(emit, type);
+// v->from->offset = exp_self(decl)->data ? ((Local*)exp_self(decl)->data)->offset : emit_local(emit, type);
+ v->from->offset = decl_non_static_offset(emit, decl, type);
exec = (f_instr *)(allocword);
if (GET_FLAG(v, late)) { // ref or emit_var ?
const Instr clean = emit_add_instr(emit, MemSetImm);
const Exp e = exp_self(exp_call);
if (exp_getvar(e)) regpush(emit, SZ_INT);
CHECK_BB(_emit_exp_call(emit, exp_call));
+ const Type t = exp_self(exp_call)->type;
if (exp_getvar(e)) {
regpop(emit, exp_self(exp_call)->type->size);
+ if(isa(t, emit->gwion->type[et_object]) > 0)
+ emit_local_exp(emit, e);
const Instr instr = emit_add_instr(emit, Reg2RegAddr);
instr->m_val = -SZ_INT;
- } else if (!is_func(emit->gwion, exp_call->func->type) &&
+ } else {
+// if(isa(t, emit->gwion->type[et_object]) > 0)
+// if(isa(t, emit->gwion->type[et_object]) > 0)
+// emit_local_exp(emit, e);
+// emit_localx(emit, t);
+ if (!is_func(emit->gwion, exp_call->func->type) &&
tflag(e->type, tflag_struct))
regpop(emit, SZ_INT);
+ }
return GW_OK;
}
emit->code->stack_depth += SZ_INT;
}
-ANN static inline Instr scoped_ini(const Emitter emit) {
+ANN static inline void scoped_ini(const Emitter emit) {
++emit->env->scope->depth;
emit_push_scope(emit);
- return emit_add_instr(emit, NoOp);
}
-ANN static inline void scoped_end(const Emitter emit, const Instr gc) {
+ANN static inline void scoped_end(const Emitter emit) {
emit_pop_scope(emit);
- const m_bool pure =
- vector_size(&emit->info->pure) && !vector_back(&emit->info->pure);
- if (!pure) {
- gc->opcode = eGcIni;
- emit_add_instr(emit, GcEnd);
- }
--emit->env->scope->depth;
}
ANN static m_bool scoped_stmt(const Emitter emit, const Stmt stmt,
const m_bool pop) {
- const Instr gc = scoped_ini(emit);
+ scoped_ini(emit);
const m_bool ret = emit_stmt(emit, stmt, pop);
- scoped_end(emit, gc);
+ scoped_end(emit);
return ret;
}
.is_spork = (unary->op == insert_symbol("spork")),
.emit_var = exp_getvar(exp_self(unary))};
CHECK_OB((sporker.vm_code = spork_prepare(emit, &sporker)));
+ if(!sporker.is_spork)
+ emit_local_exp(emit, exp_self(unary));
spork_ini(emit, &sporker);
+//puts("here");
(unary->unary_type == unary_code ? spork_code : spork_func)(emit, &sporker);
return GW_OK;
}
return optimize_tail_call(emit, &stmt->val->d.exp_call);
}
CHECK_BB(emit_exp_pop_next(emit, stmt->val));
+
+ if(isa(stmt->val->type, emit->gwion->type[et_object]) > 0 &&
+ (!stmt->val->data && stmt->val->acquire))
+ emit_object_addref(emit, -SZ_INT, exp_getvar(stmt->val));
}
vector_add(&emit->code->stack_return, (vtype)emit_add_instr(emit, Goto));
return GW_OK;
}
ANN static m_bool unroll(const Emitter emit, const struct Looper *loop) {
- const Instr gc = scoped_ini(emit);
+ scoped_ini(emit);
const Instr unroll = emit_add_instr(emit, Unroll);
unroll->m_val = loop->offset;
const m_uint start = emit_code_size(emit);
unroll->m_val2 = end - start;
const Instr unroll2 = emit_add_instr(emit, Unroll2);
unroll2->m_val = (m_uint)unroll;
- scoped_end(emit, gc);
+ scoped_end(emit);
return GW_OK;
}
// gwi->gwion->env->class_def->nspc->offset =
// udef->o + udef->s;
// set_vflag(udef->value, vflag_builtin);
- // const M_Object o = new_object(gwi->gwion->mp, NULL, udef->value->type);
+ // const M_Object o = new_object(gwi->gwion->mp, udef->value->type);
// udef->value->d.ptr = (m_uint*)o;
if (gwi->gwion->data->cdoc) {
lint_indent(gwi->lint);
}
ANN M_Object new_array(MemPool p, const Type t, const m_uint length) {
- const M_Object a = new_object(p, NULL, t);
+ const M_Object a = new_object(p, t);
const m_uint depth =
!tflag(t, tflag_typedef) ? t->array_depth : t->info->parent->array_depth;
const m_uint size = depth > 1 ? SZ_INT : array_base(t)->size;
static OP_EMIT(opem_array_slice) {
emit_add_instr(emit, ArraySlice);
- emit_gc(emit, -SZ_INT);
return GW_OK;
}
const m_uint offset = *(m_uint *)REG(SZ_INT * 3);
const M_Object ret =
new_array(shred->info->mp, o->type_ref, ARRAY_LEN(ARRAY(o)));
- vector_add(&shred->gc, (m_uint)ret);
if (ARRAY_LEN(ARRAY(o))) {
_init(shred, &map_run_code, offset, SZ_INT);
*(M_Object *)MEM(SZ_INT * 2) = ret;
const VM_Code code = *(VM_Code *)REG(SZ_INT * 2);
const m_uint offset = *(m_uint *)REG(SZ_INT * 3);
const M_Object ret = new_array(shred->info->mp, code->ret_type, 0);
- vector_add(&shred->gc, (m_uint)ret);
if (ARRAY_LEN(ARRAY(o))) {
_init(shred, &compactmap_run_code, offset, SZ_INT);
*(M_Object *)MEM(SZ_INT * 2) = ret;
static MFUN(vm_vector_filter) {
const m_uint offset = *(m_uint *)REG(SZ_INT * 3);
const M_Object ret = new_array(shred->info->mp, o->type_ref, 0);
- vector_add(&shred->gc, (m_uint)ret);
if (ARRAY_LEN(ARRAY(o))) {
_init(shred, &filter_run_code, offset, SZ_INT);
*(M_Object *)MEM(SZ_INT * 2) = ret;
return; // TODO make exception vararg
}
*(void **)(ref->data + SZ_INT) = aai.data;
-// vector_add(&shred->gc, (m_uint)ref); // heyo
if (!info->is_obj) {
POP_REG(shred, SZ_INT * (info->depth - 1));
*(M_Object *)REG(-SZ_INT) = ref;
}
static FREEARG(freearg_release) {
- struct Vector_ v = { .ptr = instr->m_val };
+ struct Vector_ v = { .ptr = (m_uint*)instr->m_val };
vector_release(&v);
}
#undef insert_symbol
-M_Object new_object(MemPool p, const VM_Shred shred, const Type t) {
+M_Object new_object(MemPool p, const Type t) {
const uint32_t offset = sizeof(struct M_Object_) + t->nspc->offset;
const M_Object a = _mp_calloc(p, offset);
a->ref = 1;
a->type_ref = t;
a->offset = t->nspc->offset;
a->vtable.ptr = t->nspc->vtable.ptr;
- if (shred) vector_add(&shred->gc, (vtype)a);
return a;
}
-M_Object new_string(MemPool p, const VM_Shred shred, const m_str str) {
- const M_Object o =
- new_object(p, shred, shred->info->vm->gwion->type[et_string]);
- STRING(o) = mstrdup(p, str);
- return o;
-}
-
-M_Object new_string2(const struct Gwion_ *gwion, const VM_Shred shred,
- const m_str str) {
- const M_Object o = new_object(gwion->mp, shred, gwion->type[et_string]);
+M_Object new_string(const struct Gwion_ *gwion, const m_str str) {
+ const M_Object o = new_object(gwion->mp, gwion->type[et_string]);
STRING(o) = mstrdup(gwion->mp, str);
return o;
}
const Exp_Unary *unary = (Exp_Unary *)data;
CHECK_BB(emit_instantiate_object(emit, exp_self(unary)->type,
unary->ctor.td->array, 0));
- // we don't need gc for arrays?
- // also when in rewrote exp
-// if(!(unary->ctor.td->array || unary->ctor.exp))
- emit_gc(emit, -SZ_INT);
+ if(!unary->ctor.exp)
+ emit_localx(emit, exp_self(unary)->type);
return GW_OK;
}
M_Object new_shred(const VM_Shred shred) {
const M_Object obj =
- new_object(shred->info->mp, NULL, shred->info->vm->gwion->type[et_shred]);
+ new_object(shred->info->mp, shred->info->vm->gwion->type[et_shred]);
ME(obj) = shred;
return obj;
}
ANN static inline M_Object fork_object(const VM_Shred shred, const Type t) {
const Gwion gwion = shred->info->vm->gwion;
- const M_Object o = new_object(gwion->mp, shred, t);
+ const M_Object o = new_object(gwion->mp, t);
*(M_Object *)(o->data + o_fork_ev) =
- new_object(gwion->mp, NULL, gwion->type[et_event]);
+ new_object(gwion->mp, gwion->type[et_event]);
vector_init(&EV_SHREDS(*(M_Object *)(o->data + o_fork_ev)));
return o;
}
const m_int idx = *(m_int *)MEM(SZ_INT);
if (s->info->args.ptr && idx >= 0 && (m_uint)idx < vector_size(&s->info->args)) {
const m_str str = (m_str)vector_at(&s->info->args, *(m_uint *)MEM(SZ_INT));
- *(M_Object *)RETURN = new_string(shred->info->mp, shred, str);
+ *(M_Object *)RETURN = new_string(shred->info->vm->gwion, str);
} else
handle(shred, "InvalidShredArgumentRequest");
}
static MFUN(shred##name##_name) { \
const VM_Shred s = ME(o); \
const m_str str = code_name((src), 0); \
- *(m_uint *)RETURN = (m_uint)new_string(shred->info->mp, shred, str); \
+ *(m_uint *)RETURN = (m_uint)new_string(shred->info->vm->gwion, str); \
}
describe_name(, s->info->orig->name) describe_name(_code, s->code->name)
static MFUN(shred##name##_path) { \
const VM_Shred s = ME(o); \
const m_str str = code_name((src), 1); \
- *(m_uint *)RETURN = (m_uint)new_string(shred->info->mp, shred, str); \
+ *(m_uint *)RETURN = (m_uint)new_string(shred->info->vm->gwion, str); \
} \
static MFUN(shred##name##_dir) { \
const VM_Shred s = ME(o); \
} \
--sz; \
} \
- *(m_uint *)RETURN = (m_uint)new_string(shred->info->mp, shred, c); \
+ *(m_uint *)RETURN = (m_uint)new_string(shred->info->vm->gwion, c); \
}
describe_path_and_dir(, s->info->orig->name)
describe_path_and_dir(_code, s->code->name)
char c[sz + 1];
for (m_int i = start, j = 0; i != end; i += op, ++j) c[j] = str[i];
c[sz] = '\0';
- *(M_Object *)REG(-SZ_INT) = new_string(shred->info->mp, shred, c);
+ *(M_Object *)REG(-SZ_INT) = new_string(shred->info->vm->gwion, c);
}
static MFUN(string_len) { *(m_uint *)RETURN = strlen(STRING(o)); }
strcpy(c, STRING(o));
for (m_uint i = 0; i < strlen(c); i++)
if (c[i] >= 'a' && c[i] <= 'z') c[i] += 'A' - 'a';
- *(M_Object *)RETURN = new_string(shred->info->mp, shred, c);
+ *(M_Object *)RETURN = new_string(shred->info->vm->gwion, c);
}
static MFUN(string_lower) {
strcpy(c, STRING(o));
for (m_uint i = 0; i < strlen(c); i++)
if (c[i] >= 'A' && c[i] <= 'Z') c[i] -= 'A' - 'a';
- *(M_Object *)RETURN = new_string(shred->info->mp, shred, c);
+ *(M_Object *)RETURN = new_string(shred->info->vm->gwion, c);
}
static MFUN(string_ltrim) {
while (str[i] == ' ') i++;
char c[strlen(str) - i + 1];
strcpy(c, STRING(o) + i);
- *(M_Object *)RETURN = new_string(shred->info->mp, shred, c);
+ *(M_Object *)RETURN = new_string(shred->info->vm->gwion, c);
}
static MFUN(string_rtrim) {
char c[len + 2];
strncpy(c, str, len + 1);
c[len + 1] = '\0';
- *(M_Object *)RETURN = new_string(shred->info->mp, shred, c);
+ *(M_Object *)RETURN = new_string(shred->info->vm->gwion, c);
} else {
++o->ref;
*(M_Object *)RETURN = o;
char c[len - start - end + 1];
for (i = start; i < len - end; i++) c[i - start] = str[i];
c[len - start - end] = '\0';
- *(M_Object *)RETURN = new_string(shred->info->mp, shred, c);
+ *(M_Object *)RETURN = new_string(shred->info->vm->gwion, c);
}
static MFUN(string_charAt) {
for (i = 0; i < len_insert; i++) c[i + index] = insert[i];
for (i = index; i < (m_int)len; i++) c[i + len_insert] = str[i];
c[len + len_insert] = '\0';
- *(M_Object *)RETURN = new_string(shred->info->mp, shred, c);
+ *(M_Object *)RETURN = new_string(shred->info->vm->gwion, c);
;
}
for (i = 0; i < index; i++) c[i] = str[i];
for (i = 0; i < len_insert; i++) c[i + index] = insert[i];
c[index + len_insert] = '\0';
- *(M_Object *)RETURN = new_string(shred->info->mp, shred, c);
+ *(M_Object *)RETURN = new_string(shred->info->vm->gwion, c);
;
}
for (i = 0; i < _len; i++) c[i + index] = insert[i];
for (i = index + _len; i < (m_int)len; i++) c[i] = str[i];
c[len + _len - 1] = '\0';
- *(M_Object *)RETURN = new_string(shred->info->mp, shred, c);
+ *(M_Object *)RETURN = new_string(shred->info->vm->gwion, c);
;
}
rewind(f);
(void)fread(c, 1, sz, f);
fclose(f);
- *(M_Object*)RETURN = new_string2(shred->info->vm->gwion, shred, c);
+ *(M_Object*)RETURN = new_string(shred->info->vm->gwion, c);
}
GWION_IMPORT(string) {
}
ANEW M_Object new_M_UGen(const struct Gwion_ *gwion) {
- const M_Object o = new_object(gwion->mp, NULL, gwion->type[et_ugen]);
+ const M_Object o = new_object(gwion->mp, gwion->type[et_ugen]);
UGEN(o) = new_UGen(gwion->mp);
return o;
}
func(&lhs->connect.net->to, (vtype)rhs); \
rhs->connect.net->size = (uint)vector_size(&rhs->connect.net->from); \
}
-describe_connect(C, vector_add) describe_connect(Disc, vector_rem2)
+describe_connect(C, vector_add)
+describe_connect(Disc, vector_rem2)
- ANN static void release_connect(const VM_Shred shred) {
+ANN static void release_connect(const VM_Shred shred) {
*(M_Object *)REG(0) = *(M_Object *)REG(SZ_INT);
PUSH_REG(shred, SZ_INT);
}
++(*(M_Object *)(arg->d + offset))->ref;
offset += t->size;
}
- const M_Object obj = new_object(shred->info->mp, shred, o->type_ref);
+ 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);
}
INSTR(VarargIni) {
- const M_Object o = new_object(shred->info->mp, shred,
- shred->info->vm->gwion->type[et_vararg]);
+ const M_Object o = new_object(shred->info->mp, shred->info->vm->gwion->type[et_vararg]);
struct Vararg_ *arg = mp_calloc(shred->info->mp, Vararg);
*(struct Vararg_ **)o->data = arg;
POP_REG(shred, instr->m_val - SZ_INT)
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;
}
sh->tick->parent = shred->tick;
if (!shred->tick->child.ptr) vector_init(&shred->tick->child);
vector_add(&shred->tick->child, (vtype)sh);
-// vector_add(&shred->gc, (vtype)sh->info->me);
return sh;
}
&&dotother, &&dotaddr, &&unioncheck, &&unionint, &&unionfloat,
&&unionother, &&unionaddr, &&staticint, &&staticfloat, &&staticother,
&&upvalueint, &&upvaluefloat, &&upvalueother, &&upvalueaddr, &&dotfunc,
- &&gcini, &&gcadd, &&gcend, &&gacktype, &&gackend, &&gack, &&try_ini,
+ &&gacktype, &&gackend, &&gack, &&try_ini,
&&try_end, &&handleeffect, &&performeffect, &&noop, &&debugline,
&&debugvalue, &&debugpush, &&debugpop, &&eoc, &&unroll2, &&other,
&®pushimm};
PRAGMA_POP()
DISPATCH()
newobj:
- *(M_Object *)reg = new_object(vm->gwion->mp, NULL, (Type)VAL2);
+ *(M_Object *)reg = new_object(vm->gwion->mp, (Type)VAL2);
reg += SZ_INT;
DISPATCH()
addref : {
*(VM_Code *)(reg + (m_uint)VAL2) =
((Func)(*(M_Object *)(reg - SZ_INT))->vtable.ptr[OFFSET + VAL])->code;
DISPATCH()
- gcini:
- vector_add(&shred->gc, 0);
- DISPATCH();
- gcadd:
- vector_add(&shred->gc, *(vtype *)(reg + IVAL));
- DISPATCH();
- gcend : {
- M_Object o;
- while ((o = (M_Object)vector_pop(&shred->gc))) _release(o, shred);
- }
- DISPATCH()
gacktype : {
const M_Object o = *(M_Object *)(reg - SZ_INT);
if (o) *(Type *)reg = o->type_ref;
if (!VAL)
gw_out("%s\n", str);
else
- *(M_Object *)(reg - SZ_INT) = new_string(vm->gwion->mp, shred, str);
+ *(M_Object *)(reg - SZ_INT) = new_string(vm->gwion, str);
if (str) mp_free2(vm->gwion->mp, strlen(str), str);
DISPATCH();
}
shred->reg = (m_bit *)shred + sizeof(struct VM_Shred_);
shred->base = shred->mem = shred->reg + SIZEOF_REG;
shred->info = new_shredinfo(p, c);
- vector_init(&shred->gc);
return shred;
}
void free_vm_shred(VM_Shred shred) {
- for (m_uint i = vector_size(&shred->gc) + 1; --i;)
- release((M_Object)vector_at(&shred->gc, i - 1), shred);
- vector_release(&shred->gc);
if (shred->info->frame.ptr) vector_release(&shred->info->frame);
if (shred->tick->child.ptr) vector_release(&shred->tick->child);
vmcode_remref(shred->info->orig, shred->info->vm->gwion);
GWION_IMPORT(global_var_test) {
const M_Object o =
- new_object(gwi->gwion->mp, NULL, gwi->gwion->type[et_string]);
+ new_object(gwi->gwion->mp, gwi->gwion->type[et_string]);
STRING(o) = s_name(insert_symbol(gwi->gwion->st, "test"));
GWI_BB(gwi_item_ini(gwi, "string", "i"))
GWI_BB(gwi_item_end(gwi, 0, obj, o))
GWION_IMPORT(static_string_test) {
const M_Object o =
- new_object(gwi->gwion->mp, NULL, gwi->gwion->type[et_string]);
+ new_object(gwi->gwion->mp, gwi->gwion->type[et_string]);
STRING(o) = s_name(insert_symbol(gwi->gwion->st, "test static string"));
GWI_BB(gwi_item_ini(gwi, "string", "self"))
GWI_BB(gwi_item_end(gwi, ae_flag_global, obj, o))