f_bbqset func;
f_bbqrun run;
struct DriverData_ *driver;
- volatile bool is_running;
+ bool is_running;
} Driver;
#define DRVINI(a) ANN m_bool a(struct VM_ *vm NUSED, Driver *di NUSED)
typedef struct Memoize_ *Memoize;
Memoize memoize_ini(const Emitter, const Func);
-void memoize_end(MemPool, Memoize);
+void memoize_end(MemPool, const Memoize);
INSTR(MemoizeIni);
INSTR(MemoizeStore);
#endif
c->name = strsep(&d, ":");
if (d) vector_init(&c->args);
while (d) vector_add(&c->args, (vtype)strdup(strsep(&d, ":")));
- free(d);
+ xfree(d);
}
ANN static inline void compiler_error(struct Compiler *const c) {
};
Memoize memoize_ini(const Emitter emit, const Func f) {
- Memoize m = mp_calloc(emit->gwion->mp, Memoize);
+ const Memoize m = mp_calloc(emit->gwion->mp, Memoize);
vector_init(&m->v);
m->ret_sz = f->def->base->ret_type->size;
m->arg_sz = f->def->stack_depth;
return m;
}
-void memoize_end(MemPool p, Memoize m) {
+void memoize_end(MemPool p, const Memoize m) {
for (m_uint i = 0; i < vector_size(&m->v); ++i)
mp_free2(p, m->arg_sz + m->arg_sz, (void *)vector_at(&m->v, i));
vector_release(&m->v);
mp_free(p, Memoize, m);
}
-ANN static inline m_bit *get_data(MemPool mp, Memoize m) {
+ANN static inline m_bit *get_data(MemPool mp, const Memoize m) {
if (vector_size(&m->v) >= m->limit)
return (m_bit *)vector_at(&m->v, m->curr++ % m->limit);
m_bit *data = mp_calloc2(mp, m->arg_sz + m->ret_sz);
INSTR(MemoizeStore) {
const Memoize m = shred->code->memoize;
- m_bit * data = get_data(shred->info->mp, m);
+ m_bit *const data = get_data(shred->info->mp, m);
memcpy(data, shred->mem, m->arg_sz);
memcpy(data + m->arg_sz, shred->reg - m->ret_sz, m->ret_sz);
}
if (di->si->arg) driver_ini(gwion);
di->func(di->driver);
CHECK_BB(di->driver->ini(gwion->vm, di));
- ;
driver_alloc(di);
return GW_OK;
}
-ANN static inline m_bool gwion_engine(const Gwion gwion) {
- return type_engine_init(gwion) > 0;
-}
-
-ANN static void gwion_cleaner(const Gwion gwion) {
+ANN static VM_Shred gwion_cleaner(const Gwion gwion) {
const VM_Code code =
new_vmcode(gwion->mp, NULL, NULL, "in code dtor", 0, true, false);
- gwion->vm->cleaner_shred = new_vm_shred(gwion->mp, code);
- vm_ini_shred(gwion->vm, gwion->vm->cleaner_shred);
+ const VM_Shred shred = new_vm_shred(gwion->mp, code);
+ vm_ini_shred(gwion->vm, shred);
+ return shred;
}
ANN VM *gwion_cpy(const VM *src) {
shreduler_set_loop(gwion->vm->shreduler, arg->loop);
if (gwion_audio(gwion) > 0) {
plug_run(gwion, &arg->mod);
- if (gwion_engine(gwion)) {
- gwion_cleaner(gwion);
+ if (type_engine_init(gwion)) {
+ gwion->vm->cleaner_shred = gwion_cleaner(gwion);
(void)arg_compile(gwion, arg);
return GW_OK;
}
Type owner = env->class_def;
do {
Type parent = t;
- while (parent) {
+ do {
if (parent == owner)
ERR_B(td->pos, _("%s declared inside %s"), t->name, owner->name);
- parent = parent->info->parent;
- }
+ } while ((parent = parent->info->parent));
} while ((owner = owner->info->value->from->owner_class));
return GW_OK;
}
ERR_O(exp_self(decl)->pos, _("can't use private type %s"), t->name)
if (GET_FLAG(t, protect) && (!env->class_def || isa(t, env->class_def) < 0))
ERR_O(exp_self(decl)->pos, _("can't use protected type %s"), t->name)
- return decl->type = t;
+ return t;
}
static inline m_bool scan1_defined(const Env env, const Var_Decl var) {
return GW_OK;
}
-static inline uint array_ref(const Array_Sub array) {
+static inline bool array_ref(const Array_Sub array) {
return array && !array->exp;
}
ANN static m_bool scan1_decl(const Env env, const Exp_Decl *decl) {
Var_Decl_List list = decl->list;
- const uint decl_ref = array_ref(decl->td->array);
+ const bool decl_ref = array_ref(decl->td->array);
do {
const Var_Decl var = list->self;
CHECK_BB(isres(env, var->xid, exp_self(decl)->pos));
}
ANN static m_bool scan1_exp_post(const Env env, const Exp_Postfix *post) {
- if (opiscall(post->op)) {
+ if (opiscall(post->op))
return exp2call(env, exp_self(post), post->op, post->exp);
- }
CHECK_BB(scan1_exp(env, post->exp));
const m_str access = exp_access(post->exp);
if (!access) return GW_OK;
const Exp_Unary * unary) {
if (unary->unary_type == unary_code) {
RET_NSPC(scan1_stmt(env, unary->code))
- } else if (opiscall(unary->op)) {
+ } else if (opiscall(unary->op))
return exp2call(env, exp_self(unary), unary->op, unary->exp);
- }
return unary->unary_type == unary_exp ? scan1_exp(env, unary->exp) : GW_OK;
}
ANN static m_bool _scan1_func_def(const Env env, const Func_Def fdef) {
if(GET_FLAG(fdef->base, abstract) && !env->class_def)
ERR_B(fdef->base->pos, "file scope function can't be abstract");
-//exit(12);
const bool global = GET_FLAG(fdef->base, global);
const m_uint scope = !global ? env->scope->depth : env_push_global(env);
if (fdef->base->td)
ANN static Type scan1_get_parent(const Env env, const Type_Def tdef) {
const Type parent = known_type(env, tdef->ext);
CHECK_OO((tdef->type->info->parent = parent));
- ;
Type t = parent;
do
if (tdef->type == t)
Driver *di = (Driver *)mp_calloc(p, BBQ);
di->func = dummy_driver;
di->driver = (DriverData *)mp_calloc(p, DriverData);
- di->is_running = 1;
+ di->is_running = true;
return di;
}