-Subproject commit f8ed98c97d7b938bb3d116e9428e9b52a3e76450
+Subproject commit 1292b905b96915cdce6627bcfce3490f415c37fa
ANN m_uint emit_local_exp(const Emitter emit, Exp*);
ANN bool emit_exp_spork(const Emitter, const Exp_Unary *);
-ANN void emit_object_addref(const Emitter emit, const m_int size,
+ANN void emit_object_addref(const Emitter emit, const m_uint size,
const bool emit_var);
-ANN void emit_struct_addref(const Emitter emit, const Type t, const m_int size,
+ANN void emit_struct_addref(const Emitter emit, const Type t, const m_uint size,
const bool emit_var);
ANN static inline void emit_compound_addref(const Emitter emit, const Type t,
- const m_int size,
+ const m_uint size,
const bool emit_var) {
return !tflag(t, tflag_struct) ? emit_object_addref(emit, size, emit_var)
: emit_struct_addref(emit, t, size, emit_var);
es->_ctx = es->env->context;
es->_filename = es->env->name;
CHECK_B(envset_push(es, v->from->owner_class, v->from->owner));
- return GW_OK;
+ return true;
}
ANN2(1) void envset_pop(struct EnvSet *, const Type);
#endif
ANN2(1, 2) ANEW Type new_type(MemPool, const m_str name, const Type);
ANEW ANN Type type_copy(MemPool, const Type type);
ANN Value find_value(const Type, const Symbol);
-ANN m_bool isa(const Type, const Type) __attribute__((pure));
+ANN bool isa(const Type, const Type) __attribute__((pure));
ANN bool not_reserved(const Env, const Tag); // move me
ANN Type array_type(const Env, const Type, const m_uint, const loc_t);
ANN Type find_common_anc(const Type, const Type) __attribute__((pure));
#define OP_CHECK(a) ANN Type a(const Env env NUSED, void *data NUSED)
#define OP_EMIT(a) ANN bool a(const Emitter emit NUSED, void *data NUSED)
#ifdef GWION_BUILTIN
-#define GWI_BB(a) \
+#define GWI_B(a) \
{ \
gwi_set_loc(gwi, __FILE__, __LINE__); \
(void)(a); \
gwi_set_loc(gwi, __FILE__, __LINE__); \
(void)(a); \
}
-#define GWI_OB(a) \
+#define GWI_B(a) \
{ \
gwi_set_loc(gwi, __FILE__, __LINE__); \
(void)(a); \
}
#define GWION_IMPORT(a) ANN bool gwimport_##a(const Gwi gwi)
#else
-#define GWI_BB(a) \
- { \
- gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); \
- CHECK_B(a); \
- }
#define GWI_B(a) \
{ \
gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); \
CHECK_B(a); \
}
-#define GWI_OB(a) \
- { \
- gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); \
- CHECK_B(a); \
- }
+
#define GWION_IMPORT(a) ANN bool gwimport_##a(const Gwi gwi)
#endif
#define ALLOC_PTR(p, a, b, c) \
ANN
static inline M_Object new_object_str(const Gwion gwion, const m_str str) {
loc_t loc = {};
- DECL_OO(const Type, t, = str2type(gwion, str, loc));
+ DECL_O(const Type, t, = str2type(gwion, str, loc));
return new_object(gwion->mp, t);
}
#define __IMPORT_ENUM
__attribute__ ((visibility ("default")))
-ANN m_int gwi_enum_ini(const Gwi gwi, const m_str type);
-ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint value);
-ANN Type gwi_enum_end(const Gwi gwi);
-ANN void ck_clean_edef(MemPool, ImportCK *);
+ANN bool gwi_enum_ini(const Gwi gwi, const m_str type);
+ANN bool gwi_enum_add(const Gwi gwi, const m_str name, const m_uint value);
+ANN bool gwi_enum_end(const Gwi gwi);
+
+ANN void ck_clean_edef(MemPool, ImportCK *);
#endif
#define GWI_ERR_B(a, ...) \
{ \
GWI_ERR((a), ##__VA_ARGS__); \
- return GW_ERROR; \
+ return false; \
}
#define GWI_ERR_O(a, ...) \
{ \
#define ENV_ERR_B(pos, a, ...) \
{ \
env_err(env, pos, (a), ##__VA_ARGS__); \
- return GW_ERROR; \
+ return false; \
}
#define ENV_ERR_O(pos, a, ...) \
{ \
#ifndef __IMPORT_ITEM
#define __IMPORT_ITEM
-ANN m_int gwi_item_ini(const Gwi gwi, const m_str type, const m_str name);
-ANN2(1) m_int gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data);
+ANN bool gwi_item_ini(const Gwi gwi, const m_str type, const m_str name);
+ANN2(1) bool gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data);
#define gwi_item_end(a, b, member, c) \
gwi_item_end(a, (ae_flag)(b), (union value_data) {.member = c})
ANN void ck_clean_item(MemPool, ImportCK *);
(node)-> poison = true; \
} while(false)
-#undef ERR_b
-#define ERR_b(a, b, ...) \
- do { \
- env_err(env, (a), (b), ##__VA_ARGS__); \
- return false; \
- } while(false)
-
-
-#define ERR_OK_NODE(ok, a, b, c, ...) \
+#define ERR_OK_NODE(ok, a, b, c, ...) \
do { \
env_err(env, (b), (c), ##__VA_ARGS__); \
POISON_NODE(ok, env, a); \
} while(false)
-#define ERR_OK(ok, a, b, ...) \
+#define ERR_OK(ok, a, b, ...) \
do { \
env_err(env, (a), (b), ##__VA_ARGS__); \
POISON(ok, env); \
} while(false)
-#undef ERR_B
#define ERR_B(a, b, ...) \
do { \
env_err(env, (a), (b), ##__VA_ARGS__); \
- return GW_ERROR; \
+ return false; \
} while(false)
-#undef ERR_O
#define ERR_O(a, b, ...) \
do { \
env_err(env, (a), (b), ##__VA_ARGS__); \
ANN static inline bool not_upvalue(const Env env, const Value v) {
if (unlikely(is_class(env->gwion, v->type))) return true;
return GET_FLAG(v, global) || vflag(v, vflag_fglobal) ||
- (v->from->owner_class && isa(v->from->owner_class, env->class_def) > 0) ||
+ (v->from->owner_class && isa(v->from->owner_class, env->class_def)) ||
nspc_lookup_value1(env->curr, insert_symbol(v->name));
}
ANN static inline bool func_match_inner(const Env env, Exp* e,
const Type t, const bool implicit,
const bool specific) {
- if (specific ? e->type == t : isa(e->type, t) > 0) // match
+ if (specific ? e->type == t : isa(e->type, t)) // match
return true;
return !implicit ? false : check_implicit(env, e, t);
}
-Subproject commit 82b13e3b9c04c292342461b481289f68d428e04e
+Subproject commit 402bf847df73f3bec3f3802984726e5d3b766557
}
plugin() {
has_func "gwimport" "$1" "$2" && {
- header "extern m_bool gwimport_${2}(const Gwi);"
+ header "extern bool gwimport_${2}(const Gwi);"
echo " plug->plugin = gwimport_${2};"
}
}
for(uint32_t i = 0; i < mp_vector_len(c->values); i++) {
const Value v = *mp_vector_at(c->values, Value, i);
set_vflag(v, vflag_builtin);
- if(isa(v->type, gwion->type[et_class]) > 0) {
+ if(isa(v->type, gwion->type[et_class])) {
const Type t = (Type)v->d.ptr;
type_addref(t);
mk_class(gwion->env, t, (loc_t) {});
gwion->emit->info->code = NULL;
return c->shred->tick->xid;
}
- return GW_OK;
+ return true;
}
ANN static m_uint compile(struct Gwion_ *gwion, struct Compiler *c) {
ANN static m_int _frame_pop(const Emitter emit) {
Frame *frame = emit->code->frame;
- DECL_OB(const Local *, l, = (Local *)vector_pop(&frame->stack));
+ const Local *l = (Local *)vector_pop(&frame->stack);
+ if(!l)return -1;
frame->curr_offset -= l->type->size;
if (l->skip) return _frame_pop(emit);
if (!l->is_compound) return _frame_pop(emit);
is_ref));
return true;
} else if (!is_ref) {
- if(!tflag(type, tflag_typedef) || isa(type, emit->gwion->type[et_closure]) > 0) {
+ if(!tflag(type, tflag_typedef) || isa(type, emit->gwion->type[et_closure])) {
const Instr instr = emit_add_instr(emit, ObjectInstantiate);
instr->m_val2 = (m_uint)type;
} // maybe we should instantiate the first actual type
emit_dotstatic(emit, (m_uint)&v->d.ptr, size, emit_addr);
// prevent invalid access to global variables
if(!emit_addr &&
- isa(v->type, emit->gwion->type[et_object]) > 0)
+ isa(v->type, emit->gwion->type[et_object]))
emit_fast_except(emit, v->from, prim_pos(data));
} else {
const m_uint size = v->type->size;
else
emit_regpushbase(emit, v->from->offset, size, exp_getvar(prim_exp(data)));
if (GET_FLAG(v, late) && !exp_getvar(prim_exp(data)) &&
- isa(v->type, emit->gwion->type[et_object]) > 0)
+ isa(v->type, emit->gwion->type[et_object]))
emit_fast_except(emit, v->from, prim_pos(data));
return true;
}
return type->size;
}
-ANN void emit_object_addref(const Emitter emit, const m_int size,
+ANN void emit_object_addref(const Emitter emit, const m_uint size,
const bool emit_var) {
const f_instr exec = !emit_var ? RegAddRef : RegAddRefAddr;
const Instr instr = emit_add_instr(emit, exec);
instr->m_val = size;
}
-ANN void emit_struct_addref(const Emitter emit, const Type t, const m_int size,
+ANN void emit_struct_addref(const Emitter emit, const Type t, const m_uint size,
const bool emit_var) {
if(!tflag(t, tflag_release)) return;
const Instr instr =
emit_add_instr(emit, !emit_var ? StructRegAddRef : StructRegAddRefAddr);
instr->m_val2 = (m_uint)t;
- instr->m_val = !emit_var ? size : (m_int)-SZ_INT;
+ instr->m_val = !emit_var ? (m_int)size : (m_int)-SZ_INT;
}
ANN2(1)
-static void emit_exp_addref1(const Emitter emit, Exp* exp, m_int size) {
+static void emit_exp_addref1(const Emitter emit, Exp* exp, m_uint size) {
const Type t = exp->cast_to ?: exp->type;
if (tflag(t, tflag_compound))
emit_compound_addref(emit, exp->type, size, exp_getvar(exp));
/*ANN2(1)
static void emit_exp_addref(const Emitter emit, Exp* exp,
- m_int size) {
+ m_uint size) {
do {
emit_exp_addref1(emit, exp, size);
size += exp_size(exp);
if (e->exp_type == ae_exp_cast ||
(e->exp_type == ae_exp_primary && e->d.prim.prim_type == ae_prim_str))
return;
- const bool isobj = isa(e->type, emit->gwion->type[et_object]) > 0;
+ const bool isobj = isa(e->type, emit->gwion->type[et_object]);
if (isobj && (tflag(e->type, tflag_ref) || !GET_FLAG(e->type, final)))
emit_add_instr(emit, GackType);
}
const bool is_ref,
const bool emit_addr) {
const Value v = var_decl->value;
- if (isa(v->type, emit->gwion->type[et_object]) > 0 && !is_ref)
+ if (isa(v->type, emit->gwion->type[et_object]) && !is_ref)
CHECK_B(decl_static(emit, decl, var_decl, 0));
CHECK_B(emit_dot_static_data(emit, v, !struct_ctor(v) ? emit_addr : 1));
if (tflag(v->type, tflag_struct)) CHECK_B(struct_finish(emit, decl));
- if (isa(v->type, emit->gwion->type[et_object]) > 0 && !is_ref) {
+ if (isa(v->type, emit->gwion->type[et_object]) && !is_ref) {
if(safe_tflag(emit->env->class_def, tflag_struct) && GET_FLAG(emit->env->class_def, global))
emit_object_addref(emit, 0, emit_addr);
}
const uint emit_var) {
const Value v = var_decl->value;
const Type type = v->type;
- const bool is_obj = isa(type, emit->gwion->type[et_object]) > 0;
+ const bool is_obj = isa(type, emit->gwion->type[et_object]);
const bool emit_addr = (!is_obj || is_ref) ? emit_var : true;
if (is_obj && !is_ref && !exp_self(decl)->ref) {
if(!decl->args) CHECK_B(emit_instantiate_decl(emit, type, decl->var.td, is_ref));
const uint is_ref, const bool emit_var) {
const Value v = var_decl->value;
const Type type = v->type;
- const bool is_obj = isa(type, emit->gwion->type[et_object]) > 0;
+ const bool is_obj = isa(type, emit->gwion->type[et_object]);
const bool emit_addr = (!is_obj || is_ref) ? emit_var : true;
if (is_obj && !is_ref) {
if(!decl->args) CHECK_B(emit_instantiate_decl(emit, type, decl->var.td, is_ref));
}
return false;
}
- if(isa(v->type, emit->gwion->type[et_object]) > 0 && GET_FLAG(v, late) && exp_getuse(exp_self(decl)))
+ if(isa(v->type, emit->gwion->type[et_object]) && GET_FLAG(v, late) && exp_getuse(exp_self(decl)))
emit_add_instr(emit, GWOP_EXCEPT);
return true;
}
!global ? emit->env->scope->depth : emit_push_global(emit);
const bool ret = emit_decl(emit, decl);
if (global) emit_pop(emit, scope);
- if(emit->status.in_return && GET_FLAG(decl->var.vd.value, late) && isa(t, emit->gwion->type[et_object]) > 0)
+ if(emit->status.in_return && GET_FLAG(decl->var.vd.value, late) && isa(t, emit->gwion->type[et_object]))
emit_add_instr(emit, GWOP_EXCEPT);
return ret;
}
else //if(is_new(f->def))//if(tflag(f->value_ref->type, tflag_ftmpl))
{
const Type t = f->value_ref->from->owner_class;
-if(t && (!emit->env->curr || isa(t, emit->env->class_def) < 0))
+if(t && (!emit->env->curr || !isa(t, emit->env->class_def)))
//!is_new(f->def) || f->value_ref->from->owner_class->array_depth)
//if(f->value_ref->from->owner_class->array_depth)
CHECK_B(emit_ensure_func(emit, f));
Instr instr;
struct M_Vector_ v = {};
const m_uint reg = emit_local(emit, emit->gwion->type[et_bool]);
- DECL_OB(const Instr, op, = _flow(emit, exp_if->cond, &instr, true));
+ DECL_B(const Instr, op, = _flow(emit, exp_if->cond, &instr, true));
if (exp_getvar(exp_self(exp_if))) {
exp_setvar(e, 1);
exp_setvar(exp_if->else_exp, 1);
}
CHECK_B(emit_exp_func[exp->exp_type](emit, &exp->d));
if (exp->cast_to) CHECK_B(emit_implicit_cast(emit, exp, exp->cast_to));
- if (isa(e->type, emit->gwion->type[et_object]) > 0 &&
- (e->cast_to ? isa(e->cast_to, emit->gwion->type[et_object]) > 0 : 1) &&
+ if (isa(e->type, emit->gwion->type[et_object]) &&
+ (e->cast_to ? isa(e->cast_to, emit->gwion->type[et_object]) : 1) &&
e->exp_type == ae_exp_decl && GET_FLAG(e->d.exp_decl.var.td, late) &&
exp_getuse(e) && !exp_getvar(e) &&
GET_FLAG(e->d.exp_decl.var.vd.value, late))
if (stmt->cond->exp_type == ae_exp_primary &&
stmt->cond->d.prim.prim_type == ae_prim_num)
return emit_if_const(emit, stmt);
- DECL_OB(const Instr, op, = emit_flow(emit, stmt->cond));
+ DECL_B(const Instr, op, = emit_flow(emit, stmt->cond));
CHECK_B(scoped_stmt(emit, stmt->if_body));
const Instr op2 = emit_add_instr(emit, Goto);
op->m_val = emit_code_size(emit);
}
ANN static inline bool emit_jump_index(const Emitter emit, const Vector v,
- const m_int n) {
+ const m_uint n) {
vector_add(v, 0); // make room
const m_uint sz = vector_size(v);
- m_int idx = 1;
+ m_uint idx = 1;
for (m_uint i = sz; --i > 1;) {
if (!vector_at(v, i) && ++idx == n) {
m_uint *data = v->ptr + OFFSET + i;
m_uint *action_index) {
CHECK_B(emit_stmt(emit, stmt->c1));
const m_uint index = emit_code_size(emit);
- DECL_OB(const Instr, op, = emit_flow(emit, stmt->c2->d.stmt_exp.val));
+ DECL_B(const Instr, op, = emit_flow(emit, stmt->c2->d.stmt_exp.val));
CHECK_B(scoped_stmt(emit, stmt->body));
*action_index = emit_code_size(emit);
if (stmt->c3) {
ANN static inline bool roll(const Emitter emit, Looper*const loop) {
const Instr instr = loop->roll(emit, loop);
-// DECL_OB(const Instr, instr, = each_op(emit, loop)); // maybe check in check.c
+// DECL_B(const Instr, instr, = each_op(emit, loop)); // maybe check in check.c
CHECK_B(scoped_stmt(emit, loop->stmt));
instr->m_val = emit_code_size(emit) + 1; // pass after goto
return true;
ANN bool env_access(const Env env, const ae_flag flag, const loc_t loc) {
if (env->scope->depth) {
if (GET(flag, ae_flag_global))
- ERR_b(loc, _("`{G}global{0}` can only be used at %s scope."),
+ ERR_B(loc, _("`{G}global{0}` can only be used at %s scope."),
GET(flag, ae_flag_global) && !env->class_def ? "file" : "class");
}
if ((GET(flag, ae_flag_static) || GET(flag, ae_flag_private) ||
GET(flag, ae_flag_protect)) &&
(!env->class_def || env->scope->depth))
- ERR_b(loc, _("`{G}static/private/protect{0}` can only be used at class scope."));
+ ERR_B(loc, _("`{G}static/private/protect{0}` can only be used at class scope."));
return true;
}
ANN bool env_storage(const Env env, ae_flag flag, const loc_t loc) {
CHECK_B(env_access(env, flag, loc));
if(env->class_def && GET(flag, ae_flag_global))
- ERR_b(loc, _("`{G}global{0}` at class scope only valid for function pointers"));
+ ERR_B(loc, _("`{G}global{0}` at class scope only valid for function pointers"));
return true;
}
#undef GET
#undef RETURN_TYPE
ANN Type find_type(const Env env, Type_Decl *td) {
- DECL_OO(Type, type, = find_initial(env, td->tag.sym));
+ DECL_O(Type, type, = find_initial(env, td->tag.sym));
while ((td = td->next) && type && type->nspc) {
const Nspc nspc = type->nspc;
if(!(type = find_in_parent(type, td->tag.sym)))
const Map map = &env->gwion->data->id;
for (m_uint i = 0; i < map_size(map); i++) {
if (tag.sym == (Symbol)VKEY(map, i))
- ERR_b(tag.loc, _("%s is reserved."), s_name(tag.sym));
+ ERR_B(tag.loc, _("%s is reserved."), s_name(tag.sym));
}
return true;
}
es->env->context = t->info->value->from->ctx;
es->env->name = t->info->value->from->filename;
const bool ret =
- t->info->cdef && !(t->tflag & es->flag) ? es->func(es->data, t) : GW_OK;
+ t->info->cdef && !(t->tflag & es->flag) ? es->func(es->data, t) : true;
envset_pop(es, owner_class);
return ret;
}
const size_t idx_len = num_digit(i);
const size_t len = base_len + tmpl_len + nspc_len + idx_len + 2;
char name[len + 1];
- CHECK_BO(sprintf(name, "%s%s%s%s@%" UINT_F "@%s", base, !tmpl ? "" : ":[",
- !tmpl ? "" : tmpl, !tmpl ? "" : "]", i, nspc));
+ if(sprintf(name, "%s%s%s%s@%" UINT_F "@%s", base, !tmpl ? "" : ":[",
+ !tmpl ? "" : tmpl, !tmpl ? "" : "]", i, nspc) < 1)
+ return NULL;
return insert_symbol(env->gwion->st, name);
}
return a;
}
-ANN m_bool isa(const restrict Type var, const restrict Type parent) {
- return (var == parent) ? GW_OK
+ANN bool isa(const restrict Type var, const restrict Type parent) {
+ return (var == parent) ? true
: var->info->parent ? isa(var->info->parent, parent)
- : GW_ERROR;
+ : false;
}
ANN Type find_common_anc(const restrict Type lhs, const restrict Type rhs) {
- return isa(lhs, rhs) > 0 ? rhs : isa(rhs, lhs) > 0 ? lhs : NULL;
+ return isa(lhs, rhs) ? rhs : isa(rhs, lhs) ? lhs : NULL;
}
#define describe_find(name, t) \
}
ANN bool is_func(const struct Gwion_ *gwion, const Type t) {
- return isa(actual_type(gwion, t), gwion->type[et_function]) > 0;
+ return isa(actual_type(gwion, t), gwion->type[et_function]);
}
ANN inline bool is_class(const struct Gwion_ *gwion, const Type t) {
-// return isa(t, gwion->type[et_class]) > 0;
+// return isa(t, gwion->type[et_class]);
return t->info->parent == gwion->type[et_class];
}
ANN2(1, 2) static void import_class_ini(const Env env, const Type t) {
t->nspc = new_nspc(env->gwion->mp, t->name);
t->nspc->parent = env->curr;
- if (isa(t, env->gwion->type[et_object]) > 0) inherit(t);
+ if (isa(t, env->gwion->type[et_object])) inherit(t);
env_push_type(env, t);
}
Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent) {
struct ImportCK ck = {.name = name};
CHECK_O(check_typename_def(gwi, &ck));
- DECL_OO(Type_Decl *, td, = gwi_str2td(gwi, parent ?: "Object"));
+ DECL_O(Type_Decl *, td, = gwi_str2td(gwi, parent ?: "Object"));
Tmpl *tmpl = ck.sl ? new_tmpl(gwi->gwion->mp, ck.sl) : NULL;
if (tmpl) CHECK_O(template_push_types(gwi->gwion->env, tmpl));
- DECL_OO(const Type, base, = known_type(gwi->gwion->env, td));
+ DECL_O(const Type, base, = known_type(gwi->gwion->env, td));
const TmplArg_List tl = td->types;
if (tflag(base, tflag_ntmpl)) td->types = NULL;
const Type p = !td->types ? known_type(gwi->gwion->env, td) : NULL;
td->types = tl;
if (tmpl) nspc_pop_type(gwi->gwion->mp, gwi->gwion->env->curr);
- CHECK_OO(p);
+ CHECK_O(p);
const Type t = new_type(gwi->gwion->mp, s_name(ck.sym), p);
t->info->cdef = new_class_def(gwi->gwion->mp, 0, MK_TAG(ck.sym, gwi->loc), td, NULL);
t->info->cdef->base.tmpl = tmpl;
mp_vector_add(gwion->mp, sl, Specialized, spec);
return true;
}
- DECL_OO(const Symbol, sym, = __str2sym(gwion, tdc));
+ DECL_O(const Symbol, sym, = __str2sym(gwion, tdc));
// TODO: handle traits?
Specialized spec = { .tag = MK_TAG(sym, tdc->loc) };
mp_vector_add(gwion->mp, sl, Specialized, spec);
td->ref = ref;
return td;
}
- DECL_OO(const Symbol, sym, = __str2sym(gwion, tdc));
+ DECL_O(const Symbol, sym, = __str2sym(gwion, tdc));
TmplArg_List tl = td_tmpl(gwion, tdc);
struct AC ac = {.str = tdc->str, .loc = tdc->loc};
CHECK_O(ac_run(gwion, &ac));
ANN Type_Decl *str2td(const Gwion gwion, const m_str str, const loc_t loc) {
struct td_checker tdc = {.str = str, .loc = loc};
- DECL_OO(Type_Decl *, td, = _str2td(gwion, &tdc));
+ DECL_O(Type_Decl *, td, = _str2td(gwion, &tdc));
if(*tdc.str) {
free_type_decl(gwion->mp, td);
GWION_ERR_O(loc, "excedental character '%c' in '%s'", *tdc.str, str);
}
ANN Type str2type(const Gwion gwion, const m_str str, const loc_t loc) {
- DECL_OO(Type_Decl *, td, = str2td(gwion, str, loc));
+ DECL_O(Type_Decl *, td, = str2td(gwion, str, loc));
const Type t = known_type(gwion->env, td);
free_type_decl(gwion->mp, td);
return t;
}
}
}
- return GW_OK;
+ return true;
}
ANEW ANN m_str type2str(const Gwion gwion, const Type t,
//! start an enum definition
//! \arg the importer
//! \arg string defining a primitive type
-ANN m_int gwi_enum_ini(const Gwi gwi, const m_str type) {
- CHECK_b(ck_ini(gwi, ck_edef));
- CHECK_OB((gwi->ck->xid = gwi_str2sym(gwi, type)));
+ANN bool gwi_enum_ini(const Gwi gwi, const m_str type) {
+ CHECK_B(ck_ini(gwi, ck_edef));
+ CHECK_B((gwi->ck->xid = gwi_str2sym(gwi, type)));
gwi->ck->tmpl = new_mp_vector(gwi->gwion->mp, EnumValue, 0);
- return GW_OK;
+ return true;
}
//! add an enum entry
//! \arg the importer
//! \arg name of the entry
-ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint i) {
+ANN bool gwi_enum_add(const Gwi gwi, const m_str name, const m_uint i) {
CHECK_B(ck_ok(gwi, ck_edef));
- DECL_OB(const Symbol, xid, = gwi_str2sym(gwi, name));
+ DECL_B(const Symbol, xid, = gwi_str2sym(gwi, name));
const EnumValue ev = { .tag = MK_TAG(xid, gwi->loc), .gwint = { .num = i }, .set = true};
mp_vector_add(gwi->gwion->mp, &gwi->ck->tmpl, EnumValue, ev);
- return GW_OK;
+ return true;
}
//! finish enum import
//! \arg the importer
-ANN Type gwi_enum_end(const Gwi gwi) {
- CHECK_O(ck_ok(gwi, ck_edef));
- if (!gwi->ck->tmpl->len) GWI_ERR_O("Enum is empty");
+ANN bool gwi_enum_end(const Gwi gwi) {
+ CHECK_B(ck_ok(gwi, ck_edef));
+ if (!gwi->ck->tmpl->len) GWI_ERR_B("Enum is empty");
const Gwion gwion = gwi->gwion;
const Enum_Def edef =
new_enum_def(gwion->mp, gwi->ck->tmpl, gwi->ck->xid, gwi->loc);
gwi->ck->tmpl = NULL;
const bool ret = traverse_enum_def(gwion->env, edef);
if (gwi->gwion->data->cdoc) gwfmt_enum_def(gwi->gwfmt, edef);
- const Type t = ret ? edef->type : NULL;
free_enum_def(gwion->mp, edef);
ck_end(gwi);
- return t;
+ return ret;
}
ANN2(1, 2, 3)
static bool dl_func_init(const Gwi gwi, const restrict m_str t,
const restrict m_str n) {
- CHECK_b(ck_ini(gwi, ck_fdef));
+ CHECK_B(ck_ini(gwi, ck_fdef));
gwi->ck->name = n;
- CHECK_b(check_typename_def(gwi, gwi->ck));
+ CHECK_B(check_typename_def(gwi, gwi->ck));
CHECK_B((gwi->ck->td = gwi_str2td(gwi, t)));
gwi->ck->mpv = new_mp_vector(gwi->gwion->mp, Arg, 0);
return true;
}
ANN bool gwi_func_end(const Gwi gwi, const f_xfun addr, const ae_flag flag) {
- CHECK_b(ck_ok(gwi, ck_fdef));
+ CHECK_B(ck_ok(gwi, ck_fdef));
gwi->ck->addr = addr;
gwi->ck->flag = flag;
const bool ret = gwi_func_valid(gwi, gwi->ck);
ANN bool gwi_func_arg(const Gwi gwi, const restrict m_str t,
const restrict m_str n) {
- CHECK_b(ck_ok(gwi, ck_fdef));
+ CHECK_B(ck_ok(gwi, ck_fdef));
DECL_B(Type_Decl *, td, = gwi_str2td(gwi, t));
struct Var_Decl_ var;
if(gwi_str2var(gwi, &var, n)) {
Arg arg = { .var = MK_VAR(td, var) };
mp_vector_add(gwi->gwion->mp, &gwi->ck->mpv, Arg, arg);
- return GW_OK;
+ return true;
}
free_type_decl(gwi->gwion->mp, td);
return false;
ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) {
CHECK_O(ck_ok(gwi, ck_fdef));
- DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi));
+ DECL_O(const Fptr_Def, fptr, = import_fptr(gwi));
fptr->base->flag |= flag;
if (gwi->gwion->data->cdoc) {
gwfmt_indent(gwi->gwfmt);
tflag_tmpl) /*&& !fptr->base->tmpl*/) {
section_fptr(gwi, fptr);
ck_end(gwi);
- return (Type)GW_OK;
+ return (Type)true;
}
const bool ret = traverse_fptr_def(gwi->gwion->env, fptr);
// if (fptr->base->func) // is it needed ?
#include "import.h"
#include "gwi.h"
-ANN m_int gwi_item_ini(const Gwi gwi, const restrict m_str type,
+ANN bool gwi_item_ini(const Gwi gwi, const restrict m_str type,
const restrict m_str name) {
- CHECK_b(ck_ini(gwi, ck_item));
- if ((gwi->ck->exp = make_exp(gwi, type, name))) return GW_OK;
+ CHECK_B(ck_ini(gwi, ck_item));
+ if ((gwi->ck->exp = make_exp(gwi, type, name))) return true;
GWI_ERR_B(_(" ... during var import '%s.%s'."), gwi->gwion->env->name, name)
}
-ANN static m_int gwi_item_tmpl(const Gwi gwi) {
+ANN static bool gwi_item_tmpl(const Gwi gwi) {
Stmt_List slist = new_mp_vector(gwi->gwion->mp, Stmt, 1);
mp_vector_set(slist, Stmt, 0, MK_STMT_EXP(gwi->loc, gwi->ck->exp));
Section section = MK_SECTION(stmt, stmt_list, slist);
gwi_body(gwi, §ion);
mp_free2(gwi->gwion->mp, sizeof(ImportCK), gwi->ck);
gwi->ck = NULL;
- return GW_OK;
+ return true;
}
#undef gwi_item_end
ANN2(1)
-m_int gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data addr) {
- CHECK_b(ck_ok(gwi, ck_item));
+bool gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data addr) {
+ CHECK_B(ck_ok(gwi, ck_item));
const Env env = gwi->gwion->env;
gwi->ck->exp->d.exp_decl.var.td->flag = flag;
if (gwi->gwion->data->cdoc) {
}
if (env->class_def && tflag(env->class_def, tflag_tmpl))
return gwi_item_tmpl(gwi);
- CHECK_b(traverse_exp(env, gwi->ck->exp));
+ CHECK_B(traverse_exp(env, gwi->ck->exp));
const Value value = gwi->ck->exp->d.exp_decl.var.vd.value;
value->d = addr;
set_vflag(value, vflag_builtin);
if (!env->class_def) SET_FLAG(value, global);
- const m_uint offset = value->from->offset;
free_exp(gwi->gwion->mp, gwi->ck->exp);
ck_end(gwi);
- return offset;
+ return true;
}
ANN void ck_clean_item(MemPool mp, ImportCK *ck) {
static OP_EMIT(opem_bitset) {
Exp_Binary *bin = data;
const Instr instr = emit_add_instr(emit, bitset);
- const Type t = isa(bin->rhs->type, emit->gwion->type[et_int]) > 0
+ const Type t = isa(bin->rhs->type, emit->gwion->type[et_int])
? bin->lhs->type
: bin->rhs->type;
instr->m_val = t->actual_size;
static OP_EMIT(opem_bitcast) {
Exp_Cast *cast = data;
- const Type t = isa(cast->exp->type, emit->gwion->type[et_int]) > 0
+ const Type t = isa(cast->exp->type, emit->gwion->type[et_int])
? known_type(emit->env, cast->td)
: cast->exp->type;
const Instr instr = emit_add_instr(emit, bitcast);
gwfmt_sc(gwi->gwfmt);
gwfmt_nl(gwi->gwfmt);
}
- CHECK_OO(gwi_str2sym(gwi, name));
+ CHECK_O(gwi_str2sym(gwi, name));
const Type parent = get_parent(gwi, parent_name);
const Type t = new_type(gwi->gwion->mp, name, parent);
t->size = size;
// move me
ANN Exp* make_exp(const Gwi gwi, const m_str type, const m_str name) {
- DECL_OO(Type_Decl *, td, = gwi_str2td(gwi, type));
+ DECL_O(Type_Decl *, td, = gwi_str2td(gwi, type));
struct Var_Decl_ vd;
if(!gwi_str2var(gwi, &vd, name)) {
free_type_decl(gwi->gwion->mp, td);
ANN bool gwi_union_ini(const Gwi gwi, const m_str name) {
CHECK_B(ck_ini(gwi, ck_udef));
gwi->ck->name = name;
- CHECK_b(check_typename_def(gwi, gwi->ck));
+ CHECK_B(check_typename_def(gwi, gwi->ck));
gwi->ck->mpv = new_mp_vector(gwi->gwion->mp, Variable, 0);
return true;
}
#define ARRAY_OPCK(a, b, loc) \
const Type l = array_base(a->type); \
const Type r = array_base(b->type); \
- if (isa(r, l) < 0) ERR_N(loc, _("array types do not match."));
+ if (!isa(r, l)) ERR_N(loc, _("array types do not match."));
static OP_CHECK(opck_array_at) {
const Exp_Binary *bin = (Exp_Binary *)data;
const Type r = array_base(t);
if (get_depth(cast->exp->type) != get_depth(t))
return NULL;
- if(isa(l, r) > 0) return l;
+ if(isa(l, r)) return l;
Type parent = t;
while(parent) {
if (tflag(parent, tflag_cdef) && parent->info->cdef->base.ext && parent->info->cdef->base.ext->array) {
const Type l = array_base(cast->exp->type);
const Type t = known_type(env, cast->td);
const Type r = array_base(t);
- if(isa(l, r) < 0) {
+ if(!isa(l, r)) {
const m_uint depth = get_depth(t);
const m_uint start = emit_code_size(emit);
cast_start(emit, depth);
access = emit_add_instr(emit, ArrayAccess);
access->m_val = (i+1) * SZ_INT - offset;
access->udata.one = offset;
- if(i < get_depth(t) || isa(array_base(t), emit->gwion->type[et_object]) > 0) {
+ if(i < get_depth(t) || isa(array_base(t), emit->gwion->type[et_object])) {
const Instr ex = emit_add_instr(emit, GWOP_EXCEPT);
ex->m_val = -SZ_INT;
}
const struct Implicit *imp = (struct Implicit *)data;
if (imp->t->array_depth != imp->e->type->array_depth)
return env->gwion->type[et_error];
- if (isa(array_base(imp->e->type), array_base(imp->t)) < 0)
+ if (!isa(array_base(imp->e->type), array_base(imp->t)))
return env->gwion->type[et_error];
return imp->t;
}
ANN static inline Type foreach_type(const Env env, Exp* exp) {
const Type et = exp->type;
- DECL_OO(Type, base, = typedef_base(et));
- DECL_OO(const Type, t, = array_base_simple(base));
+ DECL_O(Type, base, = typedef_base(et));
+ DECL_O(const Type, t, = array_base_simple(base));
if(!tflag(base, tflag_ref)) {
const m_uint depth = base->array_depth - 1;
return depth ? array_type(env, t, depth, exp->loc) : t;
GWI_B(gwi_oper_end(gwi, "@array_init", NoOp))
gwi_register_freearg(gwi, ArrayAlloc, freearg_array);
- return GW_OK;
+ return true;
}
INSTR(ArrayStruct) {
return exp_is_zero(e);
}
-#undef ERR_B
-#define ERR_B(a, b, ...) \
- { \
- env_err(env, (a), (b), ##__VA_ARGS__); \
- return false; \
- }
-
ANN2(1,2) bool check_array_instance(const Env env, Type_Decl *td, Exp* args) {
if (!last_is_zero(td->array->exp)) {
if (!args)
static bool td_match(const Env env, Type_Decl *id[2]) {
DECL_B(const Type, t0, = known_type(env, id[0]));
DECL_B(const Type, t1, = known_type(env, id[1]));
- if (isa(t0, t1) > 0) return true;
+ if (isa(t0, t1)) return true;
return t1 == env->gwion->type[et_auto];
}
// if(!info->lhs->def->base->tmpl != !info->rhs->def->base->tmpl)
// return false;
if(!info->lhs)
- ERR_b(info->exp->loc,
+ ERR_B(info->exp->loc,
_("can't resolve operator"));
return true;
}
info->lhs = v->type->info->func;
}
} else {
- DECL_OO(const Type, t,
+ DECL_O(const Type, t,
= nspc_lookup_type1(nspc, info->lhs->def->base->tag.sym));
info->lhs = actual_type(env->gwion, t)->info->func;
}
Arg_List bases = fdef->base->args;
Arg_List args = l->def->base->args;
if (mp_vector_len(bases) != mp_vector_len(args))
- ERR_b(exp_self(l)->loc, _("argument number does not match for lambda"));
+ ERR_B(exp_self(l)->loc, _("argument number does not match for lambda"));
if(l->def->captures) {
// here move to arguments
for(uint32_t i = 0; i < l->def->captures->len; i++) {
Capture *cap = mp_vector_at(l->def->captures, Capture, i);
const Value v = nspc_lookup_value1(env->curr, cap->var.tag.sym);
- if(!v) ERR_b(cap->var.tag.loc, _("unknown value in capture"));
+ if(!v) ERR_B(cap->var.tag.loc, _("unknown value in capture"));
DECL_B(const Type, t, = upvalue_type(env, cap));
cap->temp = new_value(env, t, cap->var.tag);
cap->var.value = v;
if(info->exp->type->info->func) {
CHECK_B(fptr_check(env, info));
if (!(info->exp->type = fptr_type(env, info)))
- ERR_b(info->exp->loc, _("no match found"));
+ ERR_B(info->exp->loc, _("no match found"));
return true;
}
Exp_Lambda *l = &info->exp->d.exp_lambda;
.loc = impl->e->loc};
vector_add(&env->scope->effects, 0);
DECL_ON(const Type, t, = op_check(env, &opi));
- CHECK_BN(isa(t, func->def->base->ret_type)); // error message?
+ CHECK_ON(isa(t, func->def->base->ret_type)); // error message?
MP_Vector *const eff = (MP_Vector*)vector_back(&env->scope->effects);
// if (eff && !check_effect_overload(eff, func))
// ERR_N(impl->loc, _("`{+Y}%s{0}` has effects not present in `{+G}%s{0}`\n"),
GWION_IMPORT(func) {
gwidoc(gwi, "the base of all functions.");
const Type t_function = gwi_mk_type(gwi, "function", SZ_INT, NULL);
- GWI_BB(gwi_gack(gwi, t_function, gack_function))
- GWI_BB(gwi_set_global_type(gwi, t_function, et_function))
+ GWI_B(gwi_gack(gwi, t_function, gack_function))
+ GWI_B(gwi_set_global_type(gwi, t_function, et_function))
gwidoc(gwi, "the base of decayed operators.");
const Type t_op = gwi_mk_type(gwi, "operator", SZ_INT, "function");
- GWI_BB(gwi_set_global_type(gwi, t_op, et_op))
+ GWI_B(gwi_set_global_type(gwi, t_op, et_op))
gwidoc(gwi, "the base of function pointers.");
const Type t_closure = gwi_class_ini(gwi, "funptr", "Object");
t_closure->nspc->offset = SZ_INT*3;
gwi_class_xtor(gwi, fptr_ctor, fptr_dtor);
- GWI_BB(gwi_set_global_type(gwi, t_closure, et_closure))
+ GWI_B(gwi_set_global_type(gwi, t_closure, et_closure))
GWI_B(gwi_func_ini(gwi, "void", "default"));
GWI_B(gwi_func_end(gwi, fptr_default, ae_flag_none));
gwi_class_end(gwi);
gwi_register_freearg(gwi, GTmpl, freearg_gtmpl);
gwi_register_freearg(gwi, DotTmpl, freearg_dottmpl);
- return GW_OK;
+ return true;
}
GWI_B(gwi_oper_emi(gwi, opem_deep_equal))
GWI_B(gwi_oper_end(gwi, "<>", NULL))
- return GW_OK;
+ return true;
}
Exp* func = call->func;
Exp* args = call->args;
e->exp_type = ae_exp_binary;
- CHECK_OO(check_exp(env, e->d.exp_binary.rhs = cpy_exp(env->gwion->mp, func->d.exp_dot.base)));
- CHECK_OO(check_exp(env, e->d.exp_binary.lhs = args));
+ CHECK_O(check_exp(env, e->d.exp_binary.rhs = cpy_exp(env->gwion->mp, func->d.exp_dot.base)));
+ CHECK_O(check_exp(env, e->d.exp_binary.lhs = args));
e->d.exp_binary.op = insert_symbol("~~");
free_exp(env->gwion->mp, func);
const Type t = e->d.exp_binary.rhs->type;
HMapInfo *const hinfo = (HMapInfo*)t->nspc->class_data;
- if(isa(args->type, hinfo->key) < 0 || args->next)
+ if(!isa(args->type, hinfo->key) || args->next)
ERR_N(e->loc, "dict.remove must be called with one Key argument");
return e->type = env->gwion->type[et_void];
}
const bool ret = _opem_dict_access(emit, data);
array->exp->next = enext;
CHECK_B(ret);
- return !enext ? GW_OK : emit_next_access(emit, info);
+ return !enext ? true : emit_next_access(emit, info);
}
static OP_CHECK(opck_dict_access) {
}
GWION_IMPORT(dict) {
- DECL_OB(const Type, t_dict, = gwi_class_ini(gwi, "Dict:[Key,Val]", "Object"));
+ DECL_B(const Type, t_dict, = gwi_class_ini(gwi, "Dict:[Key,Val]", "Object"));
gwi_class_xtor(gwi, dict_ctor, dict_dtor);
t_dict->nspc->offset += sizeof(struct HMap);
gwi->gwion->type[et_dict] = t_dict;
GWI_B(gwi_func_arg(gwi, "string", "key"));
GWI_B(gwi_func_end(gwi, mfun_string_h, ae_flag_none));
- return GW_OK;
+ return true;
}
gwidoc(gwi, "one type to rule them all.");
const Type t_class = gwi_mk_type(gwi, "Class", SZ_INT, NULL);
set_tflag(t_class, tflag_infer);
- GWI_BB(gwi_set_global_type(gwi, t_class, et_class))
- GWI_BB(gwi_gack(gwi, t_class, gack_class))
+ GWI_B(gwi_set_global_type(gwi, t_class, et_class))
+ GWI_B(gwi_gack(gwi, t_class, gack_class))
gwidoc(gwi, "this type is infered.");
const Type t_auto = gwi_mk_type(gwi, "auto", SZ_INT, NULL);
set_tflag(t_auto, tflag_infer);
- GWI_BB(gwi_set_global_type(gwi, t_auto, et_auto))
+ GWI_B(gwi_set_global_type(gwi, t_auto, et_auto))
gwidoc(gwi, "a void type.");
const Type t_void = gwi_mk_type(gwi, "void", 0, NULL);
- GWI_BB(gwi_gack(gwi, t_void, gack_void))
- GWI_BB(gwi_set_global_type(gwi, t_void, et_void))
+ GWI_B(gwi_gack(gwi, t_void, gack_void))
+ GWI_B(gwi_set_global_type(gwi, t_void, et_void))
gwidoc(gwi, "integer type.");
const Type t_int = gwi_mk_type(gwi, "int", SZ_INT, NULL);
- GWI_BB(gwi_gack(gwi, t_int, gack_int))
- GWI_BB(gwi_set_global_type(gwi, t_int, et_int))
+ GWI_B(gwi_gack(gwi, t_int, gack_int))
+ GWI_B(gwi_set_global_type(gwi, t_int, et_int))
gwidoc(gwi, "character type.");
const Type t_char = gwi_mk_type(gwi, "char", SZ_INT, "int");
- GWI_BB(gwi_gack(gwi, t_char, gack_char))
- GWI_BB(gwi_set_global_type(gwi, t_char, et_char))
+ GWI_B(gwi_gack(gwi, t_char, gack_char))
+ GWI_B(gwi_set_global_type(gwi, t_char, et_char))
gwidoc(gwi, "float type.");
const Type t_float = gwi_mk_type(gwi, "float", SZ_FLOAT, NULL);
- GWI_BB(gwi_gack(gwi, t_float, gack_float))
- GWI_BB(gwi_set_global_type(gwi, t_float, et_float))
+ GWI_B(gwi_gack(gwi, t_float, gack_float))
+ GWI_B(gwi_set_global_type(gwi, t_float, et_float))
set_tflag(t_float, tflag_float);
gwidoc(gwi, "represent duration.");
const Type t_dur = gwi_mk_type(gwi, "dur", SZ_FLOAT, NULL);
- GWI_BB(gwi_gack(gwi, t_dur, gack_float))
- GWI_BB(gwi_add_type(gwi, t_dur))
+ GWI_B(gwi_gack(gwi, t_dur, gack_float))
+ GWI_B(gwi_add_type(gwi, t_dur))
set_tflag(t_dur, tflag_float);
gwidoc(gwi, "represent time.");
const Type t_time = gwi_mk_type(gwi, "time", SZ_FLOAT, NULL);
- GWI_BB(gwi_gack(gwi, t_time, gack_float))
- GWI_BB(gwi_add_type(gwi, t_time))
+ GWI_B(gwi_gack(gwi, t_time, gack_float))
+ GWI_B(gwi_add_type(gwi, t_time))
set_tflag(t_time, tflag_float);
gwidoc(gwi, "internal time for `{/}now{0}{-}`.");
const Type t_now = gwi_mk_type(gwi, "@now", SZ_FLOAT, "time");
- GWI_BB(gwi_add_type(gwi, t_now))
+ GWI_B(gwi_add_type(gwi, t_now))
struct SpecialId_ spid = {.type = t_now, .exec = RegPushNow, .is_const = 1};
gwi_specialid(gwi, "now", &spid);
gwidoc(gwi, "internal base of all objects and structures.");
- GWI_BB(gwimport_enum(gwi));
+ GWI_B(gwimport_enum(gwi));
const Type t_compound = gwi_mk_type(gwi, "@Compound", SZ_INT, NULL);
- GWI_BB(gwi_gack(gwi, t_compound, gack_compound))
- GWI_BB(gwi_set_global_type(gwi, t_compound, et_compound))
+ GWI_B(gwi_gack(gwi, t_compound, gack_compound))
+ GWI_B(gwi_set_global_type(gwi, t_compound, et_compound))
- GWI_BB(gwimport_object(gwi))
+ GWI_B(gwimport_object(gwi))
- GWI_BB(gwimport_prim(gwi))
- GWI_BB(gwimport_func(gwi))
- GWI_BB(gwimport_object_op(gwi))
- GWI_BB(gwimport_values(gwi))
- GWI_BB(gwimport_union(gwi))
+ GWI_B(gwimport_prim(gwi))
+ GWI_B(gwimport_func(gwi))
+ GWI_B(gwimport_object_op(gwi))
+ GWI_B(gwimport_values(gwi))
+ GWI_B(gwimport_union(gwi))
- GWI_BB(gwimport_array(gwi))
- GWI_BB(gwimport_event(gwi))
- GWI_BB(gwimport_ugen(gwi))
- GWI_BB(gwimport_xork(gwi))
+ GWI_B(gwimport_array(gwi))
+ GWI_B(gwimport_event(gwi))
+ GWI_B(gwimport_ugen(gwi))
+ GWI_B(gwimport_xork(gwi))
GWI_B(gwi_oper_ini(gwi, NULL, (m_str)OP_ANY_TYPE, NULL))
GWI_B(gwi_oper_add(gwi, opck_new))
GWI_B(gwi_oper_emi(gwi, opem_new))
GWI_B(gwi_oper_end(gwi, "new", NULL))
- GWI_BB(gwimport_ref(gwi))
- GWI_BB(gwimport_string(gwi))
- GWI_BB(gwimport_shred(gwi))
- GWI_BB(gwimport_modules(gwi))
+ GWI_B(gwimport_ref(gwi))
+ GWI_B(gwimport_string(gwi))
+ GWI_B(gwimport_shred(gwi))
+ GWI_B(gwimport_modules(gwi))
gwidoc(gwi, "allow member access.");
GWI_B(gwi_oper_ini(gwi, "@Compound", (m_str)OP_ANY_TYPE, NULL))
GWI_B(gwi_oper_emi(gwi, opem_object_dot))
GWI_B(gwi_oper_end(gwi, ".", NULL))
- GWI_BB(gwimport_class(gwi))
+ GWI_B(gwimport_class(gwi))
gwidoc(gwi, "allow static access.");
GWI_B(gwi_oper_ini(gwi, "Class", (m_str)OP_ANY_TYPE, NULL))
GWI_B(gwi_oper_add(gwi, opck_object_dot))
GWI_B(gwi_oper_emi(gwi, opem_object_dot))
GWI_B(gwi_oper_end(gwi, ".", NULL))
- GWI_BB(gwimport_deep_equal(gwi));
+ GWI_B(gwimport_deep_equal(gwi));
- GWI_BB(gwimport_dict(gwi));
- GWI_BB(gwimport_gack(gwi));
- GWI_BB(gwimport_sift(gwi));
- GWI_BB(gwimport_locale(gwi));
+ GWI_B(gwimport_dict(gwi));
+ GWI_B(gwimport_gack(gwi));
+ GWI_B(gwimport_sift(gwi));
+ GWI_B(gwimport_locale(gwi));
// seemed need at a point to ease liking
const Type t_enum = gwi_mk_type(gwi, "enum", SZ_INT, "int");
gwi_set_global_type(gwi, t_enum, et_enum);
gwi_gack(gwi, t_enum, gack_enum);
- return GW_OK;
+ return true;
}
GWI_B(gwi_class_end(gwi))
GWI_B(gwi_oper_ini(gwi, "Event", "@now", "int"))
GWI_B(gwi_oper_end(gwi, "=>", EventWait))
- return GW_OK;
+ return true;
}
const Env env = emit->env;
const Symbol sym = func_symbol(env, nspc->name, s_name(fdef->base->tag.sym),
"template", fbase->vt_index);
- DECL_OO(const Value, v, = nspc_lookup_value0(nspc, sym)
+ DECL_O(const Value, v, = nspc_lookup_value0(nspc, sym)
?: nspc_lookup_value0(nspc, fdef->base->tag.sym));
const f_xfun xfun = v->d.func_ref->def->d.dl_func_ptr;
if (vflag(v, vflag_builtin))
POP_REG(shred, SZ_INT); \
const Type l = *(Type *)(shred->reg - SZ_INT); \
const Type r = *(Type *)(shred->reg); \
- *(m_uint *)(shred->reg - SZ_INT) = isa(arg0, arg1) > 0 __VA_ARGS__; \
+ *(m_uint *)(shred->reg - SZ_INT) = isa(arg0, arg1) __VA_ARGS__; \
}
mk_class_instr(ge, l, r) mk_class_instr(gt, l, r, &&l != r)
mk_class_instr(le, r, l) mk_class_instr(lt, r, l, &&l != r)
static OP_CHECK(opck_implicit_class) {
struct Implicit *imp = (struct Implicit*)data;
const Type t = actual_type(env->gwion, imp->e->type);
- if(isa(t, env->gwion->type[et_enum]) > 0) return imp->e->type;
+ if(isa(t, env->gwion->type[et_enum])) return imp->e->type;
return env->gwion->type[et_error];
}
*/
GWI_B(gwi_oper_emi(gwi, opem_implicit_class))
GWI_B(gwi_oper_end(gwi, "@implicit", NULL))
*/
- return GW_OK;
+ return true;
}
gwidoc(gwi, "a type for *pretty print*.");
const Type t_gack = gwi_mk_type(gwi, "@Gack", SZ_INT, NULL);
- GWI_BB(gwi_gack(gwi, t_gack, gack_gack))
- GWI_BB(gwi_set_global_type(gwi, t_gack, et_gack));
+ GWI_B(gwi_gack(gwi, t_gack, gack_gack))
+ GWI_B(gwi_set_global_type(gwi, t_gack, et_gack));
gwidoc(gwi, "@Gack implicit cast");
GWI_B(gwi_oper_ini(gwi, "@Gack", (m_str)OP_ANY_TYPE, NULL))
GWI_B(gwi_oper_emi(gwi, opem_gack_implicit))
GWI_B(gwi_oper_end(gwi, "@implicit", NULL))
- return GW_OK;
+ return true;
}
GWI_B(gwi_func_ini(gwi, "float", "BasicLocale"));
GWI_B(gwi_func_arg(gwi, "string", "str"));
GWI_B(gwi_func_end(gwi, BasicLocale, ae_flag_none));
- return GW_OK;
+ return true;
}
}
static GWION_IMPORT(gain) {
- GWI_OB(gwi_class_ini(gwi, "Gain", "UGen"))
+ GWI_B(gwi_class_ini(gwi, "Gain", "UGen"))
gwi_class_xtor(gwi, gain_ctor, basic_dtor);
gwi_func_ini(gwi, "float", "gain");
GWI_B(gwi_func_end(gwi, gain_get_gain, ae_flag_none))
}
static GWION_IMPORT(impulse) {
- GWI_OB(gwi_class_ini(gwi, "Impulse", "UGen"))
+ GWI_B(gwi_class_ini(gwi, "Impulse", "UGen"))
gwi_class_xtor(gwi, impulse_ctor, basic_dtor);
gwi_func_ini(gwi, "float", "next");
GWI_B(gwi_func_end(gwi, impulse_get_next, ae_flag_none))
}
static GWION_IMPORT(fullrect) {
- GWI_OB(gwi_class_ini(gwi, "FullRect", "UGen"))
+ GWI_B(gwi_class_ini(gwi, "FullRect", "UGen"))
gwi_class_xtor(gwi, fullrect_ctor, basic_dtor);
return gwi_class_end(gwi);
}
}
static GWION_IMPORT(halfrect) {
- GWI_OB(gwi_class_ini(gwi, "HalfRect", "UGen"))
+ GWI_B(gwi_class_ini(gwi, "HalfRect", "UGen"))
gwi_class_xtor(gwi, halfrect_ctor, basic_dtor);
return gwi_class_end(gwi);
}
}
static GWION_IMPORT(step) {
- GWI_OB(gwi_class_ini(gwi, "Step", "UGen"))
+ GWI_B(gwi_class_ini(gwi, "Step", "UGen"))
gwi_class_xtor(gwi, step_ctor, basic_dtor);
gwi_func_ini(gwi, "float", "next");
GWI_B(gwi_func_end(gwi, step_get_next, ae_flag_none))
}
static GWION_IMPORT(zerox) {
- GWI_OB(gwi_class_ini(gwi, "ZeroX", "UGen"))
+ GWI_B(gwi_class_ini(gwi, "ZeroX", "UGen"))
gwi_class_xtor(gwi, zerox_ctor, basic_dtor);
return gwi_class_end(gwi);
}
if (!arg || arg->len > 1)
ERR_N(exp_self(bin)->loc,
_("Tick function take one and only one argument"));
- if (isa(((Arg*)(arg->ptr))->type, env->gwion->type[et_float]) < 0)
+ if (!isa(((Arg*)(arg->ptr))->type, env->gwion->type[et_float]))
ERR_N(exp_self(bin)->loc,
_("Tick functions argument must be of type float"));
- if (isa(bin->lhs->type->info->func->def->base->ret_type,
- env->gwion->type[et_float]) < 0)
+ if (!isa(bin->lhs->type->info->func->def->base->ret_type,
+ env->gwion->type[et_float]))
ERR_N(exp_self(bin)->loc, _("Tick function must return float"));
if (bin->lhs->type->info->func->value_ref->from->owner_class)
- CHECK_BN(isa(bin->lhs->type->info->func->value_ref->from->owner_class,
+ CHECK_ON(isa(bin->lhs->type->info->func->value_ref->from->owner_class,
bin->rhs->type));
return bin->rhs->type;
}
}
static GWION_IMPORT(usrugen) {
- GWI_OB(gwi_class_ini(gwi, "UsrUGen", "UGen"))
+ GWI_B(gwi_class_ini(gwi, "UsrUGen", "UGen"))
gwi_class_xtor(gwi, usrugen_ctor, usrugen_dtor);
GWI_B(gwi_func_ini(gwi, "int", "default_tick"))
GWI_B(gwi_func_end(gwi, default_tick, 0))
GWI_B(gwi_oper_add(gwi, opck_usrugen))
GWI_B(gwi_oper_emi(gwi, opem_usrugen))
GWI_B(gwi_oper_end(gwi, "~=>", NULL))
- return GW_OK;
+ return true;
}
GWION_IMPORT(modules) {
- GWI_BB(gwimport_gain(gwi))
- GWI_BB(gwimport_impulse(gwi))
- GWI_BB(gwimport_fullrect(gwi))
- GWI_BB(gwimport_halfrect(gwi))
- GWI_BB(gwimport_step(gwi))
- GWI_BB(gwimport_zerox(gwi))
+ GWI_B(gwimport_gain(gwi))
+ GWI_B(gwimport_impulse(gwi))
+ GWI_B(gwimport_fullrect(gwi))
+ GWI_B(gwimport_halfrect(gwi))
+ GWI_B(gwimport_step(gwi))
+ GWI_B(gwimport_zerox(gwi))
return gwimport_usrugen(gwi);
}
if(!env->func || is_ctor(env->func->def))
ERR_O(self->loc, "can't use 'super' outside of constructor");
const Type parent = env->class_def->info->parent;
- DECL_OO(const Value, v, = find_value(parent, insert_symbol("new")));
+ DECL_O(const Value, v, = find_value(parent, insert_symbol("new")));
SET_FLAG(env->func, const);
return v->type;
}
const Env env = emit->env;
Exp* self = exp_self(prim);
if(!self->is_call)
- ERR_b(self->loc, "can only use 'super' as a function call");
+ ERR_B(self->loc, "can only use 'super' as a function call");
emit_regpushmem(emit, 0, SZ_INT, false);
emit_pushimm(emit, (m_uint)exp_self(prim)->type);
return true;
gwi_specialid(gwi, "this", &spid_this);
struct SpecialId_ spid_super = {.ck = opck_super, .em = opem_super, .is_const = 1};
gwi_specialid(gwi, "super", &spid_super);
- return GW_OK;
+ return true;
}
SET_FLAG(vd.value, late);
}
exp_setvar(bin->rhs, 1);
- CHECK_BO(isa(bin->lhs->type, bin->rhs->type));
+ CHECK_O(isa(bin->lhs->type, bin->rhs->type));
bin->rhs->ref = bin->lhs;
return bin->rhs->type;
}
static OP_CHECK(opck_object_cast) {
const Exp_Cast *cast = (Exp_Cast *)data;
const Type to = known_type(env, cast->td);
- if (isa(cast->exp->type, to) < 0) {
- if (isa(to, cast->exp->type) > 0)
+ if (!isa(cast->exp->type, to)) {
+ if (isa(to, cast->exp->type))
ERR_N(exp_self(cast)->loc, _("can't upcast '%s' to '%s'"),
cast->exp->type->name, to->name);
ERR_N(exp_self(cast)->loc, _("can't cast '%s' to '%s'"),
}
ANN static bool member_access(const Env env, Exp* exp, const Value value) {
- if (!env->class_def || isa(env->class_def, value->from->owner_class) < 0) {
+ if (!env->class_def || !isa(env->class_def, value->from->owner_class)) {
if (GET_FLAG(value, private)) {
gwerr_basic("invalid variable access", "is private", NULL, env->name,
exp->loc, 0);
const Value v = nspc_lookup_value1(env->curr, member->xid);
if(v) {
if (self->is_call) {
- if (is_func(env->gwion, v->type) && (!v->from->owner_class || isa(the_base, v->from->owner_class) > 0)) // is_callable needs type
+ if (is_func(env->gwion, v->type) && (!v->from->owner_class || isa(the_base, v->from->owner_class))) // is_callable needs type
return v->type;
}
}
CHECK_ON(not_from_owner_class(env, the_base, value, self->loc));
CHECK_ON(member_access(env, self, value));
if ((base_static && vflag(value, vflag_member)) ||
- (value->from->owner_class != env->class_def && isa(value->from->owner_class, env->class_def) > 0))
+ (value->from->owner_class != env->class_def && isa(value->from->owner_class, env->class_def)))
ERR_N(self->loc,
_("cannot access member '%s.%s' without object instance..."),
the_base->name, str);
assert(GET_FLAG(value, static));
emit_dot_static_import_data(emit, value, exp_getvar(exp_self(member)));
}
- if(isa(value->type, emit->gwion->type[et_object]) > 0 &&
+ if(isa(value->type, emit->gwion->type[et_object]) &&
!exp_getvar(exp_self(member)) &&
(GET_FLAG(value, static) || GET_FLAG(value, late)))
emit_fast_except(emit, value->from, exp_self(member)->loc);
GWION_IMPORT(object_op) {
const Type t_error = gwi_mk_type(gwi, "@error", 0, NULL);
gwi->gwion->type[et_error] = t_error;
- GWI_BB(gwi_set_global_type(gwi, t_error, et_error))
+ GWI_B(gwi_set_global_type(gwi, t_error, et_error))
GWI_B(gwi_oper_ini(gwi, "Object", "Object", NULL))
GWI_B(gwi_oper_add(gwi, opck_object_at))
GWI_B(gwi_oper_emi(gwi, opem_object_at))
GWI_B(gwi_oper_ini(gwi, "@Compound", NULL, NULL))
GWI_B(gwi_oper_add(gwi, opck_struct_scan))
GWI_B(gwi_oper_end(gwi, "class", NULL))
- return GW_OK;
+ return true;
}
OP_CHECK(opck_basic_cast) {
const Exp_Cast *cast = (Exp_Cast *)data;
- return isa(cast->exp->type, exp_self(cast)->type) > 0
+ return isa(cast->exp->type, exp_self(cast)->type)
? exp_self(cast)->type
: env->gwion->type[et_error];
}
(!array || (array->exp && exp_is_zero(array->exp))))
ERR_N(unary->ctor.td->tag.loc, _("can't use 'new' on abstract type '%s'\n"),
t->name);
- if (isa(t, env->gwion->type[et_object]) < 0)
+ if (!isa(t, env->gwion->type[et_object]))
ERR_N(exp_self(unary)->loc, _("can't use 'new' on non-object types...\n"));
return t;
}
IMPORT_BINARY_INT(mul, *)
IMPORT_BINARY_INT(div, /)
IMPORT_BINARY_INT(mod, %)
- return GW_OK;
+ return true;
}
static GWION_IMPORT(int_logical) {
CHECK_OP("&=>", rassign, r_sand)
CHECK_OP("|=>", rassign, r_sor)
CHECK_OP("^=>", rassign, r_sxor)
- return GW_OK;
+ return true;
}
static INSTR(IntRange) {
GWI_B(gwi_oper_end(gwi, "++", int_post_inc))
GWI_B(gwi_oper_add(gwi, opck_post))
GWI_B(gwi_oper_end(gwi, "--", int_post_dec))
- return GW_OK;
+ return true;
}
static GACK(gack_bool) {
// gw_out("%s", *(m_uint*)VALUE ? "true" : "false");
}
static GWION_IMPORT(int_values) {
- DECL_OB(const Type, t_bool, = gwi_mk_type(gwi, "bool", SZ_INT, "int"));
- GWI_BB(gwi_set_global_type(gwi, t_bool, et_bool))
- GWI_BB(gwi_gack(gwi, t_bool, gack_bool))
+ DECL_B(const Type, t_bool, = gwi_mk_type(gwi, "bool", SZ_INT, "int"));
+ GWI_B(gwi_set_global_type(gwi, t_bool, et_bool))
+ GWI_B(gwi_gack(gwi, t_bool, gack_bool))
gwi_item_ini(gwi, "bool", "true");
gwi_item_end(gwi, ae_flag_const, num, 1);
gwi_item_ini(gwi, "bool", "false");
struct SpecialId_ spid = {
.type = t_bool, .exec = RegPushMaybe, .is_const = 1};
gwi_specialid(gwi, "maybe", &spid);
- return GW_OK;
+ return true;
}
static GWION_IMPORT(int) {
- GWI_BB(gwimport_int_values(gwi))
+ GWI_B(gwimport_int_values(gwi))
GWI_B(gwi_oper_cond(gwi, "int", BranchEqInt, BranchNeqInt))
GWI_B(gwi_oper_ini(gwi, "int", "int", "int"))
- GWI_BB(gwimport_int_op(gwi))
- GWI_BB(gwimport_int_logical(gwi))
- GWI_BB(gwimport_int_r(gwi))
- GWI_BB(gwimport_int_unary(gwi))
- return GW_OK;
+ GWI_B(gwimport_int_op(gwi))
+ GWI_B(gwimport_int_logical(gwi))
+ GWI_B(gwimport_int_r(gwi))
+ GWI_B(gwimport_int_unary(gwi))
+ return true;
}
static OP_CHECK(opck_cast_f2i) {
GWI_B(gwi_oper_end(gwi, "==", int_float_eq))
GWI_B(gwi_oper_add(gwi, opck_int_float_neq))
GWI_B(gwi_oper_end(gwi, "!=", int_float_neq))
- return GW_OK;
+ return true;
}
#define BINARY_FLOAT_INT_FOLD(name, TYPE, OP, pre) \
GWI_B(gwi_oper_end(gwi, "<", float_int_lt))
GWI_B(gwi_oper_add(gwi, opck_float_int_le))
GWI_B(gwi_oper_end(gwi, "<=", float_int_le))
- return GW_OK;
+ return true;
}
static GWION_IMPORT(dur) {
// GWI_B(gwi_oper_add(gwi, opck_unary_meta2))
GWI_B(gwi_oper_add(gwi, opck_float_not))
GWI_B(gwi_oper_end(gwi, "!", float_not))
- return GW_OK;
+ return true;
}
ANN static GWION_IMPORT(ux) {
const Symbol s = insert_symbol(c);
if(!gwi_primitive(gwi, s_name(s), i, ae_flag_none)) return false;
}
- return GW_OK;
+ return true;
}
GWION_IMPORT(prim) {
- GWI_BB(gwimport_int(gwi))
- GWI_BB(gwimport_ux(gwi));
- GWI_BB(gwimport_float(gwi)) // const folded
- GWI_BB(gwimport_intfloat(gwi)) // const folded
- GWI_BB(gwimport_floatint(gwi)) // const folded
- GWI_BB(gwimport_dur(gwi))
+ GWI_B(gwimport_int(gwi))
+ GWI_B(gwimport_ux(gwi));
+ GWI_B(gwimport_float(gwi)) // const folded
+ GWI_B(gwimport_intfloat(gwi)) // const folded
+ GWI_B(gwimport_floatint(gwi)) // const folded
+ GWI_B(gwimport_dur(gwi))
return gwimport_time(gwi);
}
gwi_item_end(gwi, ae_flag_const, fnum, sr * 60 * 60);
gwi_item_ini(gwi, "time", "t_zero");
gwi_item_end(gwi, ae_flag_const, fnum, 0.0);
- return GW_OK;
+ return true;
}
static OP_EMIT(opem_ref_implicit_similar) {
const struct Implicit *imp = (struct Implicit *)data;
- if(!tflag(imp->t, tflag_contract)) return GW_OK;
+ if(!tflag(imp->t, tflag_contract)) return true;
const Env env = emit->env;
const Type base = ref_base(imp->t);
struct Op_Import opi = {.op = insert_symbol("@implicit"),
GWI_B(gwi_oper_ini(gwi, "Ref", NULL, NULL))
GWI_B(gwi_oper_add(gwi, opck_ref_scan))
GWI_B(gwi_oper_end(gwi, "class", NULL))
- return GW_OK;
+ return true;
}
#include "gwi.h"
#include "ugen.h"
-static m_int o_fork_thread, o_shred_cancel,
- o_fork_done, o_fork_ev;
-
-#define FORK_THREAD(o) *(THREAD_TYPE *)(o->data + o_fork_thread)
+#define SHRED_CANCEL(o) *(m_int *)(o->data + SZ_INT)
+#define FORK_THREAD(o) *(THREAD_TYPE *)(o->data + SZ_INT*2)
+#define FORK_DONE(o) *(m_int *)(o->data + SZ_INT*3)
+#define FORK_EV(o) *(M_Object *)(o->data + SZ_INT*4)
VM_Shred new_shred_base(const VM_Shred shred, const VM_Code code) {
const VM_Shred sh = new_vm_shred(shred->info->mp, code);
ANN static inline M_Object fork_object(const VM_Shred shred, const Type t) {
const Gwion gwion = shred->info->vm->gwion;
const M_Object o = new_object(gwion->mp, t);
- *(M_Object *)(o->data + o_fork_ev) =
- new_object(gwion->mp, gwion->type[et_event]);
- vector_init(&EV_SHREDS(*(M_Object *)(o->data + o_fork_ev)));
+ FORK_EV(o) = new_object(gwion->mp, gwion->type[et_event]);
+ vector_init(&EV_SHREDS(FORK_EV(o)));
return o;
}
gwt_lock(&vm->shreduler->mutex);
gwt_lock(&ME(o)->mutex);
vm->shreduler->bbq->is_running = 0;
- *(m_int *)(o->data + o_shred_cancel) = 1;
- *(m_int *)(o->data + o_fork_done) = 1;
+ SHRED_CANCEL(o) = 1;
+ FORK_DONE(o) = 1;
gwt_unlock(&ME(o)->mutex);
gwt_unlock(&vm->shreduler->mutex);
}
static inline void join(const M_Object o) {
// if(!ME(o)) return;
// gwt_lock(&ME(o)->mutex);
-// const bool done = !*(m_int *)(o->data + o_fork_done);
+// const bool done = !FORK_DONE(o));
// gwt_unlock(&ME(o)->mutex);
-//// if (!*(m_int *)(o->data + o_fork_done)) {
+//// if (!FORK_DONE(o)) {
if (FORK_THREAD(o)) {
// if (!done) {
-// *(m_int *)(o->data + o_fork_done) = 1;
+// FORK_DONE(o) = 1;
THREAD_JOIN(FORK_THREAD(o));
FORK_THREAD(o) = 0;
}
static DTOR(fork_dtor) {
VM *parent = ME(o)->info->vm->parent;
gwt_lock(&ME(o)->mutex);
- *(m_int *)(o->data + o_fork_done) = 1;
+ FORK_DONE(o) = 1;
gwt_unlock(&ME(o)->mutex);
stop(o);
join(o);
}
static MFUN(fork_join) {
- if (*(m_int *)(o->data + o_fork_done)) return;
+ if (FORK_DONE(o)) return;
if (!ME(o)->tick) return;
shred->info->me->ref++;
- vector_add(&EV_SHREDS(*(M_Object *)(o->data + o_fork_ev)), (vtype)shred);
+ vector_add(&EV_SHREDS(FORK_EV(o)), (vtype)shred);
shreduler_remove(shred->tick->shreduler, shred, false);
}
static MFUN(shred_cancel) {
if(!ME(o)->tick)return;
gwt_lock(&ME(o)->mutex);
- *(m_int *)(o->data + o_shred_cancel) = *(m_int *)MEM(SZ_INT);
+ SHRED_CANCEL(o) = *(m_int *)MEM(SZ_INT);
gwt_unlock(&ME(o)->mutex);
}
static MFUN(shred_test_cancel) {
gwt_lock(&ME(o)->mutex);
- if (*(m_int *)(o->data + o_shred_cancel)) {
+ if (SHRED_CANCEL(o)) {
gwt_unlock(&ME(o)->mutex);
vm_shred_exit(ME(o));
} else gwt_unlock(&ME(o)->mutex);
static MFUN(fork_test_cancel) {
VM *parent = ME(o)->info->vm;
gwt_lock(&parent->shreduler->mutex);
- if (*(m_int *)(o->data + o_shred_cancel)) {
+ if (SHRED_CANCEL(o)) {
gwt_unlock(&parent->shreduler->mutex);
stop(o);
join(o);
static inline int fork_running(VM *vm, const M_Object o) {
gwt_lock(&ME(o)->mutex);
- const int cancel = *(m_int *)(o->data + o_shred_cancel);
+ const int cancel = SHRED_CANCEL(o);
gwt_unlock(&ME(o)->mutex);
if(cancel)return false;
gwt_lock(&vm->shreduler->mutex);
gwion_end_child(ME(me), vm->gwion);
vm_lock(vm);
gwt_lock(&ME(me)->mutex);
- if (!*(m_int *)(me->data + o_shred_cancel) &&
+ if (!SHRED_CANCEL(me) &&
me->type_ref != vm->gwion->type[et_fork])
memcpy(me->data + vm->gwion->type[et_fork]->nspc->offset, ME(me)->reg,
((Type)vector_front(&me->type_ref->info->tuple->types))->size);
- *(m_int *)(me->data + o_fork_done) = 1;
+ FORK_DONE(me) = 1;
gwt_unlock(&ME(me)->mutex);
- if (!*(m_int *)(me->data + o_shred_cancel))
- broadcast(*(M_Object *)(me->data + o_fork_ev));
+ if (!SHRED_CANCEL(me))
+ broadcast(FORK_EV(me));
vm_unlock(vm);
THREAD_RETURN(0);
}
t_shred->nspc->offset += SZ_INT;
gwi_item_ini(gwi, "int", "cancel");
- GWI_BB((o_shred_cancel = gwi_item_end(gwi, ae_flag_const, num, 0)))
+ GWI_B(gwi_item_end(gwi, ae_flag_const, num, 0));
gwi_func_ini(gwi, "void", "exit");
GWI_B(gwi_func_end(gwi, gw_shred_exit, ae_flag_none))
const Type t_fork = gwi_class_ini(gwi, "Fork", "Shred");
gwi_class_xtor(gwi, NULL, fork_dtor);
gwi->gwion->type[et_fork] = t_fork;
- o_fork_thread = t_fork->nspc->offset;
t_fork->nspc->offset += sizeof(gwtthread_t*);
gwi_item_ini(gwi, "int", "is_done");
- GWI_BB((o_fork_done = gwi_item_end(gwi, ae_flag_const, num, 0)))
+ GWI_B(gwi_item_end(gwi, ae_flag_const, num, 0));
gwi_item_ini(gwi, "Event", "ev");
- GWI_BB((o_fork_ev = gwi_item_end(gwi, ae_flag_const, num, 0)))
+ GWI_B(gwi_item_end(gwi, ae_flag_const, num, 0));
gwi_func_ini(gwi, "void", "join");
GWI_B(gwi_func_end(gwi, fork_join, ae_flag_none))
gwi_func_ini(gwi, "void", "test_cancel");
const Type t_typed = gwi_class_ini(gwi, "TypedFork:[A]", "Fork");
gwi_item_ini(gwi, "A", "retval");
- GWI_BB(gwi_item_end(gwi, ae_flag_const, num, 0))
+ GWI_B(gwi_item_end(gwi, ae_flag_const, num, 0))
GWI_B(gwi_class_end(gwi))
SET_FLAG(t_typed, abstract | ae_flag_final);
- return GW_OK;
+ return true;
}
GWI_B(gwi_oper_ini(gwi, "Sift", "funptr", "Sift"));
GWI_B(gwi_oper_add(gwi, opck_sift));
GWI_B(gwi_oper_end(gwi, "|>", NULL));
- return GW_OK;
+ return true;
}
const Type t_string = gwi_class_ini(gwi, "string", NULL);
gwi->gwion->type[et_string] = t_string; // use func
gwi_class_xtor(gwi, string_ctor, string_dtor);
- GWI_BB(gwi_gack(gwi, t_string, gack_string))
+ GWI_B(gwi_gack(gwi, t_string, gack_string))
t_string->nspc->offset += SZ_INT;
gwi_func_ini(gwi, "int", "size");
struct SpecialId_ line_spid = {
.ck = check_linepp, .is_const = 1};
gwi_specialid(gwi, "__line__", &line_spid);
- return GW_OK;
+ return true;
}
struct ugen_importer imp_adc = {vm, adc_tick, "adc", vm->bbq->si->in};
(void)add_ugen(gwi, &imp_adc);
SET_FLAG(gwi->gwion->type[et_ugen], abstract);
- return GW_OK;
+ return true;
}
static OP_CHECK(opck_chuck_ugen) {
ANN GWION_IMPORT(union) {
const Type t_none = gwi_mk_type(gwi, "None", 0, NULL);
- GWI_BB(gwi_set_global_type(gwi, t_none, et_none))
- GWI_BB(gwi_gack(gwi, t_none, gack_none))
+ GWI_B(gwi_set_global_type(gwi, t_none, et_none))
+ GWI_B(gwi_gack(gwi, t_none, gack_none))
gwi_add_type(gwi, t_none);
struct SpecialId_ spid = {
.type = gwi->gwion->type[et_none], .exec = NoOp, .is_const = 1};
//gwi_class_xtor(gwi, NULL, UnionDtor);
gwi->gwion->type[et_union] = t_union;
- GWI_BB(gwi_item_ini(gwi, "int", "index"))
- GWI_BB(gwi_item_end(gwi, ae_flag_const, num, 0))
+ GWI_B(gwi_item_ini(gwi, "int", "index"))
+ GWI_B(gwi_item_end(gwi, ae_flag_const, num, 0))
/*
GWI_B(gwi_func_ini(gwi, "void", "@ctor"))
GWI_B(gwi_func_end(gwi, union_ctor, ae_flag_none))
GWI_B(gwi_union_add(gwi, "A", "val"))
GWI_B(gwi_union_end(gwi, ae_flag_none))
- return GW_OK;
+ return true;
}
uint32_t offset = !env->class_def ? 0 : SZ_INT;
for(uint32_t i = 0; i < unary->captures->len; i++) {
Capture *const cap = mp_vector_at(unary->captures, Capture, i);
- DECL_OO(const Type, t, = upvalue_type(env, cap));
+ DECL_O(const Type, t, = upvalue_type(env, cap));
cap->temp = new_value(env, t, cap->var.tag);
cap->temp->from->offset = offset;
offset += cap->temp->type->size;
GWI_B(gwi_oper_end(gwi, "fork", NULL))
gwi_register_freearg(gwi, SporkIni, freearg_xork);
gwi_register_freearg(gwi, fast_except, clean_fast_except);
- return GW_OK;
+ return true;
}
#include "spread.h"
#include "array.h"
-#undef ERR_B
-#define ERR_B(a, b, ...) \
- { \
- env_err(env, (a), (b), ##__VA_ARGS__); \
- return false; \
- }
-
-
ANN bool check_stmt(const Env env, Stmt*);
ANN bool check_class_def(const Env env, const Class_Def class_def);
ANN bool check_implicit(const Env env, Exp* e, const Type t) {
if (e->type == t) return true;
- if (isa(e->type, t) > 0) return true;
+ if (isa(e->type, t)) return true;
const Symbol sym = insert_symbol("@implicit");
return !!(e->cast_to = check_internal(env, sym, e, t));
}
}
} while (++depth && (e = e->next));
if (depth != array->depth)
- ERR_B(array->exp->loc, _("invalid array access expression."))
+ ERR_B(array->exp->loc, _("invalid array access expression."));
return ok;
}
ANN static inline bool inferable(const Env env, const Type t,
const loc_t loc) {
if (!tflag(t, tflag_infer)) return true;
- ERR_B(loc, _("can't infer type."))
+ ERR_B(loc, _("can't infer type."));
}
ANN Type check_exp_decl(const Env env, Exp_Decl *const decl) {
env_pop(env, scope);
set_vflag(decl->var.vd.value, vflag_direct);
}
- env_weight(env, 1 + isa(decl->type, env->gwion->type[et_object]) > 0);
+ env_weight(env, 1 + isa(decl->type, env->gwion->type[et_object]));
return ret ? decl->var.vd.value->type : NULL;
}
if (range->start) CHECK_B(check_exp(env, range->start));
if (range->end) CHECK_B(check_exp(env, range->end));
if (range->start && range->end) {
- if (isa(range->end->type, range->start->type) < 0)
- ERR_B(range->start->loc, _("range types do not match"))
+ if (!isa(range->end->type, range->start->type))
+ ERR_B(range->start->loc, _("range types do not match"));
}
return true;
}
ANN bool not_from_owner_class(const Env env, const Type t, const Value v,
const loc_t loc) {
- if (!v->from->owner_class || isa(t, v->from->owner_class) < 0) {
+ if (!v->from->owner_class || !isa(t, v->from->owner_class)) {
if(!is_class(env->gwion, v->type))
ERR_B(loc, _("'%s' from owner namespace '%s' used in '%s'."), v->name,
- v->from->owner ? v->from->owner->name : "?", t->name)
+ v->from->owner ? v->from->owner->name : "?", t->name);
}
return true;
}
return value;
}
- if (!value->from->owner_class || isa(env->class_def, value->from->owner_class) > 0)
+ if (!value->from->owner_class || isa(env->class_def, value->from->owner_class))
return value;
if(env->class_def) {
- if (isa(env->class_def, value->from->owner_class) > 0 || value == env->class_def->info->value)
+ if (isa(env->class_def, value->from->owner_class) || value == env->class_def->info->value)
return value;
}
return find_func_match_actual(env, func->next, exp, implicit,
specific);
}
- if (tflag(e->type, tflag_ref) && isa(e->type, arg->type) > 0) {
+ if (tflag(e->type, tflag_ref) && isa(e->type, arg->type)) {
if(!e->cast_to)e->cast_to = arg->type;
}
Func func;
Exp* exp = call->args;
Exp* args =
- (exp && isa(exp->type, env->gwion->type[et_void]) < 0) ? exp : NULL;
+ (exp && !isa(exp->type, env->gwion->type[et_void])) ? exp : NULL;
if ((func = find_func_match_actual(env, up, args, false, true)) ||
(func = find_func_match_actual(env, up, args, true, true)) ||
(func = find_func_match_actual(env, up, args, false, true)) ||
return;
gwerr_basic("Argument type mismatch", "call site",
"valid alternatives:", env->name, loc, 0);
- const bool is_closure = isa(t, env->gwion->type[et_closure]) < 0;
+ const bool is_closure = !isa(t, env->gwion->type[et_closure]);
Func up = is_closure
? t->info->func : closure_def(t)->base->func;
do print_signature(up);
ANN static Type check_exp_call_template(const Env env, Exp_Call *exp) {
/*const */Type t = exp->func->type;
- if(isa(t, env->gwion->type[et_closure]) > 0) {
+ if(isa(t, env->gwion->type[et_closure])) {
const Func_Def fdef = closure_def(t);
t = fdef->base->func->value_ref->type;
}
CHECK_B(check_exp(env, exp->func));
if (exp->func->exp_type == ae_exp_decl)
ERR_B(exp->func->loc, _("Can't call late function pointer at declaration "
- "site. did you meant to use `:=>`?"))
+ "site. did you meant to use `:=>`?"));
const Type t = actual_type(env->gwion, exp->func->type);
if (is_func(env->gwion, t) && exp->func->exp_type == ae_exp_dot && // is_callable
!t->info->value->from->owner_class) {
ANN Type call_type(const Env env, Exp_Call *const exp) {
const Type t = exp->func->type;
if (is_func(env->gwion, t)) return t;
- if(isa(exp->func->type, env->gwion->type[et_closure]) > 0)
+ if(isa(exp->func->type, env->gwion->type[et_closure]))
return closure_def(t)->base->func->value_ref->type;
if(is_class(env->gwion, t) && tflag(t->info->base_type, tflag_struct)) {
const Value v = nspc_lookup_value0(t->info->base_type->nspc, insert_symbol("new"));
CHECK_O(check_static(env, exp->func));
const Type _ret = _check_exp_call1(env, exp);
if(_ret) return _ret;
- if(isa(exp->func->type, env->gwion->type[et_closure]) > 0) {
+ if(isa(exp->func->type, env->gwion->type[et_closure])) {
if(exp->func->exp_type == ae_exp_dot && t->info->value->from->owner_class) {
Exp* args = exp->args;
Exp* this_arg = cpy_exp(env->gwion->mp, exp->func->d.exp_dot.base);
CHECK_O(opi.lhs);
exp_setuse(post->exp, 1);
const Type t = op_check(env, &opi);
- if (t && isa(t, env->gwion->type[et_object]) < 0)
+ if (t && !isa(t, env->gwion->type[et_object]))
exp_setmeta(exp_self(post), 1);
return t;
}
CHECK_O(func_check(env, exp, &mod));
if (mod) return exp_self(exp)->type;
Type t = actual_type(env->gwion, exp->func->type);
- if(isa(exp->func->type, env->gwion->type[et_closure]) > 0) {
+ if(isa(exp->func->type, env->gwion->type[et_closure])) {
t = typedef_base(t);
t = mp_vector_at(t->info->cdef->body, Section , 0)->d.func_def->base->func->value_ref->type;
}
ERR_O(exp_self(exp_if)->loc,
_("incompatible types '%s' and '%s' in if expression..."),
if_exp->name, else_exp->name);
- if (isa(if_exp, else_exp) < 0)
+ if (!isa(if_exp, else_exp))
ERR_O(exp_self(exp_if)->loc, _("condition type '%s' does not match '%s'"),
cond->name, ret->name);
exp_setuse(exp_if->cond, true);
const Func_Def fdef = new_func_def(env->gwion->mp, fb, code);
tdef->when_def = fdef;
CHECK_B(traverse_func_def(env, fdef));
- if (isa(when->type, env->gwion->type[et_bool]) < 0) {
+ if (!isa(when->type, env->gwion->type[et_bool])) {
char explain[strlen(when->type->name) + 20];
sprintf(explain, "found `{/+}%s{0}`", when->type->name);
gwerr_basic("Invalid `{/+}when{0}` predicate expression type", explain,
ERR_B(stmt_self(stmt)->loc,
_("empty for loop condition..."
"...(note: explicitly use 'true' if it's the intent)"
- "...(e.g., 'for(; true;){{ /*...*/ }')"))
+ "...(e.g., 'for(; true;){{ /*...*/ }')"));
return true;
}
if (is_new(env->func->def)) {
if(stmt->val)
ERR_B(stmt_self(stmt)->loc,
- _("'return' statement inside constructor function should have no expression"))
+ _("'return' statement inside constructor function should have no expression"));
return true;
}
DECL_B(const Type, ret_type,
env->func->def->base->ret_type = ret_type;
return true;
}
- if (isa(ret_type, env->func->def->base->ret_type) > 0) return true;
+ if (isa(ret_type, env->func->def->base->ret_type)) return true;
if (tflag(ret_type, tflag_noret))
ERR_B(stmt->val->loc, _("Can't use type `{+G}%s{+G}` for return"),
ret_type->name);
if (env->func->def->base->tag.sym == insert_symbol("@implicit") &&
ret_type == arg->type)
ERR_B(stmt_self(stmt)->loc,
- _("can't use implicit casting while defining it"))
+ _("can't use implicit casting while defining it"));
if (check_implicit(env, stmt->val, env->func->def->base->ret_type))
return true;
ERR_B(stmt_self(stmt)->loc,
_("invalid return type: got '%s', expected '%s'"), ret_type->name,
- env->func->def->base->ret_type->name)
+ env->func->def->base->ret_type->name);
}
- if (isa(env->func->def->base->ret_type, env->gwion->type[et_void]) > 0)
+ if (isa(env->func->def->base->ret_type, env->gwion->type[et_void]))
return true;
- ERR_B(stmt_self(stmt)->loc, _("missing value for return statement"))
+ ERR_B(stmt_self(stmt)->loc, _("missing value for return statement"));
}
-#define describe_check_stmt_stack(stack, name) \
+#define describe_check_stmt_stack(stack, name) \
ANN static bool check_stmt_##name(const Env env, const Stmt* stmt) { \
- if (!vector_size(&env->scope->stack)) \
- ERR_B(stmt->loc, _("'" #name "' found outside of for/while/until...")) \
+ if (!vector_size(&env->scope->stack)) \
+ ERR_B(stmt->loc, _("'" #name "' found outside of for/while/until...")); \
return true; \
}
describe_check_stmt_stack(conts, continue);
ANN static bool match_case_exp(const Env env, Exp* e) {
Exp* last = e;
for (m_uint i = 0; i < vector_size(&env->scope->match->cond); e = e->next, ++i) {
- if (!e) ERR_B(last->loc, _("no enough to match"))
+ if (!e) ERR_B(last->loc, _("no enough to match"));
last = e;
Exp* base = (Exp*)vector_at(&env->scope->match->cond, i);
const Symbol op = case_op(env, base->type, e);
CHECK_B(ret);
}
}
- if (e) ERR_B(e->loc, _("too many expression to match"))
+ if (e) ERR_B(e->loc, _("too many expression to match"));
return true;
}
const Func parent) {
if (GET_FLAG(parent->def->base, final))
ERR_B(fdef->base->td->tag.loc, _("can't override final function '%s'\n"),
- parent->name)
+ parent->name);
if (GET_FLAG(parent->def->base, static) != GET_FLAG(fdef->base, static)) {
const m_str c_name = fdef->base->func->value_ref->from->owner_class->name;
const m_str p_name = parent->value_ref->from->owner_class->name;
_("function '%s.%s' ressembles '%s.%s' but cannot override...\n"
" ...(reason: '%s.%s' is declared as 'static')"),
c_name, f_name, p_name, c_name,
- GET_FLAG(fdef->base, static) ? c_name : p_name, f_name)
+ GET_FLAG(fdef->base, static) ? c_name : p_name, f_name);
}
- if(fdef->base->tmpl || isa(fdef->base->ret_type, parent->def->base->ret_type) > 0)
+ if(fdef->base->tmpl || isa(fdef->base->ret_type, parent->def->base->ret_type))
return true;
gwerr_basic_from("invalid overriding", NULL, NULL, fdef->base->func->value_ref->from, 0);
gwerr_secondary_from("does not match", parent->value_ref->from);
ERR_B(f2->def->base->tag.loc,
_("global function '%s' already defined"
" for those arguments"),
- s_name(fdef->base->tag.sym))
+ s_name(fdef->base->tag.sym));
}
}
return true;
ERR_B(fdef->base->tag.loc,
_("function name '%s' conflicts with previously defined value...\n"
" from super class '%s'..."),
- s_name(fdef->base->tag.sym), override->from->owner_class->name)
+ s_name(fdef->base->tag.sym), override->from->owner_class->name);
*ov = override;
}
if (func->value_ref->from->offset &&
if (ret) {
if (env->class_def && fdef->base->effects.ptr &&
(override &&
- !check_effect_overload(&fdef->base->effects, override->d.func_ref)))
+ !check_effect_overload(&fdef->base->effects, override->d.func_ref))) {
ERR_B(fdef->base->tag.loc, _("too much effects in override."),
- s_name(fdef->base->tag.sym))
+ s_name(fdef->base->tag.sym));
+ }
if(is_new(f) && !tflag(env->class_def, tflag_struct))
CHECK_B(check_ctor(env, func));
}
}
ANN static inline bool type_is_recurs(const Type t, const Type tgt) {
- return isa(tgt, t) > 0 || isa(t, tgt) > 0 || (tgt->info->tuple && vector_find(&tgt->info->tuple->contains, (m_uint)t) > -1);
+ return isa(tgt, t) || isa(t, tgt) || (tgt->info->tuple && vector_find(&tgt->info->tuple->contains, (m_uint)t) > -1);
}
ANN static bool recursive_type_base(const Env env, const Type t);
ANN static bool var_match(const Value a, const Value b) {
bool error = true;
- if (isa(a->type, a->type) < 0) {
+ if (!isa(a->type, a->type)) {
gwerr_basic_from("invalid variable type", NULL, NULL, a->from, 0);
error = false;
}
get_tmpl(v->from->owner_class) : NULL;
if(tmpl)
(void)template_push_types(env, tmpl);
- const bool is_clos = isa(exp->func->type, env->gwion->type[et_closure]) > 0;
+ const bool is_clos = isa(exp->func->type, env->gwion->type[et_closure]);
const Func m_func = !is_clos ? func_match(env, &ra)
: fptr_match(env, &ra);
if(tmpl)
return f;
}
-#undef ERR_B
-#define ERR_B(a, b, ...) \
- { \
- env_err(env, (a), (b), ##__VA_ARGS__); \
- return false; \
- }
-
ANN static inline bool check_call(const Env env, const Exp_Call *exp) {
const ae_exp_t et = exp->func->exp_type;
if (et != ae_exp_primary && et != ae_exp_dot && et != ae_exp_cast)
if (!td->next && !td->types && op_template_type(td->tag.sym, sl))
return true;
const Type base = known_type(env, td);
- return base ? isa(t, base) > 0 : false;
+ return base ? isa(t, base) : false;
}
//! check Func_Base matches for template operator
const Func next = partial_match(env, f->next, args, loc);
if(next) {
const Type tnext = next->value_ref->from->owner_class;
- if(!t || !tnext || isa(t, tnext) < 0) {
+ if(!t || !tnext || !isa(t, tnext)) {
gwerr_basic(_("can't resolve ambiguity"), _("in this partial application"), _("use typed holes: _ $ type"), env->name, loc, 0);
gw_err(_("\nthose functions could match:\n"));
print_signature(f);
#include "spread.h"
#include "emit.h"
-#undef ERR_B
-#define ERR_B(a, b, ...) \
- { \
- env_err(env, (a), (b), ##__VA_ARGS__); \
- return false; \
- }
-
static inline void add_type(const Env env, const Nspc nspc, const Type t) {
nspc_add_type_front(nspc, insert_symbol(t->name), t);
}
*global = true;
return true;
}
- ERR_B(loc, _("can't declare as global in class def"))
+ ERR_B(loc, _("can't declare as global in class def"));
}
ANN bool scan0_fptr_def(const Env env, const Fptr_Def fptr) {
ANN static Type scan0_class_def_init(const Env env, const Class_Def cdef) {
CHECK_O(scan0_defined(env, cdef->base.tag));
DECL_O(const Type, parent, = cdef_parent(env, cdef));
- if(GET_FLAG(cdef, global) && isa(parent, env->gwion->type[et_closure]) < 0 && !type_global(env, parent)) {
+ if(GET_FLAG(cdef, global) && !isa(parent, env->gwion->type[et_closure]) && !type_global(env, parent)) {
gwerr_basic(_("parent type is not global"), NULL, NULL, env->name, cdef->base.ext ? cdef->base.ext->tag.loc : cdef->base.tag.loc, 0);
declared_here(parent->info->value);
env_set_error(env, true);
#include "instr.h"
#include "import.h"
-#undef ERR_B
-#define ERR_B(a, b, ...) \
- { \
- env_err(env, (a), (b), ##__VA_ARGS__); \
- return false; \
- }
-
ANN static bool scan1_stmt_list(const Env env, Stmt_List list);
ANN static bool scan1_stmt(const Env env, Stmt* stmt);
ANN static bool check_global(const Env env, const Type t, const loc_t loc) {
const ValueFrom *from = t->info->value->from;
- if(from->owner_class && isa(from->owner_class, env->class_def) > 0)
+ if(from->owner_class && isa(from->owner_class, env->class_def))
return true;
if(from_global_nspc(env, from->owner) ||
(from->owner_class && type_global(env, from->owner_class)))
if (decl->var.td->tag.sym == insert_symbol("auto") && decl->type) return decl->type;
if (GET_FLAG(t, private) && t->info->value->from->owner != env->curr)
ERR_O(exp_self(decl)->loc, _("can't use private type %s"), t->name);
- if (GET_FLAG(t, protect) && (!env->class_def || isa(t, env->class_def) < 0))
+ if (GET_FLAG(t, protect) && (!env->class_def || !isa(t, env->class_def)))
ERR_O(exp_self(decl)->loc, _("can't use protected type %s"), t->name);
return t;
}
env->scope->depth)
? nspc_lookup_value1
: nspc_lookup_value2)(env->curr, var->tag.sym);
- if(v && (!v->from->owner_class || isa(env->class_def, v->from->owner_class) > 0))
+ if(v && (!v->from->owner_class || isa(env->class_def, v->from->owner_class)))
ERR_B(var->tag.loc,
_("variable %s has already been defined in the same scope..."),
- s_name(var->tag.sym))
+ s_name(var->tag.sym));
return true;
}
set_vflag(v, vflag_member);
if(tflag(t, tflag_release))
set_tflag(env->class_def, tflag_release);
- if(isa(t, env->gwion->type[et_object]) > 0)
+ if(isa(t, env->gwion->type[et_object]))
set_vflag(v, vflag_release);
if (tflag(env->class_def, tflag_struct)) {
v->from->offset = env->class_def->size;
if (global) {
if (env->context) env->context->global = true;
if (!type_global(env, decl->type))
- ERR_B(exp_self(decl)->loc, _("type '%s' is not global"), decl->type->name)
+ ERR_B(exp_self(decl)->loc, _("type '%s' is not global"), decl->type->name);
}
const m_uint scope = !global ? env->scope->depth : env_push_global(env);
const bool ret = scan1_decl(env, decl);
const Value v = nspc_lookup_value0(nspc, tag.sym);
if (v && !env->func->def->builtin) {
const Type owner = v->from->owner_class;
- if (owner && env->class_def && isa(env->class_def, owner) < 0)
+ if (owner && env->class_def && !isa(env->class_def, owner))
continue;
return shadow_err(env, v, tag.loc);
}
ANN static bool scan1_stmt_return(const Env env, const Stmt_Exp stmt) {
if (!env->func)
ERR_B(stmt_self(stmt)->loc,
- _("'return' statement found outside function definition"))
+ _("'return' statement found outside function definition"));
if (env->scope->depth == 1) env->func->memoize = 1;
if(stmt->val) CHECK_B(scan1_exp(env, stmt->val));
return true;
ANN static bool class_internal(const Env env, const Func_Base *base) {
assert(base->td);
if (!env->class_def)
- ERR_B(base->td->tag.loc, _("'%s' must be in class def!!"), s_name(base->tag.sym))
+ ERR_B(base->td->tag.loc, _("'%s' must be in class def!!"), s_name(base->tag.sym));
if (base->args)
- ERR_B(base->td->tag.loc, _("'%s' must not have args"), s_name(base->tag.sym))
+ ERR_B(base->td->tag.loc, _("'%s' must not have args"), s_name(base->tag.sym));
if (base->ret_type != env->gwion->type[et_void])
- ERR_B(base->td->tag.loc, _("'%s' must return 'void'"), s_name(base->tag.sym))
+ ERR_B(base->td->tag.loc, _("'%s' must return 'void'"), s_name(base->tag.sym));
return true;
}
if (mp_vector_len(base->args) == 1) return true;
assert(base->td);
ERR_B(base->td->tag.loc, _("'%s' must have one (and only one) argument"),
- s_name(base->tag.sym))
+ s_name(base->tag.sym));
}
ANN static inline bool scan_internal_int(const Env env,
const Func_Base *base) {
assert(base->td);
CHECK_B(scan_internal_arg(env, base));
- if (isa(base->ret_type, env->gwion->type[et_int]) > 0) return true;
- ERR_B(base->td->tag.loc, _("'%s' must return 'int'"), s_name(base->tag.sym))
+ if (isa(base->ret_type, env->gwion->type[et_int])) return true;
+ ERR_B(base->td->tag.loc, _("'%s' must return 'int'"), s_name(base->tag.sym));
}
ANN static bool scan_internal(const Env env, const Func_Base *base) {
if (cdef->base.ext->array && cdef->base.ext->array->exp)
CHECK_B(scan1_exp(env, cdef->base.ext->array->exp));
DECL_B(const Type, parent, = scan1_get_parent(env, &cdef->base));
- if (isa(parent, env->gwion->type[et_object]) < 0 &&
+ if (!isa(parent, env->gwion->type[et_object]) &&
// !(tflag(cdef->base.type, tflag_cdef) || tflag(cdef->base.type, tflag_udef)))
!(tflag(cdef->base.type, tflag_cdef) || tflag(cdef->base.type, tflag_union)))
- ERR_B(loc, _("cannot extend primitive type '%s'"), parent->name)
- if (type_ref(parent)) ERR_B(loc, _("can't use ref type in class extend"))
+ ERR_B(loc, _("cannot extend primitive type '%s'"), parent->name);
+ if (type_ref(parent)) ERR_B(loc, _("can't use ref type in class extend"));
return true;
}
}
ANN static bool scan1_class_def_body(const Env env, const Class_Def cdef) {
- if(!tmpl_base(cdef->base.tmpl) && isa(cdef->base.type, env->gwion->type[et_closure]) < 0 &&
- isa(cdef->base.type, env->gwion->type[et_dict]) < 0) {
+ if(!tmpl_base(cdef->base.tmpl) && !isa(cdef->base.type, env->gwion->type[et_closure]) &&
+ !isa(cdef->base.type, env->gwion->type[et_dict])) {
MemPool mp = env->gwion->mp;
Ast base = cdef->body;
Stmt_List ctor = new_mp_vector(mp, Stmt, 0);
#include "spread.h"
#include "closure.h"
-#undef ERR_B
-#define ERR_B(a, b, ...) \
- { \
- env_err(env, (a), (b), ##__VA_ARGS__); \
- return false; \
- }
-
-
ANN static bool scan2_stmt(const Env, Stmt*);
ANN static bool scan2_stmt_list(const Env, Stmt_List);
if (!fbflag(f->base, fbflag_internal))
ERR_B(f->base->tag.loc,
_("function name '%s' is already used by another value"),
- overload->name)
+ overload->name);
}
const Func obase = overload->d.func_ref;
if (GET_FLAG(obase->def->base, final) && (!env->class_def || (obase->value_ref->from->owner_class != env->class_def))) {
const bool base = tmpl_base(f->base->tmpl);
const bool tmpl = fflag(obase, fflag_tmpl);
if ((!tmpl && base) || (tmpl && !base && !f->base->tmpl))
- ERR_B(f->base->tag.loc, _("must overload template function with template"))
+ ERR_B(f->base->tag.loc, _("must overload template function with template"));
if (GET_FLAG(f->base, global) != GET_FLAG(obase->def->base, global))
- ERR_B(f->base->tag.loc, _("function is declared global")) // improve me
+ ERR_B(f->base->tag.loc, _("function is declared global")); // improve me
return true;
}
ERR_B(f->base->tag.loc,
"template function '%s' already defined with those arguments "
"in this namespace",
- name)
+ name);
const Symbol sym =
func_symbol(env, env->curr->name, name, "template", ff->def->vt_index);
nspc_add_value(env->curr, sym, value);
CHECK_B(check_exp(env, targ->d.exp));
// check implicits?
const Type target = known_type(env, spec->td);
- if(isa(targ->d.exp->type, target) < 0) {
+ if(!isa(targ->d.exp->type, target)) {
char msg[256];
tcol_snprintf(msg, 255, "expected {G+}%s{0}", target->name);
gwerr_basic("invalid type for const generic argument", msg, NULL, env->name, spec->tag.loc, 0);
return !strcmp(s_name(spec->tag.sym), "...");
}
-#undef ERR_B
-#define ERR_B(a, b, ...) \
- { \
- env_err(env, (a), (b), ##__VA_ARGS__); \
- return false; \
- }
-
-
ANN2(1,2) bool check_tmpl(const Env env, const TmplArg_List tl, const Specialized_List sl, const loc_t loc, const bool is_spread) {
if (!sl || sl->len > tl->len || (tl->len != sl->len && !is_spread))
ERR_B(loc, "invalid template type number");
/*
if(!strcmp(name, "none")) {
vector_clear(v);
- return GW_OK;
+ return true;
}
*/
gw_err("Failed to set compilation passes, back to default\n");
env_err(env, loc, "%s: no such plugin\n", iname);
return false;
}
- return GW_OK;
+ return true;
}
ANN gwdriver_t driver_ini(const struct Gwion_ *gwion, struct SoundInfo_ *si) {
#include "import.h"
#include "gack.h"
-ANN2(1) static int fmtlen(const char *fmt, va_list args) {
+ANN2(1) static ssize_t fmtlen(const char *fmt, va_list args) {
va_list tmpa;
va_copy(tmpa, args);
const int size = vsnprintf(NULL, 0, fmt, tmpa);
static int gw_vasprintf(MemPool mp, char **str, const char *fmt, va_list args) {
char * base = *str;
const size_t base_len = base ? strlen(base) : 0;
- DECL_BB(const int, size, = fmtlen(fmt, args));
+ const int size = fmtlen(fmt, args);
+ if(size < 0) return -1;
char *ret = mp_malloc2(mp, base_len + size + 1);
if (base) strcpy(ret, base);
const int final_len = vsprintf(ret + base_len, fmt, args);
GWION_IMPORT(non_driver) {
(void)gwi;
- return GW_OK;
+ return true;
}
GWMODEND(get_module) { puts(__func__); }
GWION_IMPORT(get_module) {
- CHECK_b(set_module(gwi->gwion, "get_module", (void *)1));
- GWI_OB(get_module(gwi->gwion, "get_module"))
+ CHECK_B(set_module(gwi->gwion, "get_module", (void *)1));
+ GWI_B(get_module(gwi->gwion, "get_module"))
puts("test passed");
get_module(gwi->gwion, "non_existant_module");
- return GW_OK;
+ return true;
}
MFUN(test_mfun) {}
GWION_IMPORT(array) {
- GWI_OB(gwi_class_ini(gwi, "ArrayTest", NULL))
- GWI_BB(gwi_item_ini(gwi, "int[]", "int_array"))
- GWI_BB(gwi_item_end(gwi, 0, obj, NULL)) // import array var
+ GWI_B(gwi_class_ini(gwi, "ArrayTest", NULL))
+ GWI_B(gwi_item_ini(gwi, "int[]", "int_array"))
+ GWI_B(gwi_item_end(gwi, 0, obj, NULL)) // import array var
GWI_B(gwi_func_ini(gwi, "float[][]", "f"))
GWI_B(gwi_func_end(gwi, test_mfun, ae_flag_none))
GWI_B(gwi_func_ini(gwi, "float[][]", "g"))
GWI_B(gwi_func_end(gwi, test_mfun, ae_flag_none))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
GWION_IMPORT(array_in_var_name) {
gwi_item_ini(gwi, "int", "array[2][3]");
- return GW_OK;
+ return true;
}
GWION_IMPORT(array_in_var_name_fail) {
GWI_B(gwi_union_ini(gwi, "U"))
GWI_B(gwi_union_add(gwi, "int", "i"))
- return GW_OK;
+ return true;
}
GWION_IMPORT(array_incoherent_in_var_name) {
gwi_item_ini(gwi, "int", "array[2][3][]");
- return GW_OK;
+ return true;
}
GWION_IMPORT(array_invalid_in_var_name) {
gwi_item_ini(gwi, "int", "array[.]");
- return GW_OK;
+ return true;
}
GWION_IMPORT(callback) {
GWI_B(gwi_fptr_ini(gwi, "Vec4", "PtrType"))
- GWI_OB(gwi_fptr_end(gwi, 0))
+ GWI_B(gwi_fptr_end(gwi, 0))
- GWI_OB(gwi_class_ini(gwi, "Callback", NULL))
+ GWI_B(gwi_class_ini(gwi, "Callback", NULL))
GWI_B(gwi_func_ini(gwi, "int", "callback"))
GWI_B(gwi_func_arg(gwi, "PtrType", "func"))
GWI_B(gwi_func_end(gwi, cb_func, ae_flag_static))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
#include "import.h"
#include "gwi.h"
-static m_int o_map_key;
-static m_int o_map_value;
-#define MAP_KEY(a) *((M_Object *)(a->data + o_map_key))
-#define MAP_VAL(a) *((M_Object *)(a->data + o_map_value))
static CTOR(class_template_ctor) {
/*char* name = strdup(o->type_ref->name);*/
/*char* tmp = strsep(&name, "@");*/
}
GWION_IMPORT(class_template) {
- GWI_OB(gwi_class_ini(gwi, ":[A,B]ClassTemplate", NULL))
+ GWI_B(gwi_class_ini(gwi, ":[A,B]ClassTemplate", NULL));
gwi_class_xtor(gwi, class_template_ctor, NULL);
- GWI_BB(gwi_item_ini(gwi, "A[]", "key"))
- GWI_BB((o_map_key = gwi_item_end(gwi, ae_flag_none, obj, NULL)))
- GWI_BB(gwi_item_ini(gwi, "B[]", "value"))
- GWI_BB((o_map_value = gwi_item_end(gwi, ae_flag_none, obj, NULL)))
- GWI_B(gwi_func_ini(gwi, "int", ":[C,D]test"))
- GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
+ GWI_B(gwi_item_ini(gwi, "A[]", "key"));
+ GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL));
+ GWI_B(gwi_item_ini(gwi, "B[]", "value"));
+ GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL));
+ GWI_B(gwi_func_ini(gwi, "int", ":[C,D]test"));
+ GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none));
- GWI_B(gwi_class_end(gwi))
- GWI_BB(gwi_item_ini(gwi, ":[:[int]Ptr,int[]]ClassTemplate", "testObject"))
- GWI_BB(gwi_item_end(gwi, ae_flag_none, obj, NULL))
- return GW_OK;
+ GWI_B(gwi_class_end(gwi));
+ GWI_B(gwi_item_ini(gwi, ":[:[int]Ptr,int[]]ClassTemplate", "testObject"));
+ GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL));
+ return true;
}
#include "gwi.h"
GWION_IMPORT(class_template_fail) {
- GWI_OB(gwi_class_ini(gwi, ":[A,B]ClassTemplate", NULL))
+ GWI_B(gwi_class_ini(gwi, ":[A,B]ClassTemplate", NULL))
GWI_B(gwi_func_ini(gwi, "int", "test"))
GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
#include "import.h"
#include "gwi.h"
-static m_int o_map_key;
-static m_int o_map_value;
-#define MAP_KEY(a) *((M_Object *)(a->data + o_map_key))
-#define MAP_VAL(a) *((M_Object *)(a->data + o_map_value))
-
GWION_IMPORT(class_template_invalid) {
- GWI_OB(gwi_class_ini(gwi, "ClassTemplate:[A,B]", NULL))
- GWI_BB(gwi_item_ini(gwi, "A[]", "key"))
- GWI_BB((o_map_key = gwi_item_end(gwi, ae_flag_none, obj, NULL)))
- GWI_BB(gwi_item_ini(gwi, "B[]", "value"))
- GWI_BB((o_map_value = gwi_item_end(gwi, ae_flag_none, obj, NULL)))
- GWI_B(gwi_func_ini(gwi, "int", "test:[C,D]"))
- GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
+ GWI_B(gwi_class_ini(gwi, "ClassTemplate:[A,B]", NULL));
+ GWI_B(gwi_item_ini(gwi, "A[]", "key"));
+ GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL));
+ GWI_B(gwi_item_ini(gwi, "B[]", "value"));
+ GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL));
+ GWI_B(gwi_func_ini(gwi, "int", "test:[C,D]"));
+ GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none));
- GWI_B(gwi_class_end(gwi))
- GWI_BB(gwi_item_ini(gwi, "ClassTemplate:[:[int]Ptr,int[]]", "testObject"))
- GWI_BB(gwi_item_end(gwi, ae_flag_none, obj, NULL))
- return GW_OK;
+ GWI_B(gwi_class_end(gwi));
+ GWI_B(gwi_item_ini(gwi, "ClassTemplate:[:[int]Ptr,int[]]", "testObject"));
+ GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL));
+ return true;
}
#include <string.h>
GWION_IMPORT(compile_file) {
- DECL_OB(FILE *, file, = fopen("rm_me.gw", "w+"));
+ DECL_B(FILE *, file, = fopen("rm_me.gw", "w+"));
if(fprintf(file, "1;") >= 0) {
rewind(file);
const bool ret = compile_file(gwi->gwion, __FILE__, file);
SFUN(coverage_float) { *(m_float *)RETURN = 0; }
GWION_IMPORT(coverage) {
- GWI_OB(gwi_class_ini(gwi, "Coverage", NULL))
+ GWI_B(gwi_class_ini(gwi, "Coverage", NULL))
GWI_B(gwi_func_ini(gwi, "int", "i"))
GWI_B(gwi_func_end(gwi, coverage_int, ae_flag_static))
GWI_B(gwi_func_ini(gwi, "float", "f"))
GWI_B(gwi_func_end(gwi, coverage_float, ae_flag_static))
- GWI_BB(gwi_item_ini(gwi, "int", "s_i"))
- GWI_BB(gwi_item_end(gwi, ae_flag_static, num, 5))
+ GWI_B(gwi_item_ini(gwi, "int", "s_i"))
+ GWI_B(gwi_item_end(gwi, ae_flag_static, num, 5))
- GWI_BB(gwi_item_ini(gwi, "float", "s_f"))
- GWI_BB(gwi_item_end(gwi, ae_flag_static, fnum, 2.1))
+ GWI_B(gwi_item_ini(gwi, "float", "s_f"))
+ GWI_B(gwi_item_end(gwi, ae_flag_static, fnum, 2.1))
- GWI_BB(gwi_item_ini(gwi, "int", "sc_i"))
- GWI_BB(gwi_item_end(gwi, ae_flag_static | ae_flag_const, num, 5))
+ GWI_B(gwi_item_ini(gwi, "int", "sc_i"))
+ GWI_B(gwi_item_end(gwi, ae_flag_static | ae_flag_const, num, 5))
- GWI_BB(gwi_item_ini(gwi, "float", "sc_f"))
- GWI_BB(gwi_item_end(gwi, ae_flag_static | ae_flag_const, fnum, 2.1))
+ GWI_B(gwi_item_ini(gwi, "float", "sc_f"))
+ GWI_B(gwi_item_end(gwi, ae_flag_static | ae_flag_const, fnum, 2.1))
- GWI_BB(gwi_item_ini(gwi, "int[][]", "test_array"))
- GWI_BB(gwi_item_end(gwi, ae_flag_none, obj, NULL))
+ GWI_B(gwi_item_ini(gwi, "int[][]", "test_array"))
+ GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
GWION_IMPORT(deps) {
(void)gwi;
- return GW_OK;
+ return true;
}
static const m_str deps[] = {"array", NULL};
GWION_IMPORT(empty_union) {
GWI_B(gwi_union_ini(gwi, "U"))
GWI_B(gwi_union_end(gwi, 0))
- return GW_OK;
+ return true;
}
MFUN(test_mfun) {}
GWION_IMPORT(end_class) {
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
GWI_B(gwi_enum_add(gwi, "TYPED_ENUM7", 7))
GWI_B(gwi_enum_add(gwi, "TYPED_ENUM8", 8))
GWI_B(gwi_enum_add(gwi, "TYPED_ENUM9", 9))
- GWI_OB(gwi_enum_end(gwi))
+ GWI_B(gwi_enum_end(gwi))
- GWI_OB(gwi_class_end(gwi))
+ GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
GWION_IMPORT(enum_fail) {
GWI_B(gwi_enum_ini(gwi, "int"))
GWI_B(gwi_enum_add(gwi, "zero", 0))
- GWI_OB(gwi_enum_end(gwi))
- return GW_OK;
+ GWI_B(gwi_enum_end(gwi))
+ return true;
}
GWION_IMPORT(enum_fail2) {
GWI_B(gwi_enum_ini(gwi, "tmp"))
GWI_B(gwi_enum_add(gwi, "adc", 0))
- GWI_OB(gwi_enum_end(gwi))
- return GW_OK;
+ GWI_B(gwi_enum_end(gwi))
+ return true;
}
GWI_B(gwi_enum_ini(gwi, "test"))
GWI_B(gwi_enum_add(gwi, "adc", 0))
GWI_B(gwi_enum_ini(gwi, "error"))
- return GW_OK;
+ return true;
}
#include "gwi.h"
GWION_IMPORT(extend_array) {
- GWI_OB(gwi_class_ini(gwi, "ArrayExt", "float[1]"))
+ GWI_B(gwi_class_ini(gwi, "ArrayExt", "float[1]"))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
static MFUN(test_func) { puts("test"); }
GWION_IMPORT(fptr) {
GWI_B(gwi_fptr_ini(gwi, "void", "PtrType"))
- GWI_OB(gwi_fptr_end(gwi, 0))
+ GWI_B(gwi_fptr_end(gwi, 0))
- GWI_OB(gwi_class_ini(gwi, "FuncTypedef", NULL))
+ GWI_B(gwi_class_ini(gwi, "FuncTypedef", NULL))
GWI_B(gwi_fptr_ini(gwi, "void", "PtrType"))
- GWI_OB(gwi_fptr_end(gwi, ae_flag_static))
+ GWI_B(gwi_fptr_end(gwi, ae_flag_static))
GWI_B(gwi_func_ini(gwi, "void", "test_func"))
GWI_B(gwi_func_end(gwi, test_func, ae_flag_static))
- GWI_BB(gwi_item_ini(gwi, "PtrType", "ptr"))
- GWI_BB(gwi_item_end(gwi, ae_flag_static, obj, NULL))
+ GWI_B(gwi_item_ini(gwi, "PtrType", "ptr"))
+ GWI_B(gwi_item_end(gwi, ae_flag_static, obj, NULL))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
GWION_IMPORT(fptr_tmpl) {
Type t_func_typedef;
- GWI_OB((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT, NULL)))
+ GWI_B((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT, NULL)))
GWI_B(gwi_fptr_ini(gwi, "int", "test:[test]"))
- GWI_OB(gwi_fptr_end(gwi, 0))
- return GW_OK;
+ GWI_B(gwi_fptr_end(gwi, 0))
+ return true;
}
GWION_IMPORT(fptr_tmpl_fail) {
GWI_B(gwi_fptr_ini(gwi, "int~", "test:[A]"))
- GWI_OB(gwi_fptr_end(gwi, 0))
- return GW_OK;
+ GWI_B(gwi_fptr_end(gwi, 0))
+ return true;
}
GWI_B(gwi_func_arg(gwi, "int", "i[][]"))
GWI_B(gwi_func_arg(gwi, "Int", "i"))
GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
- return GW_OK;
+ return true;
}
GWI_B(gwi_func_arg(gwi, "int", "i[][]"))
GWI_B(gwi_func_arg(gwi, "int", "me"))
GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
- return GW_OK;
+ return true;
}
GWI_B(gwi_func_ini(gwi, "int", "test"))
GWI_B(gwi_func_arg(gwi, "int", "i[][]"))
GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
- return GW_OK;
+ return true;
}
GWION_IMPORT(func_fail4) {
GWI_B(gwi_func_ini(gwi, "Ptr:[int]", "test:[A]"))
GWI_B(gwi_func_arg(gwi, "int", "i[][]"))
- GWI_BB(gwi_item_end(gwi, ae_flag_none, num, 0))
- return GW_OK;
+ GWI_B(gwi_item_end(gwi, ae_flag_none, num, 0))
+ return true;
}
GWION_IMPORT(func_subscript_not_empty) {
GWI_B(gwi_func_ini(gwi, "int[]", "test"))
GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
- return GW_OK;
+ return true;
}
GWI_B(gwi_func_ini(gwi, "int", "test:[A]"))
GWI_B(gwi_func_arg(gwi, "A", "i"))
GWI_B(gwi_func_end(gwi, func_tmpl_xfun, ae_flag_none))
- return GW_OK;
+ return true;
}
GWION_IMPORT(func_tmpl_fail) {
GWI_B(gwi_func_ini(gwi, "voit", "test:[A]"))
GWI_B(gwi_func_end(gwi, func_tmpl_xfun, ae_flag_none))
- return GW_OK;
+ return true;
}
GWI_B(gwi_func_arg(gwi, "int", "y"))
GWI_B(gwi_func_arg(gwi, "int", "z"))
GWI_B(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
- return GW_OK;
+ return true;
}
GWI_B(gwi_func_ini(gwi, "int", "test"))
GWI_B(gwi_func_arg(gwi, "int", "i"))
GWI_B(gwi_func_end(gwi, coverage_int, ae_flag_none))
- return GW_OK;
+ return true;
}
const M_Object o =
new_object(gwi->gwion->mp, gwi->gwion->type[et_string]);
STRING(o) = s_name(insert_symbol(gwi->gwion->st, "test"));
- GWI_BB(gwi_item_ini(gwi, "string", "i"))
- GWI_BB(gwi_item_end(gwi, 0, obj, o))
- GWI_BB(gwi_item_ini(gwi, "float", "f"))
- GWI_BB(gwi_item_end(gwi, 0, fnum, 2.1))
- return GW_OK;
+ GWI_B(gwi_item_ini(gwi, "string", "i"))
+ GWI_B(gwi_item_end(gwi, 0, obj, o))
+ GWI_B(gwi_item_ini(gwi, "float", "f"))
+ GWI_B(gwi_item_end(gwi, 0, fnum, 2.1))
+ return true;
}
static MFUN(test_mfun) {}
GWION_IMPORT(invalid_arg) {
- GWI_OB(gwi_class_ini(gwi, "InvalidArg", NULL))
+ GWI_B(gwi_class_ini(gwi, "InvalidArg", NULL))
GWI_B(gwi_func_ini(gwi, "int[]", "func"))
GWI_B(gwi_func_arg(gwi, ".int", "i"))
GWI_B(gwi_func_end(gwi, test_mfun, ae_flag_static))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
static MFUN(test_mfun) {}
GWION_IMPORT(invalid_array) {
- GWI_OB(gwi_class_ini(gwi, "InvalidArray", NULL))
+ GWI_B(gwi_class_ini(gwi, "InvalidArray", NULL))
GWI_B(gwi_func_ini(gwi, "int[]", "func"))
GWI_B(gwi_func_arg(gwi, "int[][]", "i"))
GWI_B(gwi_func_arg(gwi, "int", "j[]"))
GWI_B(gwi_func_end(gwi, test_mfun, ae_flag_static))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
static MFUN(test_mfun) {}
GWION_IMPORT(invalid_func) {
- GWI_OB(gwi_class_ini(gwi, "t_invalid_var_type", NULL))
+ GWI_B(gwi_class_ini(gwi, "t_invalid_var_type", NULL))
GWI_B(gwi_func_ini(gwi, ".int", "i"))
GWI_B(gwi_func_end(gwi, test_mfun, ae_flag_static))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
#include "gwi.h"
GWION_IMPORT(invalid_names) {
- DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T~", SZ_INT, NULL));
+ DECL_B(const Type, t0, = gwi_mk_type(gwi, "T~", SZ_INT, NULL));
gwi_add_type(gwi, t0);
const Type t1 = gwi_mk_type(gwi, "T,", SZ_INT, NULL);
const Type t3 = gwi_mk_type(gwi, "T:[a]", SZ_INT, NULL);
gwi_add_type(gwi, t3);
- return GW_OK;
+ return true;
}
#include "gwi.h"
GWION_IMPORT(invalid_names0) {
- DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T~", SZ_INT, NULL));
+ DECL_B(const Type, t0, = gwi_mk_type(gwi, "T~", SZ_INT, NULL));
gwi_add_type(gwi, t0);
- return GW_OK;
+ return true;
}
#include "gwi.h"
GWION_IMPORT(invalid_names1) {
- DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T,", SZ_INT, NULL));
+ DECL_B(const Type, t0, = gwi_mk_type(gwi, "T,", SZ_INT, NULL));
gwi_add_type(gwi, t0);
- return GW_OK;
+ return true;
}
#include "gwi.h"
GWION_IMPORT(invalid_names2) {
- DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T<a>", SZ_INT, NULL));
+ DECL_B(const Type, t0, = gwi_mk_type(gwi, "T<a>", SZ_INT, NULL));
gwi_add_type(gwi, t0);
- return GW_OK;
+ return true;
}
#include "gwi.h"
GWION_IMPORT(invalid_names3) {
- DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T:[a]", SZ_INT, NULL));
+ DECL_B(const Type, t0, = gwi_mk_type(gwi, "T:[a]", SZ_INT, NULL));
gwi_add_type(gwi, t0);
- return GW_OK;
+ return true;
}
#include "import.h"
GWION_IMPORT(invalid_type1) {
- GWI_OB(gwi_class_ini(gwi, "invalid_var_type", NULL))
- GWI_BB(gwi_item_ini(gwi, "i|nt", "test"))
- GWI_BB(gwi_item_end(gwi, 0, num, 0))
+ GWI_B(gwi_class_ini(gwi, "invalid_var_type", NULL))
+ GWI_B(gwi_item_ini(gwi, "i|nt", "test"))
+ GWI_B(gwi_item_end(gwi, 0, num, 0))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
#include "import.h"
GWION_IMPORT(invalid_type2) {
- GWI_OB(gwi_class_ini(gwi, "invalid_var_type", NULL))
- GWI_BB(gwi_item_ini(gwi, ".int", "test"))
- GWI_BB(gwi_item_end(gwi, 0, num, 0))
+ GWI_B(gwi_class_ini(gwi, "invalid_var_type", NULL))
+ GWI_B(gwi_item_ini(gwi, ".int", "test"))
+ GWI_B(gwi_item_end(gwi, 0, num, 0))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
#include "import.h"
GWION_IMPORT(invalid_type3) {
- GWI_OB(gwi_class_ini(gwi, "InvalidVarType", NULL))
- GWI_BB(gwi_item_ini(gwi, ".int", "test"))
- GWI_BB(gwi_item_end(gwi, 0, num, 0))
+ GWI_B(gwi_class_ini(gwi, "InvalidVarType", NULL))
+ GWI_B(gwi_item_ini(gwi, ".int", "test"))
+ GWI_B(gwi_item_end(gwi, 0, num, 0))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
MFUN(test_mfun) {}
GWION_IMPORT(mk_type_array) {
Type t_invalid_var_name;
- GWI_OB((t_invalid_var_name =
+ GWI_B((t_invalid_var_name =
gwi_mk_type(gwi, "invalid_var_name", SZ_INT, "Object[]")))
- return GW_OK;
+ return true;
}
GWION_IMPORT(not_importing) {
GWI_B(gwi_enum_add(gwi, "adc", 0))
- return GW_OK;
+ return true;
}
GWION_IMPORT(pass) {
gwi_register_pass(gwi, "dummy", pass);
- return GW_OK;
+ return true;
}
struct SpecialId_ spid = {
.type = gwi->gwion->type[et_int], .em = spidem, .is_const = 1};
gwi_specialid(gwi, "testid", &spid);
- return GW_OK;
+ return true;
}
const M_Object o =
new_object(gwi->gwion->mp, gwi->gwion->type[et_string]);
STRING(o) = s_name(insert_symbol(gwi->gwion->st, "test static string"));
- GWI_BB(gwi_item_ini(gwi, "string", "self"))
- GWI_BB(gwi_item_end(gwi, ae_flag_global, obj, o))
- return GW_OK;
+ GWI_B(gwi_item_ini(gwi, "string", "self"))
+ GWI_B(gwi_item_end(gwi, ae_flag_global, obj, o))
+ return true;
}
#include "gwi.h"
GWION_IMPORT(str2decl) {
- GWI_OB(gwi_class_ini(gwi, "Test", NULL))
- GWI_OB(gwi_class_ini(gwi, "Child", NULL))
+ GWI_B(gwi_class_ini(gwi, "Test", NULL))
+ GWI_B(gwi_class_ini(gwi, "Child", NULL))
GWI_B(gwi_class_end(gwi))
GWI_B(gwi_class_end(gwi))
- GWI_OB(gwi_class_ini(gwi, "Test2", "Test.Child"))
+ GWI_B(gwi_class_ini(gwi, "Test2", "Test.Child"))
return gwi_class_end(gwi);
}
#include "gwi.h"
GWION_IMPORT(str2list_fail) {
- GWI_BB(gwi_item_ini(gwi, "SoemClass.child", "i"))
- GWI_BB(gwi_item_end(gwi, ae_flag_none, num, 0))
- return GW_OK;
+ GWI_B(gwi_item_ini(gwi, "SoemClass.child", "i"))
+ GWI_B(gwi_item_end(gwi, ae_flag_none, num, 0))
+ return true;
}
SFUN(coverage_float) { *(m_float *)RETURN = 0; }
GWION_IMPORT(struct) {
- GWI_OB(gwi_struct_ini(gwi, "Struct"))
+ GWI_B(gwi_struct_ini(gwi, "Struct"))
GWI_B(gwi_func_ini(gwi, "int", "i"))
GWI_B(gwi_func_end(gwi, coverage_int, ae_flag_static))
GWI_B(gwi_func_ini(gwi, "float", "f"))
GWI_B(gwi_func_end(gwi, coverage_float, ae_flag_static))
- GWI_BB(gwi_item_end(gwi, ae_flag_static, num, 5))
+ GWI_B(gwi_item_end(gwi, ae_flag_static, num, 5))
- GWI_BB(gwi_item_ini(gwi, "int", "s_f"))
- GWI_BB(gwi_item_end(gwi, ae_flag_static, fnum, 2.1))
+ GWI_B(gwi_item_ini(gwi, "int", "s_f"))
+ GWI_B(gwi_item_end(gwi, ae_flag_static, fnum, 2.1))
- GWI_BB(gwi_item_ini(gwi, "int", "sc_i"))
- GWI_BB(gwi_item_end(gwi, ae_flag_static | ae_flag_const, num, 5))
+ GWI_B(gwi_item_ini(gwi, "int", "sc_i"))
+ GWI_B(gwi_item_end(gwi, ae_flag_static | ae_flag_const, num, 5))
- GWI_BB(gwi_item_ini(gwi, "float", "sc_f"))
- GWI_BB(gwi_item_end(gwi, ae_flag_static | ae_flag_const, fnum, 2.1))
+ GWI_B(gwi_item_ini(gwi, "float", "sc_f"))
+ GWI_B(gwi_item_end(gwi, ae_flag_static | ae_flag_const, fnum, 2.1))
- GWI_BB(gwi_item_ini(gwi, "int[][]", "test_array"))
- GWI_BB(gwi_item_end(gwi, ae_flag_none, obj, NULL))
+ GWI_B(gwi_item_ini(gwi, "int[][]", "test_array"))
+ GWI_B(gwi_item_end(gwi, ae_flag_none, obj, NULL))
GWI_B(gwi_struct_end(gwi))
- return GW_OK;
+ return true;
}
static MFUN(template_arg_fun) {}
GWION_IMPORT(template_arg) {
- GWI_OB(gwi_class_ini(gwi, "TemplateArg", NULL))
+ GWI_B(gwi_class_ini(gwi, "TemplateArg", NULL))
GWI_B(gwi_func_ini(gwi, "int", "set"))
GWI_B(gwi_func_arg(gwi, "Pair<Ptr<int>,float>", "test"))
GWI_B(gwi_func_end(gwi, template_arg_fun, ae_flag_none))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
}
GWION_IMPORT(trig) {
- GWI_OB(gwi_class_ini(gwi, "Trig", "UGen"))
+ GWI_B(gwi_class_ini(gwi, "Trig", "UGen"))
gwi_class_xtor(gwi, trig_ctor, NULL);
gwi_class_end(gwi);
- GWI_OB(gwi_class_ini(gwi, "Trig2", "UGen"))
+ GWI_B(gwi_class_ini(gwi, "Trig2", "UGen"))
gwi_class_xtor(gwi, trig2_ctor, NULL);
return gwi_class_end(gwi);
}
#include "import.h"
GWION_IMPORT(typedef) {
- GWI_OB(gwi_typedef_ini(gwi, "int", "Typedef"))
- GWI_OB(gwi_typedef_end(gwi, ae_flag_none))
- return GW_OK;
+ GWI_B(gwi_typedef_ini(gwi, "int", "Typedef"))
+ GWI_B(gwi_typedef_end(gwi, ae_flag_none))
+ return true;
}
GWION_IMPORT(typedef_fail) {
GWI_B(gwi_typedef_ini(gwi, "int", "Typedef:[A]"))
GWI_B(gwi_typedef_ini(gwi, "int", "Typedef:[A]"))
- return GW_OK;
+ return true;
}
GWION_IMPORT(typedef_tmpl) {
GWI_B(gwi_typedef_ini(gwi, "Ptr:[A]", "Typedef:[A]"))
- GWI_OB(gwi_typedef_end(gwi, ae_flag_none))
- return GW_OK;
+ GWI_B(gwi_typedef_end(gwi, ae_flag_none))
+ return true;
}
const UGen ug1 = (UGen)vector_at(&gwi->gwion->vm->ugen, 1);
ugen_connect(ug0, ug1);
ugen_disconnect(ug0, ug1);
- return GW_OK;
+ return true;
}
GWI_B(gwi_union_add(gwi, "float", "f"))
GWI_B(gwi_union_add(gwi, "int", "i"))
GWI_B(gwi_union_end(gwi, 0))
- return GW_OK;
+ return true;
}
GWI_B(gwi_union_add(gwi, "Float", "f"))
GWI_B(gwi_union_add(gwi, "int", "i"))
GWI_B(gwi_union_end(gwi, 0))
- return GW_OK;
+ return true;
}
#include "import.h"
GWION_IMPORT(union_member) {
- GWI_OB(gwi_class_ini(gwi, "UnionMember", NULL))
+ GWI_B(gwi_class_ini(gwi, "UnionMember", NULL))
GWI_B(gwi_union_ini(gwi, "U"))
GWI_B(gwi_union_add(gwi, "float", "f"))
GWI_B(gwi_union_add(gwi, "int[]", "array"))
GWI_B(gwi_union_end(gwi, ae_flag_none))
GWI_B(gwi_class_end(gwi))
- return GW_OK;
+ return true;
}
GWI_B(gwi_union_add(gwi, "float", "f"))
GWI_B(gwi_union_add(gwi, "int", "i"))
GWI_B(gwi_union_end(gwi, 0))
- return GW_OK;
+ return true;
}
GWI_B(gwi_union_add(gwi, "int", "i"))
GWI_B(gwi_union_add(gwi, "A", "a"))
GWI_B(gwi_union_end(gwi, 0))
- return GW_OK;
+ return true;
}
GWI_B(gwi_union_add(gwi, "int", "i"))
GWI_B(gwi_union_add(gwi, "A", "a"))
GWI_B(gwi_union_end(gwi, 0))
- return GW_OK;
+ return true;
}
GWI_B(gwi_union_add(gwi, "A", "a"))
GWI_B(gwi_union_ini(gwi, "U:[A]"))
GWI_B(gwi_union_end(gwi, 0))
- return GW_OK;
+ return true;
}
GWI_B(gwi_union_add(gwi, "int", "i"))
GWI_B(gwi_union_add(gwi, "A", "a"))
GWI_B(gwi_union_end(gwi, 0))
- return GW_OK;
+ return true;
}
GWI_B(gwi_func_ini(gwi, "int", "test"))
GWI_B(gwi_func_arg(gwi, "int", "i"))
GWI_B(gwi_func_end(gwi, coverage_int, ae_flag_none))
- return GW_OK;
+ return true;
}
-Subproject commit 373c31f93cc54f6dd0f04dee5b685bb8f73d4a88
+Subproject commit 40579aff6f25a637d6d0da8032700e85b1611cb0