#ifndef __NSPC
#define __NSPC
struct NspcInfo_ {
- m_bit * class_data;
struct Map_ op_map;
Scope value;
Scope type;
Scope func;
Scope trait;
struct Vector_ op_tmpl;
- uint16_t offset;
- uint16_t class_data_size;
};
struct Nspc_ {
- struct NspcInfo_ *info;
- Nspc parent;
- m_str name;
struct Vector_ vtable;
+ m_bit * class_data;
struct VM_Code_ * pre_ctor;
struct VM_Code_ * dtor;
+ Nspc parent;
+ m_str name;
+ struct NspcInfo_ *info;
+ uint16_t offset;
uint16_t ref;
+ uint16_t class_data_size;
};
REF_FUNC(Nspc, nspc)
if (strlen(b) < DID_YOU_MEAN_LIMIT) did_you_mean_type(a, b);
ANN static inline void nspc_allocdata(MemPool mp, const Nspc nspc) {
- if (nspc->info->class_data_size) {
- nspc->info->class_data =
- (m_bit *)mp_calloc2(mp, nspc->info->class_data_size);
+ if (nspc->class_data_size) {
+ nspc->class_data =
+ (m_bit *)mp_calloc2(mp, nspc->class_data_size);
}
}
#endif
-Subproject commit ac29ebb012d01fda0eb1c84dc204941fc6a55d4f
+Subproject commit 57d4e8c83af845579d08ebb7b1453aa6a98aaa47
const bool emit_var) {
const m_uint size = v->type->size;
const Instr instr = emit_dotstatic(emit, size, emit_var);
- instr->m_val = (m_uint)(v->from->owner->info->class_data + v->from->offset);
+ instr->m_val = (m_uint)(v->from->owner->class_data + v->from->offset);
instr->m_val2 = size;
return GW_OK;
}
LOOP_OPTIM
for (m_uint i = 0; i < vector_size(&edef->values); ++i) {
const Value v = (Value)vector_at(&edef->values, i);
- *(m_uint *)(v->from->owner->info->class_data + v->from->offset) = i;
+ *(m_uint *)(v->from->owner->class_data + v->from->offset) = i;
}
set_tflag(edef->t, tflag_emit);
return GW_OK;
ANN static inline void nspc_release_object(const Nspc a, Value value,
Gwion gwion) {
- if ((GET_FLAG(value, static) && a->info->class_data) ||
+ if ((GET_FLAG(value, static) && a->class_data) ||
(value->d.ptr && vflag(value, vflag_builtin))) {
const M_Object obj =
value->d.ptr ? (M_Object)value->d.ptr
- : *(M_Object *)(a->info->class_data + value->from->offset);
+ : *(M_Object *)(a->class_data + value->from->offset);
release(obj, gwion->vm->cleaner_shred);
}
}
ANN2(1, 3)
static inline void nspc_release_struct(const Nspc a, Value value, Gwion gwion) {
- if (value && ((GET_FLAG(value, static) && a->info->class_data) ||
+ if (value && ((GET_FLAG(value, static) && a->class_data) ||
(vflag(value, vflag_builtin) && value->d.ptr))) {
const m_bit *ptr =
(value && value->d.ptr)
? (m_bit *)value->d.ptr
- : (m_bit *)(a->info->class_data + value->from->offset);
+ : (m_bit *)(a->class_data + value->from->offset);
for (m_uint i = 0; i < vector_size(&value->type->info->tuple->types); ++i) {
const Type t = (Type)vector_at(&value->type->info->tuple->types, i);
if (isa(t, gwion->type[et_object]) > 0)
if (a->info->op_map.ptr) free_op_map(&a->info->op_map, gwion);
if (a->info->op_tmpl.ptr) free_op_tmpl(&a->info->op_tmpl, gwion);
nspc_free_type(a, gwion);
- if (a->info->class_data && a->info->class_data_size)
- mp_free2(gwion->mp, a->info->class_data_size, a->info->class_data);
+ if (a->class_data && a->class_data_size)
+ mp_free2(gwion->mp, a->class_data_size, a->class_data);
if (a->vtable.ptr) vector_release(&a->vtable);
mp_free(gwion->mp, NspcInfo, a->info);
if (a->pre_ctor) vmcode_remref(a->pre_ctor, gwion);
ANN void inherit(const Type t) {
const Nspc nspc = t->nspc, parent = t->info->parent->nspc;
if (!nspc || !parent) return;
- nspc->info->offset = parent->info->offset;
+ nspc->offset = parent->offset;
if (parent->vtable.ptr) vector_copy2(&parent->vtable, &nspc->vtable);
}
if (!gwi->gwion->env->class_def)
GWI_ERR_B(_("import: too many class_end called."))
const Type t = gwi->gwion->env->class_def;
- if (t->nspc->info->class_data_size && !t->nspc->info->class_data)
+ if (t->nspc->class_data_size && !t->nspc->class_data)
nspc_allocdata(gwi->gwion->mp, t->nspc);
if (tflag(t, tflag_tmpl)) {
--gwi->tmpls;
// if(!udef->tmpl)
// emit_union_offset(udef->l, udef->o);
// if(gwi->gwion->env->class_def && !GET_FLAG(udef, static))
- // gwi->gwion->env->class_def->nspc->info->offset =
+ // 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);
UNSET_FLAG(fork, final);
const Type typed = str2type(env->gwion, "TypedFork", exp_self(unary)->pos);
// ensure room for retval
- if (typed->nspc->info->offset == fork->nspc->info->offset)
- typed->nspc->info->offset += t->size;
+ if (typed->nspc->offset == fork->nspc->offset)
+ typed->nspc->offset += t->size;
UNSET_FLAG(typed, final);
const Type ret = str2type(env->gwion, c, exp_self(unary)->pos);
SET_FLAG(typed, final);
a->type_ref = t;
if (t->nspc) {
a->vtable.ptr = t->nspc->vtable.ptr;
- if (t->nspc->info->offset)
- a->data = (m_bit *)_mp_calloc(p, t->nspc->info->offset);
+ if (t->nspc->offset)
+ a->data = (m_bit *)_mp_calloc(p, t->nspc->offset);
}
if (shred) vector_add(&shred->gc, (vtype)a);
return a;
}
ANN void free_object(MemPool p, const M_Object o) {
- if (o->type_ref->nspc && o->type_ref->nspc->info->offset)
- mp_free2(p, o->type_ref->nspc->info->offset, o->data);
+ if (o->type_ref->nspc && o->type_ref->nspc->offset)
+ mp_free2(p, o->type_ref->nspc->offset, o->data);
mp_free(p, M_Object, o);
}
const bool emit_addr) {
const m_uint size = v->type->size;
const Instr instr = emit_dotstatic(emit, size, emit_addr);
- instr->m_val = (m_uint)(v->from->owner->info->class_data + v->from->offset);
+ instr->m_val = (m_uint)(v->from->owner->class_data + v->from->offset);
instr->m_val2 = size;
}
MUTEX_LOCK(vm->parent->shreduler->mutex);
if (!*(m_int *)(me->data + o_shred_cancel) &&
me->type_ref != vm->gwion->type[et_fork])
- memcpy(me->data + vm->gwion->type[et_fork]->nspc->info->offset, ME(me)->reg,
+ memcpy(me->data + vm->gwion->type[et_fork]->nspc->offset, ME(me)->reg,
FORK_RETSIZE(me));
*(m_int *)(me->data + o_fork_done) = 1;
if (!*(m_int *)(me->data + o_shred_cancel))
return GW_OK;
}
-#define describe_check_decl(a, b, flag) \
- ANN static inline void decl_##a(const Env env, const Value v) { \
- const Nspc nspc = env->curr; \
- flag; \
- v->from->offset = nspc->info->b; \
- nspc->info->b += v->type->size; \
+#define describe_check_decl(a, b, flag) \
+ ANN static inline void decl_##a(const Env env, const Value v) { \
+ const Nspc nspc = env->curr; \
+ flag; \
+ v->from->offset = nspc->b; \
+ nspc->b += v->type->size; \
}
describe_check_decl(member, offset, v->vflag |= vflag_member);
CHECK_BB(scan0_defined(env, udef->xid, udef->pos));
udef->type = union_type(env, udef->xid, udef->pos);
Union_List l = udef->l;
- do udef->type->nspc->info->offset += SZ_INT;
+ do udef->type->nspc->offset += SZ_INT;
while ((l = l->next));
- udef->type->nspc->info->offset += SZ_INT;
+ udef->type->nspc->offset += SZ_INT;
SET_ACCESS(udef, udef->type);
if (udef->tmpl) union_tmpl(env, udef);
if (global) env_pop(env, 0);
nspc_add_value_front(env->curr, l->xid, v);
if (t->size > sz) sz = t->size;
} while ((l = l->next));
- udef->type->nspc->info->offset = SZ_INT + sz;
+ udef->type->nspc->offset = SZ_INT + sz;
return GW_OK;
}