From: fennecdjay Date: Tue, 24 Sep 2019 20:47:17 +0000 (+0200) Subject: :art: prepare gack X-Git-Tag: nightly~2199^2~20 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=f8f6494a6f52d5068c440fa3758010318d83d4a1;p=gwion.git :art: prepare gack --- diff --git a/include/gack.h b/include/gack.h index 54fc7fcb..bafbba27 100644 --- a/include/gack.h +++ b/include/gack.h @@ -1,4 +1,4 @@ #ifndef __GACK #define __GACK -ANN void gack(const m_bit*, const Instr); +ANN void gack(const Gwion, const m_bit*, const Instr); #endif diff --git a/src/lib/engine.c b/src/lib/engine.c index 824f6114..9780f1ad 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -44,7 +44,7 @@ ANN static m_bool import_core_libs(const Gwi gwi) { GWI_OB((t_auto = gwi_mk_type(gwi, "auto", SZ_INT, NULL))) // size = SZ_INT to enable declarations GWI_BB(gwi_add_type(gwi, t_auto)) SET_FLAG(t_class, abstract); - GWI_OB((t_void = gwi_mk_type(gwi, "void", 0, NULL))) + const Type t_void = gwi_mk_type(gwi, "void", 0, NULL); GWI_BB(gwi_set_global_type(gwi, t_void, et_void)) GWI_OB((t_null = gwi_mk_type(gwi, "@null", SZ_INT, NULL))) GWI_BB(gwi_add_type(gwi, t_null)) diff --git a/src/lib/gack.c b/src/lib/gack.c index 3749a3db..174be2fc 100644 --- a/src/lib/gack.c +++ b/src/lib/gack.c @@ -10,6 +10,8 @@ #include "func.h" #include "object.h" #include "instr.h" +#include "gwion.h" +#include "gack.h" static void print_type(const Type type) { const m_bool is_func = isa(type, t_function) > 0 && isa(type, t_fptr) < 0; @@ -104,7 +106,7 @@ ANN static void print_prim(const Type type, const m_bit* stack) { print_float(*(m_float*)stack); } -ANN void gack(const m_bit* reg, const Instr instr) { +ANN void gack(const Gwion gwion, const m_bit* reg, const Instr instr) { m_uint offset = instr->m_val; const Vector v = (Vector)instr->m_val2; const m_uint size = vector_size(v); @@ -120,7 +122,7 @@ ANN void gack(const m_bit* reg, const Instr instr) { print_type(type); else if(isa(type, t_class) > 0) print_type(type->e->d.base_type); - else if(isa(type, t_void) > 0) + else if(isa(type, gwion->type[et_void]) > 0) print_string1("void"); else print_prim(type, (reg-offset)); diff --git a/src/oo/type.c b/src/oo/type.c index 418d0fb4..be611145 100644 --- a/src/oo/type.c +++ b/src/oo/type.c @@ -197,6 +197,6 @@ ANN m_uint get_depth(const Type type) { return depth; } -Type t_void, t_int, t_bool, t_float, t_dur, t_time, t_now, t_complex, t_polar, t_vec3, t_vec4, +Type t_int, t_bool, t_float, t_dur, t_time, t_now, t_complex, t_polar, t_vec3, t_vec4, t_null, t_object, t_shred, t_fork, t_event, t_ugen, t_string, t_ptr, t_array, t_gack, t_function, t_fptr, t_varloop, t_vararg, t_lambda, t_class, t_union, t_undefined, t_auto, t_tuple; diff --git a/src/parse/check.c b/src/parse/check.c index b8cca619..18b3343d 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -340,7 +340,7 @@ ANN static Type prim_##name(const Env env NUSED, const Exp_Primary * primary NUS } describe_prim_xxx(num, t_int) describe_prim_xxx(float, t_float) -describe_prim_xxx(nil, t_void) +describe_prim_xxx(nil, env->gwion->type[et_void]) describe_prim_xxx(unpack, t_tuple) typedef Type (*_type_func)(const Env, const void*); @@ -491,7 +491,7 @@ ANN2(1,2) static Func find_func_match_actual(const Env env, Func func, const Exp ANN2(1, 2) static Func find_func_match(const Env env, const Func up, const Exp exp) { Func func; - const Exp args = (exp && isa(exp->type, t_void) < 0) ? exp : NULL; + const Exp args = (exp && isa(exp->type, env->gwion->type[et_void]) < 0) ? exp : NULL; if((func = find_func_match_actual(env, up, args, 0, 1)) || (func = find_func_match_actual(env, up, args, 1, 1)) || (func = find_func_match_actual(env, up, args, 0, 0)) || @@ -769,7 +769,7 @@ ANN static Type check_lambda_call(const Env env, const Exp_Call *exp) { if(env->class_def) SET_FLAG(l->def, member); ((Exp_Call*)exp)->m_func = l->def->base->func; - return l->def->base->ret_type ?: (l->def->base->ret_type = t_void); + return l->def->base->ret_type ?: (l->def->base->ret_type = env->gwion->type[et_void]); } ANN Type check_exp_call1(const Env env, const Exp_Call *exp) { @@ -1074,7 +1074,7 @@ stmt_func_xxx(auto, Stmt_Auto,, do_stmt_auto(env, stmt)) ANN static m_bool check_stmt_return(const Env env, const Stmt_Exp stmt) { if(!env->func) ERR_B(stmt_self(stmt)->pos, _("'return' statement found outside function definition")) - DECL_OB(const Type, ret_type, = stmt->val ? check_exp(env, stmt->val) : t_void) + DECL_OB(const Type, ret_type, = stmt->val ? check_exp(env, stmt->val) : env->gwion->type[et_void]) if(!env->func->def->base->ret_type) { assert(isa(env->func->value_ref->type, t_lambda) > 0); env->func->def->base->ret_type = ret_type; diff --git a/src/parse/type_decl.c b/src/parse/type_decl.c index 21675e7a..e0106766 100644 --- a/src/parse/type_decl.c +++ b/src/parse/type_decl.c @@ -38,7 +38,7 @@ ANN Type type_decl_resolve(const Env env, const Type_Decl* td) { DECL_OO(const Type, t, = scan_type(env, base, td)) const Type ret = !td->array ? t : array_type(env, t, td->array->depth); if(GET_FLAG(td, nonnull)) { - if(isa(ret, t_void) > 0) + if(isa(ret, env->gwion->type[et_void]) > 0) ERR_O(td_pos(td), _("void types can't be nonnull.")) if(isa(ret, t_object) < 0 && isa(ret, t_function) < 0) return ret; diff --git a/src/vm/vm.c b/src/vm/vm.c index 0ef90a00..4c127ff0 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -821,7 +821,7 @@ gcend: _release(a.obj, shred); DISPATCH() gack: - gack(reg, (Instr)VAL); + gack(vm->gwion, reg, (Instr)VAL); DISPATCH() other: shred->code = code;