VM* vm;
struct Map_ freearg;
SymTable *st;
- MemPool p;
+ MemPool mp;
struct Vector_ child;
};
#define _CHECK_OP(op, check, func)\
CHECK_BB(gwi_oper_add(gwi, opck_##check))\
CHECK_BB(gwi_oper_end(gwi, op_##op, func))
-#define GWI_LOC new_loc(gwi->gwion->p, __LINE__)
+#define GWI_LOC new_loc(gwi->gwion->mp, __LINE__)
ANN VM* gwi_vm(const Gwi);
#define RET_NSPC(exp) \
++env->scope->depth; \
-nspc_push_value(env->gwion->p, env->curr); \
+nspc_push_value(env->gwion->mp, env->curr); \
const m_bool ret = exp; \
-nspc_pop_value(env->gwion->p, env->curr); \
+nspc_pop_value(env->gwion->mp, env->curr); \
--env->scope->depth; \
return ret;
#ifndef __TEMPLATE
#define __TEMPLATE
ANN m_bool template_push_types(const Env, ID_List, Type_List);
-#define POP_RET(a) { nspc_pop_type(env->gwion->p, env->curr); return (a); }
+#define POP_RET(a) { nspc_pop_type(env->gwion->mp, env->curr); return (a); }
#endif
#define describe_fold_xxx(name, type, _l, _r, etype, opt) \
ANN static m_bool fold_##name(const Env env, const Exp_Binary* bin) { \
- MemPool mp = env->gwion->p; \
+ MemPool mp = env->gwion->mp; \
const union exp_primary_data *l = &bin->lhs->d.exp_primary.d; \
const union exp_primary_data *r = &bin->rhs->d.exp_primary.d; \
type ret = 0; \
static m_uint compile(struct Gwion_* gwion, struct Compiler* c) {
VM_Shred shred = NULL;
VM_Code code;
- compiler_name(gwion->p, c);
+ compiler_name(gwion->mp, c);
if(check(gwion, c) < 0 ||
!(code = emit_ast(gwion->emit, c->ast)))
gw_err("while compiling file '%s'\n", c->base);
else {
- const VM_Shred shred = new_vm_shred(gwion->p, code);
+ const VM_Shred shred = new_vm_shred(gwion->mp, code);
shred->info->args = c->args;
vm_add_shred(gwion->vm, shred);
}
- compiler_clean(gwion->p, c);
+ compiler_clean(gwion->mp, c);
return shred ? shred->tick->xid : 0;
}
/*
m_bool is_obj;
} Local;
-static inline void emit_pop_type(const Emitter emit) { nspc_pop_type(emit->gwion->p, emit->env->curr); }
+static inline void emit_pop_type(const Emitter emit) { nspc_pop_type(emit->gwion->mp, emit->env->curr); }
static inline void emit_pop(const Emitter emit, const m_uint scope) { env_pop(emit->env, scope); }
static inline m_uint emit_push(const Emitter emit, const Type type, const Nspc nspc) {
return env_push(emit->env, type, nspc);
ANN static m_bool emit_func_def(const Emitter emit, const Func_Def func_def);
ANEW static Code* new_code(const Emitter emit, const m_str name) {
- Code* code = mp_alloc(emit->gwion->p, Code);
+ Code* code = mp_alloc(emit->gwion->mp, Code);
code->name = code_name_set(name, emit->env->name);
vector_init(&code->instr);
vector_init(&code->stack_break);
vector_init(&code->stack_cont);
vector_init(&code->stack_return);
- code->frame = new_frame(emit->gwion->p);
+ code->frame = new_frame(emit->gwion->mp);
return code;
}
}
ANN static inline m_uint emit_local(const Emitter emit, const m_uint size, const m_bool is_obj) {
- return frame_local(emit->gwion->p, emit->code->frame, size, is_obj);
+ return frame_local(emit->gwion->mp, emit->code->frame, size, is_obj);
}
ANN static void emit_pre_ctor(const Emitter emit, const Type type) {
ANN ArrayInfo* emit_array_extend_inner(const Emitter emit, const Type t, const Exp e) {
CHECK_BO(emit_exp(emit, e, 0))
const Type base = array_base(t);
- ArrayInfo* info = mp_alloc(emit->gwion->p, ArrayInfo);
+ ArrayInfo* info = mp_alloc(emit->gwion->mp, ArrayInfo);
vector_init(&info->type);
for(m_uint i = 1; i < t->array_depth; ++i)
vector_add(&info->type, (vtype)array_type(emit->env, base, i));
Array_Sub array = arr;
if(type->array_depth) {
if(!array || array->depth < type->array_depth) { // from typeof xxx[]...
- Exp base = new_exp_prim_int(emit->gwion->p, 0, new_loc(emit->gwion->p, __LINE__)), e = base;
+ Exp base = new_exp_prim_int(emit->gwion->mp, 0, new_loc(emit->gwion->mp, __LINE__)), e = base;
for(m_uint i = (array ? array->depth : 0); i < type->array_depth; ++i)
- e = (e->next = new_exp_prim_int(emit->gwion->p, 0, new_loc(emit->gwion->p, __LINE__)));
+ e = (e->next = new_exp_prim_int(emit->gwion->mp, 0, new_loc(emit->gwion->mp, __LINE__)));
if(array) {
Exp array_base = array->exp;
while(array_base->next)
array_base = array_base->next;
array_base->next = base;
} else
- array = new_array_sub(emit->gwion->p, base);
+ array = new_array_sub(emit->gwion->mp, base);
}
assert(array->exp);
ArrayInfo* info = emit_array_extend_inner(emit, type, array->exp);
CHECK_OB(info)
info->is_ref = !!is_ref;
if(array != arr)
- free_array_sub(emit->gwion->p, array);
+ free_array_sub(emit->gwion->mp, array);
} else if(!is_ref) {
const Instr instr = emit_add_instr(emit, ObjectInstantiate);
instr->m_val2 = (m_uint)type;
static const f_instr allocword[] = { AllocWord, AllocWord2, AllocWord3, AllocWord4 };
ANN static inline Exp this_exp(const Emitter emit, const Type t, const loc_t pos) {
- const Exp exp = new_exp_prim_id(emit->gwion->p, insert_symbol("this"),
- loc_cpy(emit->gwion->p, pos));
+ const Exp exp = new_exp_prim_id(emit->gwion->mp, insert_symbol("this"),
+ loc_cpy(emit->gwion->mp, pos));
exp->type = t;
return exp;
}
ANN static inline Exp dot_this_exp(const Emitter emit, const Exp_Primary* prim, const Type t) {
const Exp exp = this_exp(emit, t, exp_self(prim)->pos);
- const Exp dot = new_exp_dot(emit->gwion->p, exp, prim->d.var);
+ const Exp dot = new_exp_dot(emit->gwion->mp, exp, prim->d.var);
dot->d.exp_dot.t_base = t;
return dot;
}
ANN static inline Exp dot_static_exp(const Emitter emit, const Exp_Primary* prim, const Type t) {
const Symbol s = insert_symbol(t->name);
- const Exp e = new_exp_prim_id(emit->gwion->p, s,
- loc_cpy(emit->gwion->p, exp_self(prim)->pos));
+ const Exp e = new_exp_prim_id(emit->gwion->mp, s,
+ loc_cpy(emit->gwion->mp, exp_self(prim)->pos));
const Value val = nspc_lookup_value1(t->nspc->parent, s);
- const Exp dot = new_exp_dot(emit->gwion->p, e, prim->d.var);
+ const Exp dot = new_exp_dot(emit->gwion->mp, e, prim->d.var);
dot->d.exp_dot.t_base = val->type;
return dot;
}
dot->type = v->type;
dot->emit_var = exp_self(prim)->emit_var;
const m_bool ret = emit_exp_dot(emit, &dot->d.exp_dot);
- free_exp(emit->gwion->p, dot);
+ free_exp(emit->gwion->mp, dot);
return ret;
}
ANEW ANN VM_Code emit_code(const Emitter emit) {
Code* c = emit->code;
- const VM_Code code = new_vm_code(emit->gwion->p, &c->instr, c->stack_depth,
+ const VM_Code code = new_vm_code(emit->gwion->mp, &c->instr, c->stack_depth,
c->flag, c->name);
- free_code(emit->gwion->p, c);
+ free_code(emit->gwion->mp, c);
return code;
}
ANN static m_bool prim_gack(const Emitter emit, const Exp_Primary* primary) {
const Exp exp = primary->d.exp;
- const Vector v = new_vector(emit->gwion->p);
+ const Vector v = new_vector(emit->gwion->mp);
m_uint offset = 0;
Exp e = exp;
do {
ADD_REF(e->type);
} while((e = e->next));
if(emit_exp(emit, exp, 0) < 0) {
- free_vector(emit->gwion->p, v);
+ free_vector(emit->gwion->mp, v);
ERR_B(exp->pos, "\t... in 'gack' expression.")
}
const Instr instr = emit_add_instr(emit, Gack);
if(is_obj && (is_array || !is_ref))
CHECK_BB(emit_instantiate_object(emit, type, array, is_ref))
const Instr instr = emit_kind(emit, v->type->size, emit_addr, dotstatic);
- v->d.ptr = mp_alloc2(emit->gwion->p, v->type->size);
+ v->d.ptr = mp_alloc2(emit->gwion->mp, v->type->size);
SET_FLAG(v, union);
instr->m_val = (m_uint)v->d.ptr;
instr->m_val2 = v->type->size;
ANN static void emit_func_arg_vararg(const Emitter emit, const Exp_Call* exp_call) {
const Instr instr = emit_add_instr(emit, VarargIni);
- const Vector kinds = new_vector(emit->gwion->p);
+ const Vector kinds = new_vector(emit->gwion->mp);
if((instr->m_val = round2szint(vararg_size(exp_call, kinds))))
instr->m_val2 = (m_uint)kinds;
else {
instr->opcode = eRegPushImm;
- free_vector(emit->gwion->p, kinds);
+ free_vector(emit->gwion->mp, kinds);
}
}
m_bool ret = GW_ERROR;
if(traverse_func_template(emit->env, dt->def, dt->tl) > 0) {
ret = emit_func_def(emit, dt->def);
- nspc_pop_type(emit->gwion->p, emit->env->curr);
+ nspc_pop_type(emit->gwion->mp, emit->env->curr);
}
emit_pop(emit, scope);
return ret;
char c[sz + 1];
memcpy(c, f->name, sz);
c[sz] = '\0';
- struct dottmpl_ *dt = mp_alloc(emit->gwion->p, dottmpl);
+ struct dottmpl_ *dt = mp_alloc(emit->gwion->mp, dottmpl);
dt->name = s_name(insert_symbol(c));
dt->overload = f->def->tmpl->base;
dt->tl = tmpl_tl(emit->env, c);
ANN static Instr _flow(const Emitter emit, const Exp e, const m_bool b) {
if(e->next) {
- free_exp(emit->gwion->p, e->next);
+ free_exp(emit->gwion->mp, e->next);
e->next = NULL;
env_err(emit->env, e->pos, "expression after comma won't be executed");
}
CHECK_BB(emit_stmt(emit, stmt->stmt, 1))
instr->m_val = switch_idx(emit->env) ?: emit_code_size(emit);
if(push[0]) {
- push[2]->m_val = push[1]->m_val2 = (m_uint) emit_switch_map(emit->gwion->p, (Map)instr->m_val2);
+ push[2]->m_val = push[1]->m_val2 = (m_uint) emit_switch_map(emit->gwion->mp, (Map)instr->m_val2);
Vector v = (Vector)(push[1]->m_val = (m_uint)switch_vec(emit->env));
push[0]->m_val = vector_size(v) * SZ_INT;
}
for(m_uint i = 0; i < vector_size(&stmt->values); ++i) {
const Value v = (Value)vector_at(&stmt->values, i);
if(!emit->env->class_def) {
- ALLOC_PTR(emit->gwion->p, addr, m_uint, i);
+ ALLOC_PTR(emit->gwion->mp, addr, m_uint, i);
v->offset = emit_local(emit, SZ_INT, 0);
v->d.ptr = addr;
} else
stmt->value->type->nspc->info->class_data =
(m_bit*)xcalloc(1, stmt->value->type->nspc->info->class_data_size);
stmt->value->type->nspc->info->offset = stmt->s;
- Type_Decl *type_decl = new_type_decl(emit->gwion->p,
- new_id_list(emit->gwion->p, stmt->xid, loc_cpy(emit->gwion->p, loc_cpy(emit->gwion->p, stmt_self(stmt)->pos))),
+ Type_Decl *type_decl = new_type_decl(emit->gwion->mp,
+ new_id_list(emit->gwion->mp, stmt->xid, loc_cpy(emit->gwion->mp, loc_cpy(emit->gwion->mp, stmt_self(stmt)->pos))),
// emit->env->class_def ? ae_flag_member : 0);
stmt->flag);
//if(emit->env->class_def && !GET_FLAG(stmt, static))
//SET_FLAG(type_decl, member);
// type_decl->flag = stmt->flag;// ???
- const Var_Decl var_decl = new_var_decl(emit->gwion->p, stmt->xid, NULL, loc_cpy(emit->gwion->p, stmt_self(stmt)->pos));
- const Var_Decl_List var_decl_list = new_var_decl_list(emit->gwion->p, var_decl, NULL);
- const Exp exp = new_exp_decl(emit->gwion->p, type_decl, var_decl_list);
+ const Var_Decl var_decl = new_var_decl(emit->gwion->mp, stmt->xid, NULL, loc_cpy(emit->gwion->mp, stmt_self(stmt)->pos));
+ const Var_Decl_List var_decl_list = new_var_decl_list(emit->gwion->mp, var_decl, NULL);
+ const Exp exp = new_exp_decl(emit->gwion->mp, type_decl, var_decl_list);
exp->d.exp_decl.type = stmt->value->type;
var_decl->value = stmt->value;
CHECK_BB(emit_exp_decl(emit, &exp->d.exp_decl))
- free_exp(emit->gwion->p, exp);
+ free_exp(emit->gwion->mp, exp);
if(global) {
- const M_Object o = new_object(emit->gwion->p, NULL, stmt->value->type);
+ const M_Object o = new_object(emit->gwion->mp, NULL, stmt->value->type);
stmt->value->d.ptr = (m_uint*)o;
SET_FLAG(stmt->value, builtin);
SET_FLAG(stmt->value, global);
Instr instr = (Instr)vector_back(func->code->instr);
instr->opcode = eOP_MAX;
instr->execute = DTOR_EOC;
- instr->m_val = (m_uint)emit->gwion->p;
+ instr->m_val = (m_uint)emit->gwion->mp;
ADD_REF(func->code)
}
}
ANN static void emit_free_code(const Emitter emit, Code* code) {
if(vector_size(&code->instr))
free_code_instr(&code->instr, emit->gwion);
- free_code(emit->gwion->p, code);
+ free_code(emit->gwion->mp, code);
}
ANN static void emit_free_stack(const Emitter emit) {
__attribute__((returns_nonnull))
ANN2(1) Instr emit_add_instr(const Emitter emit, const f_instr f) {
- const Instr instr = mp_alloc(emit->gwion->p, Instr);
+ const Instr instr = mp_alloc(emit->gwion->mp, Instr);
if((m_uint)f < 255)
instr->opcode = (m_uint)f;
else {
{ memoize_return1, memoize_return2, memoize_return3, memoize_return4};
Memoize memoize_ini(const Emitter emit, const Func f, const enum Kind kind) {
- Memoize m = mp_alloc(emit->gwion->p, Memoize);
+ Memoize m = mp_alloc(emit->gwion->mp, Memoize);
vector_init(&m->v);
m->ret_sz = f->def->base->ret_type->size;
m->kind = kind;
#include "shreduler_private.h"
ANN VM* gwion_cpy(const VM* src) {
- const Gwion gwion = mp_alloc(src->gwion->p, Gwion);
- gwion->vm = new_vm(src->gwion->p, 0);
+ const Gwion gwion = mp_alloc(src->gwion->mp, Gwion);
+ gwion->vm = new_vm(src->gwion->mp, 0);
gwion->vm->gwion = gwion;
- gwion->vm->bbq->si = soundinfo_cpy(src->gwion->p, src->bbq->si);
+ gwion->vm->bbq->si = soundinfo_cpy(src->gwion->mp, src->bbq->si);
gwion->emit = src->gwion->emit;
gwion->env = src->gwion->env;
gwion->freearg = src->gwion->freearg;
gwion->st = src->gwion->st;
- gwion->p = src->gwion->p;
+ gwion->mp = src->gwion->mp;
return gwion->vm;
}
ANN m_bool gwion_ini(const Gwion gwion, Arg* arg) {
- gwion->p = mempool_ini((sizeof(VM_Shred) + SIZEOF_REG + SIZEOF_MEM) / SZ_INT);
- gwion->st = new_symbol_table(gwion->p, 65347);
- gwion->vm = new_vm(gwion->p, 1);
+ gwion->mp = mempool_ini((sizeof(VM_Shred) + SIZEOF_REG + SIZEOF_MEM) / SZ_INT);
+ gwion->st = new_symbol_table(gwion->mp, 65347);
+ gwion->vm = new_vm(gwion->mp, 1);
gwion->emit = new_emitter();
- gwion->env = new_env(gwion->p);
+ gwion->env = new_env(gwion->mp);
gwion->emit->env = gwion->env;
gwion->emit->gwion = gwion;
gwion->vm->gwion = gwion;
gwion->env->gwion = gwion;
- gwion->vm->bbq->si = new_soundinfo(gwion->p);
+ gwion->vm->bbq->si = new_soundinfo(gwion->mp);
arg->si = gwion->vm->bbq->si;
arg_parse(arg);
gwion->emit->memoize = arg->memoize;
- gwion->plug = new_plug(gwion->p, &arg->lib);
+ gwion->plug = new_plug(gwion->mp, &arg->lib);
map_init(&gwion->freearg);
shreduler_set_loop(gwion->vm->shreduler, arg->loop);
if(gwion_audio(gwion) > 0 && gwion_engine(gwion)) {
}
ANN void gwion_end(const Gwion gwion) {
- const VM_Code code = new_vm_code(gwion->p, NULL, 0, ae_flag_builtin, "in code dtor");
- gwion->vm->cleaner_shred = new_vm_shred(gwion->p, code);
+ const VM_Code code = new_vm_code(gwion->mp, NULL, 0, ae_flag_builtin, "in code dtor");
+ gwion->vm->cleaner_shred = new_vm_shred(gwion->mp, code);
vm_add_shred(gwion->vm, gwion->vm->cleaner_shred);
MUTEX_LOCK(gwion->vm->shreduler->mutex);
if(gwion->child.ptr)
free_plug(gwion);
map_release(&gwion->freearg);
free_symbols(gwion->st);
- mempool_end(gwion->p);
+ mempool_end(gwion->mp);
}
ANN void env_err(const Env env, const struct YYLTYPE* pos, const m_str fmt, ...) {
ArrayInfo* info = (ArrayInfo*)instr->m_val;
REM_REF((Type)vector_back(&info->type), gwion);
vector_release(&info->type);
- mp_free(((Gwion)gwion)->p, ArrayInfo, info);
+ mp_free(((Gwion)gwion)->mp, ArrayInfo, info);
}
GWION_IMPORT(array) {
static FREEARG(freearg_switchini) {
if(instr->m_val)
- free_vector(((Gwion)gwion)->p, (Vector)instr->m_val);
+ free_vector(((Gwion)gwion)->mp, (Vector)instr->m_val);
if(instr->m_val2)
- free_map(((Gwion)gwion)->p, (Map)instr->m_val2);
+ free_map(((Gwion)gwion)->mp, (Map)instr->m_val2);
}
static FREEARG(freearg_switchbranch) {
- free_map(((Gwion)gwion)->p, (Map)instr->m_val2);
+ free_map(((Gwion)gwion)->mp, (Map)instr->m_val2);
}
static FREEARG(freearg_gack) {
const Vector v = (Vector)instr->m_val2;
for(m_uint i = vector_size(v) + 1; --i;)
REM_REF(((Type)vector_at(v, i - 1)), gwion);
- free_vector(((Gwion)gwion)->p, v);
+ free_vector(((Gwion)gwion)->mp, v);
}
ANN static m_bool import_core_libs(const Gwi gwi) {
struct Gwi_ gwi;
memset(&gwi, 0, sizeof(struct Gwi_));
gwi.gwion = vm->gwion;
- gwi.loc = new_loc(vm->gwion->p, 0);
+ gwi.loc = new_loc(vm->gwion->mp, 0);
CHECK_BB(import_core_libs(&gwi))
vm->gwion->env->name = "[imported]";
for(m_uint i = 0; i < vector_size(plug_dirs); ++i) {
if(import && import(&gwi) < 0)
env_reset(gwi.gwion->env);
}
- free_loc(vm->gwion->p, gwi.loc);
+ free_loc(vm->gwion->mp, gwi.loc);
return GW_OK;
}
}
if(base || arg)
ERR_B(exp_self(l)->pos, "argument number does not match for lambda")
- l->def = new_func_def(env->gwion->p, new_func_base(env->gwion->p, def->base->td, l->name, l->args), l->code, def->flag,
- loc_cpy(env->gwion->p, def->pos));
+ l->def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, def->base->td, l->name, l->args), l->code, def->flag,
+ loc_cpy(env->gwion->mp, def->pos));
const m_bool ret = traverse_func_def(env, l->def);
arg = l->args;
while(arg) {
return unary->op == op_spork ? t_shred : t_fork;
else if(unary->code) {
++env->scope->depth; \
- nspc_push_value(env->gwion->p, env->curr); \
+ nspc_push_value(env->gwion->mp, env->curr); \
const m_bool ret = check_stmt(env, unary->code);
- nspc_pop_value(env->gwion->p, env->curr); \
+ nspc_pop_value(env->gwion->mp, env->curr); \
--env->scope->depth;
CHECK_BO(ret)
return unary->op == op_spork ? t_shred : t_fork;
static FREEARG(freearg_dottmpl) {
struct dottmpl_ *dt = (struct dottmpl_*)instr->m_val;
- free_type_list(((Gwion)gwion)->p, dt->tl);
- mp_free(((Gwion)gwion)->p, dottmpl, dt);
+ free_type_list(((Gwion)gwion)->mp, dt->tl);
+ mp_free(((Gwion)gwion)->mp, dottmpl, dt);
}
GWION_IMPORT(func) {
ANN static ID_List templater_def(SymTable *st, const Gwi gwi) {
const Templater* templater = &gwi->templater;
ID_List list[templater->n];
- list[0] = new_id_list(st->p, insert_symbol(st, templater->list[0]), loc_cpy(gwi->gwion->p, gwi->loc));
+ list[0] = new_id_list(st->p, insert_symbol(st, templater->list[0]), loc_cpy(gwi->gwion->mp, gwi->loc));
for(m_uint i = 1; i < templater->n; i++) {
- list[i] = new_id_list(st->p, insert_symbol(st, templater->list[i]), loc_cpy(gwi->gwion->p, gwi->loc));
+ list[i] = new_id_list(st->p, insert_symbol(st, templater->list[i]), loc_cpy(gwi->gwion->mp, gwi->loc));
list[i - 1]->next = list[i];
}
return list[0];
if((i != 1 && last != '.' && last != '\0') ||
(i == 1 && c != '.')) {
path_valid_inner(p->curr);
- *list = prepend_id_list(env->gwion->st->p, insert_symbol(env->gwion->st, p->curr), *list, loc_cpy(env->gwion->p, &p->loc));
+ *list = prepend_id_list(env->gwion->st->p, insert_symbol(env->gwion->st, p->curr), *list, loc_cpy(env->gwion->mp, &p->loc));
memset(p->curr, 0, p->len + 1);
} else {
env_err(env, &p->loc, "path '%s' must not ini or end with '.'.", p->path);
*array_depth = depth;
if(path_valid(env, &list, &p) < 0) {
if(list)
- free_id_list(env->gwion->p, list);
+ free_id_list(env->gwion->mp, list);
return NULL;
}
CHECK_OO(list)
}
ANN2(1,2) Type gwi_mk_type(const Gwi gwi NUSED, const m_str name, const m_uint size, const Type parent) {
- const Type t = new_type(gwi->gwion->p, 0, name, parent);
+ const Type t = new_type(gwi->gwion->mp, 0, name, parent);
t->size = size;
return t;
}
ANN2(1,2) static void import_class_ini(const Env env, const Type type,
const f_xtor pre_ctor, const f_xtor dtor) {
- type->nspc = new_nspc(env->gwion->p, type->name);
+ type->nspc = new_nspc(env->gwion->mp, type->name);
type->nspc->parent = env->curr;
if(pre_ctor)
- mk_xtor(env->gwion->p, type, (m_uint)pre_ctor, ae_flag_ctor);
+ mk_xtor(env->gwion->mp, type, (m_uint)pre_ctor, ae_flag_ctor);
if(dtor)
- mk_xtor(env->gwion->p, type, (m_uint)dtor, ae_flag_dtor);
+ mk_xtor(env->gwion->mp, type, (m_uint)dtor, ae_flag_dtor);
if(type->parent) {
type->nspc->info->offset = type->parent->nspc->info->offset;
if(type->parent->nspc->info->vtable.ptr)
ERR_B(gwi->loc, "during import: class '%s' already imported.", type->name)
if(gwi->templater.n) {
const ID_List types = templater_def(gwi->gwion->st, gwi);
- type->def = new_class_def(gwi->gwion->p, 0, insert_symbol(gwi->gwion->st, type->name), NULL, NULL, loc_cpy(gwi->gwion->p, gwi->loc));
- type->def->tmpl = new_tmpl_class(gwi->gwion->p, types, -1);
+ type->def = new_class_def(gwi->gwion->mp, 0, insert_symbol(gwi->gwion->st, type->name), NULL, NULL, loc_cpy(gwi->gwion->mp, gwi->loc));
+ type->def->tmpl = new_tmpl_class(gwi->gwion->mp, types, -1);
type->def->base.type = type;
SET_FLAG(type, template);
} else
if(ctor)
emit_ext_ctor(gwi->gwion->emit, ctor);
emit_class_finish(gwi->gwion->emit, gwi->gwion->env->class_def->nspc);
- free_type_decl(gwi->gwion->p, td);
+ free_type_decl(gwi->gwion->mp, td);
} else {
SET_FLAG(td, typedef);
gwi->gwion->env->class_def->def->base.ext = td;
ANN2(1) m_int gwi_item_end(const Gwi gwi, const ae_flag flag, const m_uint* addr) {
DL_Var* v = &gwi->var;
- dl_var_set(gwi->gwion->p, v, flag | ae_flag_builtin);
+ dl_var_set(gwi->gwion->mp, v, flag | ae_flag_builtin);
v->var.addr = (void*)addr;
if(gwi->gwion->env->class_def && GET_FLAG(gwi->gwion->env->class_def, template)) {
- Type_Decl *type_decl = new_type_decl(gwi->gwion->p, v->t.xid, flag);
- const Var_Decl var_decl = new_var_decl(gwi->gwion->p, v->var.xid, v->var.array, loc_cpy(gwi->gwion->p, gwi->loc));
- const Var_Decl_List var_decl_list = new_var_decl_list(gwi->gwion->p, var_decl, NULL);
- const Exp exp = new_exp_decl(gwi->gwion->p, type_decl, var_decl_list);
- const Stmt stmt = new_stmt_exp(gwi->gwion->p, ae_stmt_exp, exp);
- const Stmt_List list = new_stmt_list(gwi->gwion->p, stmt, NULL);
- Section* section = new_section_stmt_list(gwi->gwion->p, list);
- const Class_Body body = new_class_body(gwi->gwion->p, section, NULL);
+ Type_Decl *type_decl = new_type_decl(gwi->gwion->mp, v->t.xid, flag);
+ const Var_Decl var_decl = new_var_decl(gwi->gwion->mp, v->var.xid, v->var.array, loc_cpy(gwi->gwion->mp, gwi->loc));
+ const Var_Decl_List var_decl_list = new_var_decl_list(gwi->gwion->mp, var_decl, NULL);
+ const Exp exp = new_exp_decl(gwi->gwion->mp, type_decl, var_decl_list);
+ const Stmt stmt = new_stmt_exp(gwi->gwion->mp, ae_stmt_exp, exp);
+ const Stmt_List list = new_stmt_list(gwi->gwion->mp, stmt, NULL);
+ Section* section = new_section_stmt_list(gwi->gwion->mp, list);
+ const Class_Body body = new_class_body(gwi->gwion->mp, section, NULL);
type_decl->array = v->t.array;
gwi_body(gwi, body);
return GW_OK;
v->exp.pos = gwi->loc;
CHECK_BB(traverse_decl(gwi->gwion->env, &v->exp.d.exp_decl))
SET_FLAG(v->var.value, builtin);
- dl_var_release(gwi->gwion->p, v);
+ dl_var_release(gwi->gwion->mp, v);
return (m_int)v->var.value->offset;
}
ANN /*static */ Type_List str2tl(const Env env, const m_str s, m_uint *depth) {
Type_Decl* td = str2decl(env, s, depth);
- td->array = make_dll_arg_list_array(env->gwion->p, NULL, depth, 0);
- return new_type_list(env->gwion->p, td, NULL);
+ td->array = make_dll_arg_list_array(env->gwion->mp, NULL, depth, 0);
+ return new_type_list(env->gwion->mp, td, NULL);
}
ANN Type_Decl* str2decl(const Env env, const m_str s, m_uint *depth) {
CHECK_OO(type_name)
ID_List id = str2list(env, type_name, depth);
CHECK_OO(id)
- Type_Decl* td = new_type_decl(env->gwion->p, id, 0);
+ Type_Decl* td = new_type_decl(env->gwion->mp, id, 0);
Type_List tmp = NULL;
if(!td) {
- free_id_list(env->gwion->p, id);
+ free_id_list(env->gwion->mp, id);
return NULL;
}
while((type_name = get_type_name(env, s, i++))) {
ID_List type_path2;
if(!(type_decl = str2decl(env, arg->type, &array_depth))) {
if(arg_list)
- free_arg_list(env->gwion->p, arg_list);
+ free_arg_list(env->gwion->mp, arg_list);
env_err(env, gwi->loc, "\t...\tat argument '%i'", i + 1);
return NULL;
}
if((type_path2 = str2list(env, arg->name, &array_depth2)))
- free_id_list(env->gwion->p, type_path2);
+ free_id_list(env->gwion->mp, type_path2);
if(array_depth && array_depth2) {
- free_type_decl(env->gwion->p, type_decl);
+ free_type_decl(env->gwion->mp, type_decl);
if(arg_list)
- free_arg_list(env->gwion->p, arg_list);
+ free_arg_list(env->gwion->mp, arg_list);
env_err(env, gwi->loc, "array subscript specified incorrectly for built-in module");
return NULL;
}
- array_sub = make_dll_arg_list_array(env->gwion->p, array_sub, &array_depth, array_depth2);
- var_decl = new_var_decl(env->gwion->p, insert_symbol(env->gwion->st, arg->name), array_sub, loc_cpy(gwi->gwion->p, gwi->loc));
- arg_list = new_arg_list(env->gwion->p, type_decl, var_decl, arg_list);
+ array_sub = make_dll_arg_list_array(env->gwion->mp, array_sub, &array_depth, array_depth2);
+ var_decl = new_var_decl(env->gwion->mp, insert_symbol(env->gwion->st, arg->name), array_sub, loc_cpy(gwi->gwion->mp, gwi->loc));
+ arg_list = new_arg_list(env->gwion->mp, type_decl, var_decl, arg_list);
}
return arg_list;
}
flag |= ae_flag_builtin;
if(!(type_path = str2list(env, dl_fun->type, &array_depth)) ||
- !(type_decl = new_type_decl(env->gwion->p, type_path, 0))) {
- if(type_path)free_id_list(env->gwion->p, type_path);
+ !(type_decl = new_type_decl(env->gwion->mp, type_path, 0))) {
+ if(type_path)free_id_list(env->gwion->mp, type_path);
env_err(env, gwi->loc, "\t...\tduring @ function import '%s' (type).", dl_fun->name);
return NULL;
}
if(array_depth) {
- Array_Sub array_sub = new_array_sub(env->gwion->p, NULL);
+ Array_Sub array_sub = new_array_sub(env->gwion->mp, NULL);
for(i = 1; i < array_depth; i++)
array_sub = prepend_array_sub(array_sub, NULL);
type_decl = add_type_decl_array(type_decl, array_sub);
}
name = dl_fun->name;
arg_list = make_dll_arg_list(gwi, dl_fun);
- func_def = new_func_def(env->gwion->p, new_func_base(env->gwion->p, type_decl, insert_symbol(env->gwion->st, name), arg_list),
- NULL, flag, loc_cpy(gwi->gwion->p, gwi->loc));
+ func_def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, type_decl, insert_symbol(env->gwion->st, name), arg_list),
+ NULL, flag, loc_cpy(gwi->gwion->mp, gwi->loc));
func_def->d.dl_func_ptr = (void*)(m_uint)dl_fun->addr;
return func_def;
}
// Func_Def def = import_fun(gwi->gwion->env, &gwi->func, flag);
CHECK_OB(def)
if(gwi->templater.n) {
- def = new_func_def(gwi->gwion->p, new_func_base(gwi->gwion->p, NULL, NULL, NULL), NULL, 0, loc_cpy(gwi->gwion->p, gwi->loc));
+ def = new_func_def(gwi->gwion->mp, new_func_base(gwi->gwion->mp, NULL, NULL, NULL), NULL, 0, loc_cpy(gwi->gwion->mp, gwi->loc));
const ID_List list = templater_def(gwi->gwion->st, gwi);
- def->tmpl = new_tmpl_list(gwi->gwion->p, list, -1);
+ def->tmpl = new_tmpl_list(gwi->gwion->mp, list, -1);
SET_FLAG(def, template);
}
if(gwi->gwion->env->class_def && GET_FLAG(gwi->gwion->env->class_def, template)) {
- Section* section = new_section_func_def(gwi->gwion->p, def);
- Class_Body body = new_class_body(gwi->gwion->p, section, NULL);
+ Section* section = new_section_func_def(gwi->gwion->mp, def);
+ Class_Body body = new_class_body(gwi->gwion->mp, section, NULL);
gwi_body(gwi, body);
return GW_OK;
}
if(traverse_func_def(gwi->gwion->env, def) < 0) {
- free_func_def(gwi->gwion->p, def);
+ free_func_def(gwi->gwion->mp, def);
return GW_ERROR;
}
return GW_OK;
const ID_List list = (str && str != (m_str)OP_ANY_TYPE) ? str2list(env, str, &depth) : NULL;
const Type t = (str == (m_str) OP_ANY_TYPE) ? OP_ANY_TYPE : list ? find_type(env, list) : NULL;
if(list)
- free_id_list(env->gwion->p, list);
+ free_id_list(env->gwion->mp, list);
return t ? (depth ? array_type(env, t, depth) : t) : NULL;
}
const Arg_List args = make_dll_arg_list(gwi, dl_fun);
flag |= ae_flag_builtin;
if(!(type_path = str2list(env, dl_fun->type, &array_depth)) ||
- !(type_decl = new_type_decl(env->gwion->p, type_path, 0))) {
+ !(type_decl = new_type_decl(env->gwion->mp, type_path, 0))) {
env_err(env, gwi->loc, "\t...\tduring fptr import '%s' (type).",
dl_fun->name);
return NULL;
}
- struct Func_Base_ *base = new_func_base(env->gwion->p, type_decl, insert_symbol(env->gwion->st, dl_fun->name), args);
- return new_stmt_fptr(env->gwion->p, base, flag);
+ struct Func_Base_ *base = new_func_base(env->gwion->mp, type_decl, insert_symbol(env->gwion->st, dl_fun->name), args);
+ return new_stmt_fptr(env->gwion->mp, base, flag);
}
ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) {
SET_FLAG(stmt->d.stmt_fptr.base->func, builtin);
const Type t = stmt->d.stmt_fptr.type;
// ADD_REF(t);
- free_stmt(gwi->gwion->p, stmt);
+ free_stmt(gwi->gwion->mp, stmt);
return t;
}
Array_Sub array = NULL;
CHECK_OO((id_list = str2list(env, type, &array_depth)))
if(array_depth) {
- array = new_array_sub(env->gwion->p, NULL);
+ array = new_array_sub(env->gwion->mp, NULL);
array->depth = array_depth;
}
- type_decl = new_type_decl(env->gwion->p, id_list, 0);
- const Var_Decl var_decl = new_var_decl(env->gwion->p,
- insert_symbol(env->gwion->st, name), array, loc_cpy(env->gwion->p, gwi->loc));
- const Var_Decl_List var_decl_list = new_var_decl_list(env->gwion->p, var_decl, NULL);
- return new_exp_decl(env->gwion->p, type_decl, var_decl_list);
+ type_decl = new_type_decl(env->gwion->mp, id_list, 0);
+ const Var_Decl var_decl = new_var_decl(env->gwion->mp,
+ insert_symbol(env->gwion->st, name), array, loc_cpy(env->gwion->mp, gwi->loc));
+ const Var_Decl_List var_decl_list = new_var_decl_list(env->gwion->mp, var_decl, NULL);
+ return new_exp_decl(env->gwion->mp, type_decl, var_decl_list);
}
ANN2(1) m_int gwi_union_ini(const Gwi gwi, const m_str name) {
ERR_B(gwi->loc, "type '%s' unknown in union declaration.", type)
if(isa(t, t_object) > 0)
SET_FLAG(exp->d.exp_decl.td, ref);
- gwi->union_data.list = new_decl_list(gwi->gwion->p, exp, gwi->union_data.list);
+ gwi->union_data.list = new_decl_list(gwi->gwion->mp, exp, gwi->union_data.list);
return GW_OK;
}
ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) {
if(!gwi->union_data.list)
ERR_O(gwi->loc, "union is empty");
- const Stmt stmt = new_stmt_union(gwi->gwion->p, gwi->union_data.list, loc_cpy(gwi->gwion->p, gwi->loc));
+ const Stmt stmt = new_stmt_union(gwi->gwion->mp, gwi->union_data.list, loc_cpy(gwi->gwion->mp, gwi->loc));
stmt->d.stmt_union.flag = flag;
CHECK_BO(traverse_stmt_union(gwi->gwion->env, &stmt->d.stmt_union))
emit_union_offset(stmt->d.stmt_union.l, stmt->d.stmt_union.o);
stmt->d.stmt_union.o + stmt->d.stmt_union.s;
const Type t = stmt->d.stmt_union.xid ? stmt->d.stmt_union.value->type :
stmt->d.stmt_union.type_xid ? stmt->d.stmt_union.type : t_int;
- free_stmt(gwi->gwion->p, stmt);
+ free_stmt(gwi->gwion->mp, stmt);
gwi->union_data.list = NULL;
gwi->union_data.xid = NULL;
return t;
}
ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint i) {
- const ID_List list = new_id_list(gwi->gwion->p, insert_symbol(gwi->gwion->st, name), loc_cpy(gwi->gwion->p, gwi->loc));
+ const ID_List list = new_id_list(gwi->gwion->mp, insert_symbol(gwi->gwion->st, name), loc_cpy(gwi->gwion->mp, gwi->loc));
DL_Enum* d = &gwi->enum_data;
- ALLOC_PTR(gwi->gwion->p, addr, m_int, i);
+ ALLOC_PTR(gwi->gwion->mp, addr, m_int, i);
vector_add(&gwi->enum_data.addr, (vtype)addr);
if(!d->base)
d->base = list;
ANN Type gwi_enum_end(const Gwi gwi) {
DL_Enum* d = &gwi->enum_data;
- const Stmt stmt = new_stmt_enum(gwi->gwion->p, d->base, d->t ? insert_symbol(gwi->gwion->st, d->t) : NULL);
+ const Stmt stmt = new_stmt_enum(gwi->gwion->mp, d->base, d->t ? insert_symbol(gwi->gwion->st, d->t) : NULL);
if(traverse_stmt_enum(gwi->gwion->env, &stmt->d.stmt_enum) < 0) {
- free_id_list(gwi->gwion->p, d->base);
+ free_id_list(gwi->gwion->mp, d->base);
return NULL;
}
import_enum_end(gwi, &stmt->d.stmt_enum.values);
const Type t = stmt->d.stmt_enum.t;
- free_stmt(gwi->gwion->p, stmt);
+ free_stmt(gwi->gwion->mp, stmt);
return t;
}
const Value v = nspc_lookup_value1(t->nspc, sym);
CHECK_OO(v)
const Func_Def base = v->d.func_ref->def;
- const Func_Def def = new_func_def(env->gwion->p, new_func_base(env->gwion->p, base->base->td, insert_symbol(env->gwion->st, v->name),
- base->base->args), base->d.code, base->flag, loc_cpy(env->gwion->p, base->pos));
- def->tmpl = new_tmpl_list(env->gwion->p, base->tmpl->list, dt->overload);
+ const Func_Def def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, base->base->td, insert_symbol(env->gwion->st, v->name),
+ base->base->args), base->d.code, base->flag, loc_cpy(env->gwion->mp, base->pos));
+ def->tmpl = new_tmpl_list(env->gwion->mp, base->tmpl->list, dt->overload);
SET_FLAG(def, template);
return def;
}
__attribute__((hot))
ANN void __release(const M_Object o, const VM_Shred shred) {
- MemPool p = shred->info->mp;// = shred->info->vm->gwion->p;
+ MemPool p = shred->info->mp;// = shred->info->vm->gwion->mp;
Type t = o->type_ref;
while(t->parent) {
struct scope_iter iter = { t->nspc->info->value, 0, 0 };\
strcpy(name, t->name);
strcpy(name + len, STR_FORCE);
const Symbol sym = insert_symbol(env->gwion->st, name);
- return nspc_lookup_type0(t->owner, sym) ?: new_force_type(env->gwion->p, t, sym);
+ return nspc_lookup_type0(t->owner, sym) ?: new_force_type(env->gwion->mp, t, sym);
}
static OP_CHECK(opck_object_cast) {
static GWION_IMPORT(values) {
VM* vm = gwi_vm(gwi);
- ALLOC_PTR(gwi->gwion->p, d_zero, m_float, 0.0);
- ALLOC_PTR(gwi->gwion->p, sr, m_float, (m_float)vm->bbq->si->sr);
- ALLOC_PTR(gwi->gwion->p, samp, m_float, 1.0);
- ALLOC_PTR(gwi->gwion->p, ms, m_float, (m_float)(*sr / 1000.));
- ALLOC_PTR(gwi->gwion->p, second, m_float, (m_float)*sr);
- ALLOC_PTR(gwi->gwion->p, minute, m_float, (m_float)(*sr * 60.0));
- ALLOC_PTR(gwi->gwion->p, hour, m_float, (m_float)(*minute * 60.0));
- ALLOC_PTR(gwi->gwion->p, t_zero, m_float, 0.0);
- ALLOC_PTR(gwi->gwion->p, pi, m_float, (m_float)M_PI);
+ ALLOC_PTR(gwi->gwion->mp, d_zero, m_float, 0.0);
+ ALLOC_PTR(gwi->gwion->mp, sr, m_float, (m_float)vm->bbq->si->sr);
+ ALLOC_PTR(gwi->gwion->mp, samp, m_float, 1.0);
+ ALLOC_PTR(gwi->gwion->mp, ms, m_float, (m_float)(*sr / 1000.));
+ ALLOC_PTR(gwi->gwion->mp, second, m_float, (m_float)*sr);
+ ALLOC_PTR(gwi->gwion->mp, minute, m_float, (m_float)(*sr * 60.0));
+ ALLOC_PTR(gwi->gwion->mp, hour, m_float, (m_float)(*minute * 60.0));
+ ALLOC_PTR(gwi->gwion->mp, t_zero, m_float, 0.0);
+ ALLOC_PTR(gwi->gwion->mp, pi, m_float, (m_float)M_PI);
gwi_item_ini(gwi, "float", "samplerate");
gwi_item_end(gwi, ae_flag_const, sr);
gwi_item_ini(gwi, "float", "pi");
ANN static m_int add_ugen(const Gwi gwi, struct ugen_importer* imp) {
VM* vm = gwi_vm(gwi);
- const M_Object o = new_M_UGen(gwi->gwion->p);
+ const M_Object o = new_M_UGen(gwi->gwion->mp);
const UGen u = imp->ugen = UGEN(o);
- ugen_ini(vm->gwion->p, u, imp->nchan, imp->nchan);
- ugen_gen(vm->gwion->p, u, imp->tick, (void*)imp->vm, 0);
+ ugen_ini(vm->gwion->mp, u, imp->nchan, imp->nchan);
+ ugen_gen(vm->gwion->mp, u, imp->tick, (void*)imp->vm, 0);
vector_add(&vm->ugen, (vtype)u);
CHECK_BB(gwi_item_ini(gwi, "UGen", imp->name))
return gwi_item_end(gwi, ae_flag_const, o);
static FREEARG(freearg_vararg) {
if(instr->m_val2)
- free_vector(((Gwion)gwion)->p, (Vector)instr->m_val2);
+ free_vector(((Gwion)gwion)->mp, (Vector)instr->m_val2);
}
GWION_IMPORT(vararg) {
ANN static void free_context(const Context a, Gwion gwion) {
REM_REF(a->nspc, gwion)
- mp_free(gwion->p, Context, a);
+ mp_free(gwion->mp, Context, a);
}
ANN2(2) Context new_context(MemPool p, const Ast ast, const m_str str) {
if(context->lbls.ptr) {
LOOP_OPTIM
for(m_uint i = 0; i < map_size(&context->lbls); i++)
- free_map(env->gwion->p, (Map)map_at(&context->lbls, i));
+ free_map(env->gwion->mp, (Map)map_at(&context->lbls, i));
map_release(&context->lbls);
}
REM_REF(context, env->gwion);
vector_release(&a->breaks);
vector_release(&a->conts);
switch_release(a->swi);
- mp_free(gwion->p, Scope, a->swi);
- mp_free(gwion->p, Env_Scope, a);
+ mp_free(gwion->mp, Scope, a->swi);
+ mp_free(gwion->mp, Env_Scope, a);
}
ANN void free_env(const Env a) {
}
ANN void env_add_type(const Env env, const Type type) {
- const Type v_type = type_copy(env->gwion->p, t_class);
+ const Type v_type = type_copy(env->gwion->mp, t_class);
v_type->d.base_type = type;
SET_FLAG(type, builtin);
nspc_add_type(env->curr, insert_symbol(type->name), type);
- const Value v = new_value(env->gwion->p, v_type, type->name);
+ const Value v = new_value(env->gwion->mp, v_type, type->name);
SET_FLAG(v, checked | ae_flag_const | ae_flag_global | ae_flag_builtin);
nspc_add_value(env->curr, insert_symbol(type->name), v);
type->owner = env->curr;
}
ANN m_bool type_engine_check_prog(const Env env, const Ast ast) {
- const Context ctx = new_context(env->gwion->p, ast, env->name);
+ const Context ctx = new_context(env->gwion->mp, ast, env->name);
env_reset(env);
load_context(ctx, env);
const m_bool ret = traverse_ast(env, ast);
}
REM_REF(v, gwion);
}
- free_scope(gwion->p, a->info->value);
+ free_scope(gwion->mp, a->info->value);
}
#define describe_nspc_free(A, b) \
A a;\
while(scope_iter(&iter, &a) > 0) \
REM_REF(a, gwion);\
- free_scope(gwion->p, n->info->b);\
+ free_scope(gwion->mp, n->info->b);\
}
describe_nspc_free(Func, func)
vector_release(&a->info->vtable);
if(a->info->op_map.ptr)
free_op_map(&a->info->op_map, gwion);
- mp_free(gwion->p, NspcInfo, a->info);
+ mp_free(gwion->mp, NspcInfo, a->info);
if(a->pre_ctor)
REM_REF(a->pre_ctor, gwion);
if(a->dtor)
REM_REF(a->dtor, gwion);
- mp_free(gwion->p, Nspc, a);
+ mp_free(gwion->mp, Nspc, a);
}
ANN Nspc new_nspc(MemPool p, const m_str name) {
};
ANN static Switch new_swinfo(const Env env, const Stmt_Switch stmt) {
- struct SwInfo_ *info = mp_alloc(env->gwion->p, SwInfo);
+ struct SwInfo_ *info = mp_alloc(env->gwion->mp, SwInfo);
info->s = stmt;
info->t = env->class_def;
info->f = env->func;
- const Switch sw = new_switch(env->gwion->p);
+ const Switch sw = new_switch(env->gwion->mp);
map_set(&env->scope->swi->map, (vtype)info, (vtype)sw);
sw->depth = env->scope->depth + 2;
return sw;
void switch_reset(const Env env) {
for(m_uint i = VLEN(&env->scope->swi->map) + 1; --i;) {
struct SwInfo_ *info = (struct SwInfo_ *)VKEY(&env->scope->swi->map, i - 1);
- mp_free(env->gwion->p, SwInfo, info);
+ mp_free(env->gwion->mp, SwInfo, info);
Switch sw = (Switch)VVAL(&env->scope->swi->map, i - 1);
- free_switch(env->gwion->p, sw);
+ free_switch(env->gwion->mp, sw);
}
_scope_clear(env->scope->swi);
map_clear(&env->scope->swi->map);
ANN Vector switch_vec(const Env env) {
const Switch sw = (Switch)_scope_back(env->scope->swi);
- return vector_copy(env->gwion->p, sw->vec); // new_vector(); // dyn only
+ return vector_copy(env->gwion->mp, sw->vec); // new_vector(); // dyn only
}
ANN m_uint switch_idx(const Env env) {
if(!VLEN(sw->cases) && !VLEN(&sw->exp))
ERR_B(pos, "switch statement with no cases.")
map_remove(&env->scope->swi->map, index);
- free_switch(env->gwion->p, sw);
+ free_switch(env->gwion->mp, sw);
return GW_OK;
}
ANN static void free_type(Type a, Gwion gwion) {
if(GET_FLAG(a, template))
- free_class_def(gwion->p, a->def);
+ free_class_def(gwion->mp, a->def);
if(a->nspc)
REM_REF(a->nspc, gwion);
- mp_free(gwion->p, Type, a);
+ mp_free(gwion->mp, Type, a);
}
Type new_type(MemPool p, const m_uint xid, const m_str name, const Type parent) {
const Type type = nspc_lookup_type1(base->owner, sym);
if(type)
return type;
- const Type t = new_type(env->gwion->p, t_array->xid, base->name, t_array);
+ const Type t = new_type(env->gwion->mp, t_array->xid, base->name, t_array);
t->name = s_name(sym);
t->size = SZ_INT;
t->array_depth = depth + base->array_depth;
if(!GET_FLAG(a, func) && a->d.ptr && !GET_FLAG(a, union) &&
!(GET_FLAG(a, enum) && GET_FLAG(a, builtin) && a->owner_class)
&& isa(a->type, t_object) < 0)
- _mp_free(gwion->p, a->type->size, a->d.ptr);
+ _mp_free(gwion->mp, a->type->size, a->d.ptr);
if(isa(a->type, t_class) > 0 || isa(a->type, t_function) > 0 || GET_FLAG(a->type, op))
REM_REF(a->type, gwion)
- mp_free(gwion->p, Value, a);
+ mp_free(gwion->mp, Value, a);
}
ANN Value new_value(MemPool p, const Type type, const m_str name) {
td->xid = str2list(env, t->name, &depth);
if(depth) {
- Exp base = new_exp_prim_int(env->gwion->p, 0, new_loc(env->gwion->p, __LINE__)), e = base;
+ Exp base = new_exp_prim_int(env->gwion->mp, 0, new_loc(env->gwion->mp, __LINE__)), e = base;
for(m_uint i = 0; i < depth - 1; ++i) {
- e = (e->next = new_exp_prim_int(env->gwion->p, 0, new_loc(env->gwion->p, __LINE__)));
+ e = (e->next = new_exp_prim_int(env->gwion->mp, 0, new_loc(env->gwion->mp, __LINE__)));
}
- td->array = new_array_sub(env->gwion->p, base);
+ td->array = new_array_sub(env->gwion->mp, base);
}
return t;
}
}
ID_List id = NULL;
for(m_uint i = vector_size(&v) + 1; --i;)
- id = prepend_id_list(env->gwion->p, (Symbol)vector_at(&v, i - 1), id, new_loc(env->gwion->p, __LINE__));
+ id = prepend_id_list(env->gwion->mp, (Symbol)vector_at(&v, i - 1), id, new_loc(env->gwion->mp, __LINE__));
vector_release(&v);
assert(id);
- Type_Decl* td = new_type_decl(env->gwion->p, id, 0);
- return new_type_list(env->gwion->p, td, NULL);
+ Type_Decl* td = new_type_decl(env->gwion->mp, id, 0);
+ return new_type_list(env->gwion->mp, td, NULL);
}
ANN static m_bool func_match_inner(const Env env, const Exp e, const Type t,
if(!(value = template_get_ready(env, v, "template", i)))
continue;
base = value->d.func_ref->def;
- def->tmpl = new_tmpl_list(env->gwion->p, base->tmpl->list, (m_int)i);
+ def->tmpl = new_tmpl_list(env->gwion->mp, base->tmpl->list, (m_int)i);
}
} else {
if(!(value = template_get_ready(env, v, "template", i)))
continue;
base = value->d.func_ref->def;
- def = new_func_def(env->gwion->p, new_func_base(env->gwion->p, base->base->td, insert_symbol(v->name),
- base->base->args), base->d.code, base->flag, loc_cpy(env->gwion->p, base->pos));
- def->tmpl = new_tmpl_list(env->gwion->p, base->tmpl->list, (m_int)i);
+ def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, base->base->td, insert_symbol(v->name),
+ base->base->args), base->d.code, base->flag, loc_cpy(env->gwion->mp, base->pos));
+ def->tmpl = new_tmpl_list(env->gwion->mp, base->tmpl->list, (m_int)i);
SET_FLAG(def, template);
}
if(traverse_func_template(env, def, types) > 0) {
- nspc_pop_type(env->gwion->p, env->curr);
+ nspc_pop_type(env->gwion->mp, env->curr);
if(check_call(env, exp) > 0) {
const Func next = def->base->func->next;
def->base->func->next = NULL;
}
// check m_func => maybe assert
if(!m_func && sz != vector_size((Vector)env->curr->info->type))
- nspc_pop_type(env->gwion->p, env->curr);
+ nspc_pop_type(env->gwion->mp, env->curr);
SET_FLAG(base, template);
}
end:
ANN static Func get_template_func(const Env env, const Exp_Call* func, const Value v) {
const Func f = find_template_match(env, v, func);
if(f) {
- Tmpl_Call* tmpl = new_tmpl_call(env->gwion->p, func->tmpl->types);
+ Tmpl_Call* tmpl = new_tmpl_call(env->gwion->mp, func->tmpl->types);
tmpl->base = v->d.func_ref->def->tmpl->list;
((Exp_Call*)func)->tmpl = tmpl;
return ((Exp_Call*)func)->m_func = f;
}
if(arg || e)
ERR_O(exp_self(exp)->pos, "argument number does not match for lambda")
- l->def = new_func_def(env->gwion->p, new_func_base(env->gwion->p, NULL, l->name, l->args),
- l->code, 0, loc_cpy(env->gwion->p, exp_self(exp)->pos));
+ l->def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, NULL, l->name, l->args),
+ l->code, 0, loc_cpy(env->gwion->mp, exp_self(exp)->pos));
CHECK_BO(traverse_func_def(env, l->def))
if(env->class_def)
SET_FLAG(l->def, member);
check_class_def(env, ptr->def);
}
t = depth ? array_type(env, ptr, depth) : ptr;
- stmt->v = new_value(env->gwion->p, t, s_name(stmt->sym));
+ stmt->v = new_value(env->gwion->mp, t, s_name(stmt->sym));
SET_FLAG(stmt->v, checked);
nspc_add_value(env->curr, stmt->sym, stmt->v);
return check_conts(env, stmt_self(stmt), stmt->body);
}
ANN static Value set_variadic(const Env env) {
- const Value variadic = new_value(env->gwion->p, t_vararg, "vararg");
+ const Value variadic = new_value(env->gwion->mp, t_vararg, "vararg");
SET_FLAG(variadic, checked);
nspc_add_value(env->curr, insert_symbol("vararg"), variadic);
return variadic;
const Func former = env->func;
env->func = func;
++env->scope->depth;
- nspc_push_value(env->gwion->p, env->curr);
+ nspc_push_value(env->gwion->mp, env->curr);
if(!f->base->args)
UNSET_FLAG(f->base->func, pure);
else
else if(GET_FLAG(f, op))
operator_func(func);
}
- nspc_pop_value(env->gwion->p, env->curr);
+ nspc_pop_value(env->gwion->mp, env->curr);
--env->scope->depth;
env->func = former;
if(GET_FLAG(f, global))
CHECK_BB(template_push_types(env, class_def->tmpl->list.list, class_def->tmpl->base))
CHECK_BB(traverse_template(env, t->def))
if(class_def->tmpl)
- nspc_pop_type(env->gwion->p, env->curr);
+ nspc_pop_type(env->gwion->mp, env->curr);
}
}
if(!GET_FLAG(class_def->base.type->parent, checked))
ANN static void free_func(Func a, Gwion gwion) {
if(GET_FLAG(a, template)) {
- free_tmpl_list(gwion->p, a->def->tmpl);
- free_func_base(gwion->p, a->def->base);
- free_loc(gwion->p, a->def->pos);
- mp_free(gwion->p, Func_Def, a->def);
+ free_tmpl_list(gwion->mp, a->def->tmpl);
+ free_func_base(gwion->mp, a->def->base);
+ free_loc(gwion->mp, a->def->pos);
+ mp_free(gwion->mp, Func_Def, a->def);
}
if(a->code)
REM_REF(a->code, gwion);
- mp_free(gwion->p, Func, a);
+ mp_free(gwion->mp, Func, a);
}
ANN Func new_func(MemPool p, const m_str name, const Func_Def def) {
REM_REF(a->rhs, gwion)
if(a->ret)
REM_REF(a->ret, gwion)
- mp_free(gwion->p, M_Operator, a);
+ mp_free(gwion->mp, M_Operator, a);
}
ANN void free_op_map(Map map, struct Gwion_ *gwion) {
LOOP_OPTIM
for(m_uint j = vector_size(v) + 1; --j;)
free_op((M_Operator*)vector_at(v, j - 1), gwion);
- free_vector(gwion->p, v);
+ free_vector(gwion->mp, v);
}
map_release(map);
}
} while((n = n->parent));
Vector v = (Vector)map_get(&nspc->info->op_map, (vtype)opi->op);
if(!v) {
- v = new_vector(gwion->p);
+ v = new_vector(gwion->mp);
map_set(&nspc->info->op_map, (vtype)opi->op, (vtype)v);
}
// new mo
- mo = mp_alloc(gwion->p, M_Operator);
+ mo = mp_alloc(gwion->mp, M_Operator);
mo->lhs = opi->lhs;
mo->rhs = opi->rhs;
mo->ret = opi->ret;
#include "traverse.h"
ANN static Value mk_class(const Env env, const Type base) {
- const Type t = type_copy(env->gwion->p, t_class);
- const Value v = new_value(env->gwion->p, t, base->name);
+ const Type t = type_copy(env->gwion->mp, t_class);
+ const Value v = new_value(env->gwion->mp, t, base->name);
t->d.base_type = base;
v->owner = base->owner;
SET_FLAG(v, const | ae_flag_checked);
CHECK_BB(env_access(env, stmt->base->td->flag, stmt_self(stmt)->pos))
CHECK_BB(scan0_defined(env, stmt->base->xid, td_pos(stmt->base->td)));
const m_str name = s_name(stmt->base->xid);
- const Type t = new_type(env->gwion->p, t_fptr->xid, name, t_fptr);
+ const Type t = new_type(env->gwion->mp, t_fptr->xid, name, t_fptr);
t->owner = !(!env->class_def && GET_FLAG(stmt->base->td, global)) ?
env->curr : env->global_nspc;
- t->nspc = new_nspc(env->gwion->p, name);
+ t->nspc = new_nspc(env->gwion->mp, name);
t->flag = stmt->base->td->flag;
stmt->type = t;
nspc_add_type(t->owner, stmt->base->xid, t);
CHECK_OB(base)
CHECK_BB(scan0_defined(env, stmt->xid, td_pos(stmt->ext)))
if(!stmt->ext->types && (!stmt->ext->array || !stmt->ext->array->exp)) {
- const Type t = new_type(env->gwion->p, ++env->scope->type_xid, s_name(stmt->xid), base);
+ const Type t = new_type(env->gwion->mp, ++env->scope->type_xid, s_name(stmt->xid), base);
t->size = base->size;
const Nspc nspc = (!env->class_def && GET_FLAG(stmt->ext, global)) ?
env->global_nspc : env->curr;
SET_FLAG(t, empty);
} else {
const ae_flag flag = base->def ? base->def->flag : 0;
- const Class_Def cdef = new_class_def(env->gwion->p, flag, stmt->xid, stmt->ext, NULL,
- loc_cpy(env->gwion->p, td_pos(stmt->ext)));
+ const Class_Def cdef = new_class_def(env->gwion->mp, flag, stmt->xid, stmt->ext, NULL,
+ loc_cpy(env->gwion->mp, td_pos(stmt->ext)));
CHECK_BB(scan0_class_def(env, cdef))
stmt->type = cdef->base.type;
}
s_name(stmt->xid), v->type->name)
CHECK_BB(scan0_defined(env, stmt->xid, stmt_self(stmt)->pos))
}
- const Type t = type_copy(env->gwion->p, t_int);
+ const Type t = type_copy(env->gwion->mp, t_int);
t->xid = ++env->scope->type_xid;
t->name = stmt->xid ? s_name(stmt->xid) : "int";
t->parent = t_int;
ANN static Type union_type(const Env env, const Nspc nspc, const Symbol s, const m_bool add) {
const m_str name = s_name(s);
- const Type t = type_copy(env->gwion->p, t_union);
+ const Type t = type_copy(env->gwion->mp, t_union);
t->xid = ++env->scope->type_xid;
t->name = name;
- t->nspc = new_nspc(env->gwion->p, name);
+ t->nspc = new_nspc(env->gwion->mp, name);
t->nspc->parent = nspc;
t->owner = nspc;
if(add) {
env->curr : env->global_nspc;
const Type t = union_type(env, nspc, stmt->type_xid ?: stmt->xid,
!!stmt->type_xid);
- stmt->value = new_value(env->gwion->p, t, s_name(stmt->xid));
+ stmt->value = new_value(env->gwion->mp, t, s_name(stmt->xid));
stmt->value->owner_class = env->class_def;
stmt->value->owner = nspc;
nspc_add_value(nspc, stmt->xid, stmt->value);
const Nspc nspc = !GET_FLAG(stmt, global) ?
env->curr : env->global_nspc;
const Type t = union_type(env, nspc, insert_symbol("union"), 1);
- stmt->value = new_value(env->gwion->p, t, "union");
+ stmt->value = new_value(env->gwion->mp, t, "union");
stmt->value->owner_class = env->class_def;
stmt->value->owner = nspc;
nspc_add_value(nspc, stmt->xid, stmt->value);
}
ANN static Type scan0_class_def_init(const Env env, const Class_Def cdef) {
- const Type t = new_type(env->gwion->p, ++env->scope->type_xid, s_name(cdef->base.xid), t_object);
+ const Type t = new_type(env->gwion->mp, ++env->scope->type_xid, s_name(cdef->base.xid), t_object);
t->owner = env->curr;
- t->nspc = new_nspc(env->gwion->p, t->name);
+ t->nspc = new_nspc(env->gwion->mp, t->name);
t->nspc->parent = GET_FLAG(cdef, global) ? env_nspc(env) : env->curr;
t->def = cdef;
t->flag = cdef->flag;
}
t = array_type(env, decl->type, var->array->depth);
}
- const Value v = var->value = former ? former : new_value(env->gwion->p, t, s_name(var->xid));
+ const Value v = var->value = former ? former : new_value(env->gwion->mp, t, s_name(var->xid));
nspc_add_value(nspc, var->xid, v);
v->flag = decl->td->flag;
if(var->array && !var->array->exp)
ID_List list = stmt->list;
do {
CHECK_BB(already_defined(env, list->xid, stmt_self(stmt)->pos))
- const Value v = new_value(env->gwion->p, stmt->t, s_name(list->xid));
+ const Value v = new_value(env->gwion->mp, stmt->t, s_name(list->xid));
if(env->class_def) {
v->owner_class = env->class_def;
v->owner = env->curr;
Stmt_List next = l->next;
l->next = l->next->next;
next->next = NULL;
- free_stmt_list(env->gwion->p, next);
+ free_stmt_list(env->gwion->mp, next);
}
} else {
Stmt_List tmp = l->next;
l->next = NULL;
- free_stmt_list(env->gwion->p, tmp);
+ free_stmt_list(env->gwion->mp, tmp);
}
}
} while((l = l->next));
CHECK_BB(template_push_types(env, decl->base->tmpl->list.list, decl->td->types));
CHECK_BB(scan1_class_def(env, decl->type->def))
CHECK_BB(scan2_class_def(env, decl->type->def))
- nspc_pop_type(env->gwion->p, env->curr);
+ nspc_pop_type(env->gwion->mp, env->curr);
return GW_OK;
}
const Var_Decl var = list->var_decl;
if(var->array)
list->type = array_type(env, list->type, var->array->depth);
- var->value = arg_value(env->gwion->p, list);
+ var->value = arg_value(env->gwion->mp, list);
var->value->offset = f->stack_depth;
f->stack_depth += list->type->size;
} while((list = list->next));
}
ANN m_bool scan2_stmt_fptr(const Env env, const Stmt_Fptr ptr) {
- const Func_Def def = new_func_def(env->gwion->p, new_func_base(env->gwion->p, ptr->base->td, ptr->base->xid, ptr->base->args),
- NULL,ptr->base->td->flag, loc_cpy(env->gwion->p, stmt_self(ptr)->pos));
+ const Func_Def def = new_func_def(env->gwion->mp, new_func_base(env->gwion->mp, ptr->base->td, ptr->base->xid, ptr->base->args),
+ NULL,ptr->base->td->flag, loc_cpy(env->gwion->mp, stmt_self(ptr)->pos));
def->base->ret_type = ptr->base->ret_type;
- ptr->base->func = new_func(env->gwion->p, s_name(ptr->base->xid), def);
+ ptr->base->func = new_func(env->gwion->mp, s_name(ptr->base->xid), def);
ptr->value->d.func_ref = ptr->base->func;
ptr->base->func->value_ref = ptr->value;
ptr->type->d.func = ptr->base->func;
if(!label->ptr)
map_init(label);
if(!(m = (Map)map_get(label, (vtype)key))) {
- m = new_map(env->gwion->p);
+ m = new_map(env->gwion->mp);
map_set(label, (vtype)key, (vtype)m);
}
return m;
}
ANN static Func scan_new_func(const Env env, const Func_Def f, const m_str name) {
- const Func func = new_func(env->gwion->p, name, f);
+ const Func func = new_func(env->gwion->mp, name, f);
if(env->class_def) {
if(GET_FLAG(env->class_def, template))
SET_FLAG(func, ref);
}
ANN static Type func_type(const Env env, const Func func) {
- const Type t = type_copy(env->gwion->p, t_function);
+ const Type t = type_copy(env->gwion->mp, t_function);
t->name = func->name;
t->owner = env->curr;
if(GET_FLAG(func, member))
ANN2(1,2) static Value func_value(const Env env, const Func f,
const Value overload) {
const Type t = func_type(env, f);
- const Value v = new_value(env->gwion->p, t, t->name);
+ const Value v = new_value(env->gwion->mp, t, t->name);
CHECK_OO(scan2_func_assign(env, f->def, f, v))
if(!overload) {
ADD_REF(v);
const Value v = func_value(env, func, overload);
scan2_func_def_flag(env, f);
if(GET_FLAG(f, builtin))
- CHECK_BO(scan2_func_def_builtin(env->gwion->p, func, func->name))
+ CHECK_BO(scan2_func_def_builtin(env->gwion->mp, func, func->name))
if(GET_FLAG(func, member))
f->stack_depth += SZ_INT;
if(GET_FLAG(func->def, variadic))
}
ANEW ANN static Vector get_types(const Env env, Type t) {
- const Vector v = new_vector(env->gwion->p);
+ const Vector v = new_vector(env->gwion->mp);
do if(GET_FLAG(t, template))
vector_add(v, (vtype)t->def->tmpl->list.list);
while((t = owner_type(env, t)));
const Vector v = get_types(env, parent);
const ID_List base = (ID_List)vector_pop(v);
if(!base) {
- free_vector(env->gwion->p, v);
+ free_vector(env->gwion->mp, v);
return t->def->tmpl ? t->def->tmpl->list.list : NULL;
}
- const ID_List types = id_list_copy(env->gwion->p, base);
+ const ID_List types = id_list_copy(env->gwion->mp, base);
ID_List list, tmp = types;
for(m_uint i = vector_size(v) + 1; --i;) {
list = (ID_List)vector_pop(v);
- tmp = (tmp->next = id_list_copy(env->gwion->p, list));
+ tmp = (tmp->next = id_list_copy(env->gwion->mp, list));
}
tmp->next = t->def->tmpl->list.list;
- free_vector(env->gwion->p, v);
+ free_vector(env->gwion->mp, v);
return types;
}
ANN static Class_Def template_class(const Env env, const Class_Def def, const Type_List call) {
const Symbol name = template_id(env, def, call);
const Type t = nspc_lookup_type1(env->curr, name);
- return t ? t->def : new_class_def(env->gwion->p, def->flag, name, def->base.ext, def->body,
- loc_cpy(env->gwion->p, def->pos));
+ return t ? t->def : new_class_def(env->gwion->mp, def->flag, name, def->base.ext, def->body,
+ loc_cpy(env->gwion->mp, def->pos));
}
ANN m_bool template_push_types(const Env env, ID_List base, Type_List tl) {
Type_List call = tl;
- nspc_push_type(env->gwion->p, env->curr);
+ nspc_push_type(env->gwion->mp, env->curr);
do {
if(!call)
break;
if(GET_FLAG(t, builtin))
SET_FLAG(a->base.type, builtin);
CHECK_BO(scan1_class_def(env, a))
- nspc_pop_type(env->gwion->p, env->curr);
+ nspc_pop_type(env->gwion->mp, env->curr);
if(t->nspc->dtor) {
a->base.type->nspc->dtor = t->nspc->dtor;
SET_FLAG(a->base.type, dtor);
ADD_REF(t->nspc->dtor)
}
- a->tmpl = new_tmpl_class(env->gwion->p, get_total_type_list(env, t), 0);
+ a->tmpl = new_tmpl_class(env->gwion->mp, get_total_type_list(env, t), 0);
a->tmpl->base = type->types;
nspc_add_type(t->owner, insert_symbol(a->base.type->name), a->base.type);
return a->base.type;
struct Plug_ *plug = (struct Plug_*)vector_at(&v[GWPLUG_MODULE], i);
if(plug->end)
plug->end(gwion, plug->self);
- mp_free(gwion->p, Plug, plug);
+ mp_free(gwion->mp, Plug, plug);
}
for(m_uint i = 0; i < vector_size(&v[GWPLUG_DL]); ++i)
DLCLOSE((void*)vector_at(&v[GWPLUG_DL], i));
for(m_uint i = 0; i < GWPLUG_LAST; ++i)
vector_release(&v[i]);
map_release(&p->drv);
- mp_free(gwion->p, PlugInfo, p);
+ mp_free(gwion->mp, PlugInfo, p);
}
ANN Vector split_args(MemPool p, const m_str str) {
const Vector v = &gwion->plug->vec[GWPLUG_MODULE];
for(m_uint i = 0; i < vector_size(v); ++i) {
struct Plug_ *plug = (struct Plug_*)vector_at(v, i);
- const Vector arg = get_arg(gwion->p, plug->name, args);
+ const Vector arg = get_arg(gwion->mp, plug->name, args);
plug->self = plug->ini(gwion, arg);
if(arg) {
for(m_uint i = 0; i < vector_size(arg); ++i)
xfree((m_str)vector_at(arg, i));
- free_vector(gwion->p, arg);
+ free_vector(gwion->mp, arg);
}
}
}
\ No newline at end of file
xfree(d->in);
if(d->out)
xfree(d->out);
- mp_free(vm->gwion->p, SoundInfo, d->si);
+ mp_free(vm->gwion->mp, SoundInfo, d->si);
if(d->driver->del)
d->driver->del(vm, d);
- mp_free(vm->gwion->p, DriverData, d->driver);
- mp_free(vm->gwion->p, BBQ, d);
+ mp_free(vm->gwion->mp, DriverData, d->driver);
+ mp_free(vm->gwion->mp, BBQ, d);
}
ANN void driver_alloc(Driver *d) {
if(vm->bbq)
free_driver(vm->bbq, vm);
MUTEX_CLEANUP(vm->shreduler->mutex);
- mp_free(vm->gwion->p, Shreduler, vm->shreduler);
- mp_free(vm->gwion->p, VM, vm);
+ mp_free(vm->gwion->mp, Shreduler, vm->shreduler);
+ mp_free(vm->gwion->mp, VM, vm);
}
ANN void vm_add_shred(const VM* vm, const VM_Shred shred) {
array_base = NULL;
goto regpush;
newobj:
- *(M_Object*)reg = new_object(vm->gwion->p, shred, (Type)instr->m_val2);
+ *(M_Object*)reg = new_object(vm->gwion->mp, shred, (Type)instr->m_val2);
reg += SZ_INT;
DISPATCH()
addref:
reg += SZ_INT;
DISPATCH()
pushstr:
- *(M_Object*)reg = new_string2(vm->gwion->p, shred, (m_str)instr->m_val);
+ *(M_Object*)reg = new_string2(vm->gwion->mp, shred, (m_str)instr->m_val);
reg += SZ_INT;
DISPATCH();
gcini:
map_get(&gwion->freearg, (vtype)instr->execute));
if(f)
f(instr, gwion);
- mp_free(gwion->p, Instr, instr);
+ mp_free(gwion->mp, Instr, instr);
}
-// free_vector(gwion->p, v);
+// free_vector(gwion->mp, v);
}
ANN static void _free_code_instr(const Vector v, const Gwion gwion) {
free_code_instr(v, gwion);
- free_vector(gwion->p, v);
+ free_vector(gwion->mp, v);
}
ANN static void free_vm_code(VM_Code a, Gwion gwion) {
if(a->memoize)
- memoize_end(gwion->p, a->memoize);
+ memoize_end(gwion->mp, a->memoize);
if(!GET_FLAG(a, builtin))
_free_code_instr(a->instr, gwion);
xfree(a->name);
- mp_free(gwion->p , VM_Code, a);
+ mp_free(gwion->mp , VM_Code, a);
}
VM_Code new_vm_code(MemPool p, const Vector instr, const m_uint stack_depth,