#ifndef __GACK
#define __GACK
-ANN void gack(const m_bit*, const Instr);
+ANN void gack(const Gwion, const m_bit*, const Instr);
#endif
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))
#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;
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);
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));
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;
}
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*);
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)) ||
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) {
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;
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;
_release(a.obj, shred);
DISPATCH()
gack:
- gack(reg, (Instr)VAL);
+ gack(vm->gwion, reg, (Instr)VAL);
DISPATCH()
other:
shred->code = code;