enum COLOR color;
} CliArg;
-ANN void arg_release(CliArg *);
-ANN m_bool arg_parse(const Gwion, CliArg *);
-ANN void arg_compile(const Gwion, CliArg *);
+ANN void arg_release(CliArg *);
+ANN bool arg_parse(const Gwion, CliArg *);
+ANN void arg_compile(const Gwion, CliArg *);
#endif
ANN Type check_array_access(const Env env, const Array_Sub array);
ANN m_bool emit_array_access(const Emitter emit,
struct ArrayAccessInfo *const info);
-ANN2(1,2) m_bool check_array_instance(const Env env, Type_Decl *td, Exp* args);
+ANN2(1,2) bool check_array_instance(const Env env, Type_Decl *td, Exp* args);
#endif
ANN void free_emitter(MemPool, Emitter);
ANN m_bool emit_ast(const Env env, Ast *ast);
ANN m_bool emit_func_def(const Emitter emit, const Func_Def fdef);
-ANN m_bool emit_exp_call1(const Emitter, const Func, const m_uint size, const bool is_static);
+ANN m_bool emit_exp(const Emitter, Exp*);
+ANN bool emit_exp_call1(const Emitter, const Func, const m_uint size, const bool is_static);
ANN2(1)
Instr emit_add_instr(const Emitter, const f_instr)
__attribute__((returns_nonnull));
ANN Code * emit_class_code(const Emitter, const m_str);
-ANN m_bool emit_array_extend(const Emitter, const Type, Exp*);
-ANN void emit_class_finish(const Emitter, const Nspc);
ANN2(1, 2)
-m_bool emit_instantiate_object(const Emitter, const Type, const Array_Sub,
- const m_bool);
+bool emit_instantiate_object(const Emitter, const Type, const Array_Sub,
+ const bool);
ANN m_uint emit_code_offset(const Emitter emit);
ANN m_uint emit_local(const Emitter emit, const Type t);
ANN m_uint emit_localn(const Emitter emit, const Type t);
ANN void* emit_localx(const Emitter emit, const Type t);
ANN m_uint emit_local_exp(const Emitter emit, Exp*);
-ANN m_bool emit_exp_spork(const Emitter, const Exp_Unary *);
-ANN m_bool emit_exp(const Emitter, Exp*);
+ANN bool emit_exp_spork(const Emitter, const Exp_Unary *);
ANN void emit_object_addref(const Emitter emit, const m_int size,
const bool emit_var);
const bool emit_var);
ANN static inline void emit_compound_addref(const Emitter emit, const Type t,
const m_int size,
- const m_bool emit_var) {
+ const bool emit_var) {
return !tflag(t, tflag_struct) ? emit_object_addref(emit, size, emit_var)
: emit_struct_addref(emit, t, size, emit_var);
}
ANN void emit_push_scope(const Emitter emit);
ANN void emit_pop_scope(const Emitter emit);
-ANN m_bool ensure_emit(const Emitter, const Type);
-ANN m_bool emit_ensure_func(const Emitter emit, const Func f);
-ANN m_bool get_emit_var(const Emitter emit, const Type t, bool is_var);
+ANN bool emit_ensure_func(const Emitter emit, const Func f);
+ANN bool get_emit_var(const Emitter emit, const Type t, bool is_var);
ANN static inline void emit_regmove(const Emitter emit, const m_uint i) {
const Instr instr = emit_add_instr(emit, RegMove);
#ifndef __ESCAPE
#define __ESCAPE
-char * escape_table(MemPool);
-ANN char str2char(const Emitter, const m_str, const loc_t);
-ANN m_bool escape_str(const Emitter, m_str, const loc_t);
+char *escape_table(MemPool);
+ANN bool str2char(const Emitter, const m_str, char *, const loc_t);
+ANN bool escape_str(const Emitter, m_str, const loc_t);
#endif
struct Vector_ effect;
} OperCK;
-ANN void func_checker_clean(const Gwi gwi, struct ImportCK *ck);
-ANN m_bool check_typename_def(const Gwi gwi, struct ImportCK *ck);
+ANN void func_checker_clean(const Gwi gwi, struct ImportCK *ck);
+ANN bool check_typename_def(const Gwi gwi, struct ImportCK *ck);
-ANN Symbol str2sym(const Gwion, const m_str, const loc_t);
-ANN ID_List str2symlist(const Gwion, const m_str, const loc_t);
-ANN m_bool str2var(const Gwion, Var_Decl*, const m_str, const loc_t);
+ANN Symbol str2sym(const Gwion, const m_str, const loc_t);
+ANN ID_List str2symlist(const Gwion, const m_str, const loc_t);
+ANN bool str2var(const Gwion, Var_Decl*, const m_str, const loc_t);
ANN Type_Decl *str2td(const Gwion, const m_str, const loc_t);
ANN Type str2type(const Gwion, const m_str, const loc_t);
#define gwi_str2td(gwi, path) str2td(gwi->gwion, path, gwi->loc)
#define gwi_str2type(gwi, path) str2type(gwi->gwion, path, gwi->loc)
-ANN m_bool ck_ini(const Gwi, const enum importck_type);
-ANN m_bool ck_ok(const Gwi, const enum importck_type);
+ANN bool ck_ini(const Gwi, const enum importck_type);
+ANN bool ck_ok(const Gwi, const enum importck_type);
ANN void ck_end(const Gwi gwi);
ANN void ck_clean(const Gwi gwi);
#endif
}
#define GWION_ERR(pos, a, ...) \
{ env_err(gwion->env, pos, (a), ##__VA_ARGS__); }
+
#define GWION_ERR_B(pos, a, ...) \
{ \
GWION_ERR(pos, (a), ##__VA_ARGS__); \
- return GW_ERROR; \
+ return false; \
}
#define GWION_ERR_O(pos, a, ...) \
{ \
Type type;
m_str tmpl_name;
};
-ANN m_bool traverse_dot_tmpl(const Emitter emit, const Func_Def fdef, const Value v);
+ANN bool traverse_dot_tmpl(const Emitter emit, const Func_Def fdef, const Value v);
INSTR(SetFunc);
INSTR(FuncWait);
}
#define RET_NSPC(exp) \
- ++env->scope->depth; \
- nspc_push_value(env->gwion->mp, env->curr); \
- const m_bool ret = exp; \
- nspc_pop_value(env->gwion->mp, env->curr); \
- --env->scope->depth; \
- return ret;
-
-#define RET_NSPC_B(exp) \
++env->scope->depth; \
nspc_push_value(env->gwion->mp, env->curr); \
const bool ret = exp; \
}
#define describe_stmt_func(prefix, name, type, prolog, exp) \
- ANN static m_bool prefix##_stmt_##name(const Env env, const type stmt) { \
+ ANN static bool prefix##_stmt_##name(const Env env, const type stmt) { \
RET_NSPC(exp) \
}
-#define describe_stmt_func_b(prefix, name, type, prolog, exp) \
- ANN static bool prefix##_stmt_##name(const Env env, const type stmt) { \
- RET_NSPC_B(exp) \
- }
-
-//ANN m_bool check_stmt(const Env env, Stmt* stmt);
ANN bool check_stmt_list(const Env env, const Stmt_List);
-typedef m_bool (*_exp_func)(const void *, const void *);
-
ANN bool scanx_body(const Env e, const Class_Def c, const _envset_func f,
void *d);
-static inline ANN m_bool env_body(const Env env, const Class_Def cdef,
+static inline ANN bool env_body(const Env env, const Class_Def cdef,
const _envset_func f) {
return scanx_body(env, cdef, f, env);
}
typedef m_bool (*compilation_pass)(const Env, Ast*);
ANEW ANN struct Passes_ *new_passes(const Gwion);
-ANN void free_passes(MemPool mp, struct Passes_ *);
-ANN void pass_register(const Gwion, const m_str, const compilation_pass);
-ANN void pass_default(const Gwion);
-ANN m_bool pass_set(const Gwion, const Vector);
+ANN void free_passes(MemPool mp, struct Passes_ *);
+ANN void pass_register(const Gwion, const m_str, const compilation_pass);
+ANN void pass_default(const Gwion);
+ANN bool pass_set(const Gwion, const Vector);
#endif
while (d) {
const m_str str = strsep(&d, " ");
const size_t sz = strlen(str);
- const m_bool arg = (str[sz - 1] == '\n');
+ const bool arg = (str[sz - 1] == '\n');
vector_add(v, (vtype)strndup(str, arg ? sz - 1 : sz));
}
xfree(d);
char * line = NULL;
size_t len = 0;
FILE * f = fopen(name, "r");
- CHECK_OO(f);
+ CHECK_O(f);
const Vector v = (Vector)xmalloc(sizeof(struct Vector_));
vector_init(v);
while (getline(&line, &len, f) != -1) {
CliArg *arg;
};
-ANN m_bool _arg_parse(struct ArgInternal *arg);
+ANN bool _arg_parse(struct ArgInternal *arg);
ANN static void config_parse(struct ArgInternal *arg, const char *name) {
const Vector v = get_config(name);
#define GWION_VERSION "N.A."
#endif
-ANN m_bool _arg_parse(struct ArgInternal *arg) {
+ANN bool _arg_parse(struct ArgInternal *arg) {
cmdapp_t app;
const cmdapp_info_t info = {
.program = "gwion",
if (cmdapp_run(&app) == EXIT_SUCCESS && cmdapp_should_exit(&app))
arg->arg->quit = 1;
cmdapp_destroy(&app);
- return GW_OK;
+ return true;
}
ANN static void config_default(struct ArgInternal *arg) {
config_parse(arg, c);
}
-ANN m_bool arg_parse(const Gwion gwion, CliArg *a) {
+ANN bool arg_parse(const Gwion gwion, CliArg *a) {
if(!a->uargs) a->arg.argc = 1;
if(a->config_args) a->arg.argv = a->config_args(&a->arg.argc, a->arg.argv);
struct ArgInternal arg = {.gwion = gwion, .arg = a};
ANN static m_bool emit_class_def(const Emitter, const Class_Def);
ANN static bool emit_cdef(const Emitter, const Type);
-ANN /*static inline*/ m_bool ensure_emit(const Emitter emit, const Type t) {
+ANN static m_bool ensure_emit(const Emitter emit, const Type t) {
if (tflag(t, tflag_emit) || !(tflag(t, tflag_cdef) || tflag(t, tflag_udef)))
- return GW_OK; // clean callers
- if(!tflag(t, tflag_tmpl))return GW_OK;
+ return true;
+ if(!tflag(t, tflag_tmpl)) return true;
struct EnvSet es = {.env = emit->env,
.data = emit,
.func = (_envset_func)emit_cdef,
.scope = emit->env->scope->depth,
.flag = tflag_emit};
- return envset_run(&es, t) ? GW_OK : GW_ERROR;
+ return envset_run(&es, t);
}
ANN void emit_object_release(const Emitter emit, const m_uint offset) {
}
ANN2(1, 2)
-static ArrayInfo *emit_array_extend_inner(const Emitter emit, const Type t,
+static ArrayInfo *emit_array_extend(const Emitter emit, const Type t,
Exp* e, const uint is_ref);
-ANN static m_bool emit_pre_ctor(const Emitter emit, const Type type) {
+ANN static bool emit_pre_ctor(const Emitter emit, const Type type) {
if (type->info->parent) {
- CHECK_BB(emit_pre_ctor(emit, type->info->parent));
+ CHECK_B(emit_pre_ctor(emit, type->info->parent));
if (tflag(type, tflag_typedef) && type->info->parent->array_depth)
- CHECK_OB(emit_array_extend_inner(emit, type, type->info->cdef->base.ext->array->exp, false));
+ CHECK_B(emit_array_extend(emit, type, type->info->cdef->base.ext->array->exp, false));
}
maybe_ctor(emit, type);
- return GW_OK;
+ return true;
}
ANN static void struct_expand(const Emitter emit, const Type t) {
const Instr instr = emit_add_instr(emit, ArrayStruct);
instr->m_val = type->size;
}
- CHECK_BB(emit_pre_ctor(emit, type));
+ CHECK_b(emit_pre_ctor(emit, type));
if (!tflag(type, tflag_struct))
emit_add_instr(emit, ArrayBottom);
else
}
ANN2(1)
-static m_bool extend_indices(const Emitter emit, Exp* e, const m_uint depth) {
- if (e) CHECK_BB(emit_exp(emit, e));
+static bool extend_indices(const Emitter emit, Exp* e, const m_uint depth) {
+ if (e) CHECK_b(emit_exp(emit, e));
m_uint count = 0;
while (e) {
++count;
e = e->next;
}
for (m_uint i = count; i < depth; ++i) emit_pushimm(emit, 0);
- return GW_OK;
+ return true;
}
ANEW ANN static ArrayInfo *new_arrayinfo(const Emitter emit, const Type t, const loc_t loc) {
}
ANN2(1, 2)
-static ArrayInfo *emit_array_extend_inner(const Emitter emit, const Type t,
+static ArrayInfo *emit_array_extend(const Emitter emit, const Type t,
Exp* e, const uint is_ref) {
- CHECK_BO(extend_indices(emit, e, get_depth(t)));
+ CHECK_O(extend_indices(emit, e, get_depth(t)));
ArrayInfo * info = new_arrayinfo(emit, t, t->info->cdef->base.tag.loc);
const Instr alloc = emit_add_instr(emit, ArrayAlloc);
alloc->m_val = (m_uint)info;
}
ANN2(1, 2)
-m_bool emit_instantiate_object(const Emitter emit, const Type type,
- const Array_Sub array, const m_bool is_ref) {
+bool emit_instantiate_object(const Emitter emit, const Type type,
+ const Array_Sub array, const bool is_ref) {
emit_notpure(emit);
if (type->array_depth) {
- DECL_OB(ArrayInfo *, info,
- = emit_array_extend_inner(emit, type, array ? array->exp : NULL,
+ DECL_B(ArrayInfo *, info,
+ = emit_array_extend(emit, type, array ? array->exp : NULL,
is_ref));
- return GW_OK;
+ return true;
} else if (!is_ref) {
if(!tflag(type, tflag_typedef) || isa(type, emit->gwion->type[et_closure]) > 0) {
const Instr instr = emit_add_instr(emit, ObjectInstantiate);
instr->m_val2 = (m_uint)type;
} // maybe we should instantiate the first actual type
- CHECK_BB(emit_pre_ctor(emit, type));
+ CHECK_b(emit_pre_ctor(emit, type));
}
- return GW_OK;
+ return true;
}
ANN2(1, 2)
-m_bool emit_instantiate_decl(const Emitter emit, const Type type,
+bool emit_instantiate_decl(const Emitter emit, const Type type,
const Type_Decl *td, const m_bool is_ref) {
return emit_instantiate_object(emit, type, td->array, is_ref);
}
}
e->next = next;
CHECK_BB(emit_exp(emit, &func));
- CHECK_BB(emit_exp_call1(emit, func.type->info->func,
+ CHECK_b(emit_exp_call1(emit, func.type->info->func,
func.type->info->func->def->base->ret_type->size, true));
count++;
} while((e = e->next->next));
}
ANN static m_bool emit_prim_char(const Emitter emit, const m_str *str) {
- const char c = str2char(emit, *str, prim_pos(str));
+ char c;
+ CHECK_b(str2char(emit, *str, &c, prim_pos(str)));
emit_pushimm(emit, c);
return GW_OK;
}
char c[sz + 1];
if (sz) {
strcpy(c, str->data);
- CHECK_BB(escape_str(emit, c, prim_pos(str)));
+ CHECK_B(escape_str(emit, c, prim_pos(str)));
} else
c[0] = '\0';
v->d.obj = new_string(emit->gwion, c);
return GW_OK;
}
-ANN m_bool emit_ensure_func(const Emitter emit, const Func f) {
+ANN bool emit_ensure_func(const Emitter emit, const Func f) {
const ValueFrom *from = f->value_ref->from;
if(from->owner_class)
- CHECK_BB(ensure_emit(emit, from->owner_class));
- if(f->code) return GW_OK;
+ CHECK_b(ensure_emit(emit, from->owner_class));
+ if(f->code) return true;
const m_uint scope = emit_push(emit, from->owner_class, from->owner);
- const m_bool ret = emit_func_def(emit, f->def);
+ const bool ret = emit_func_def(emit, f->def);
emit_pop(emit, scope);
return ret;
}
if(emit->locale->def->d.code) {
const Stmt* stmt = mp_vector_at((emit->locale->def->d.code), Stmt, 0);
const Func f = stmt->d.stmt_exp.val->d.exp_call.func->type->info->func;
- CHECK_OB(emit_ensure_func(emit, f));
+ CHECK_b(emit_ensure_func(emit, f));
}
- CHECK_OB(emit_ensure_func(emit, emit->locale));
+ CHECK_b(emit_ensure_func(emit, emit->locale));
comptime_ini(emit, "locale");
const M_Object string = new_string(emit->gwion, s_name(*id));
emit_pushimm(emit, (m_uint)string);
emit_pushimm(emit, (m_uint)emit->locale->code);
- CHECK_BB(emit_exp_call1(emit, emit->locale, SZ_FLOAT, true));
+ CHECK_b(emit_exp_call1(emit, emit->locale, SZ_FLOAT, true));
m_float ret;
comptime_end(emit, SZ_FLOAT, &ret);
if(ret == -1.0)
ANN static m_bool _decl_static(const Emitter emit, const Exp_Decl *decl,
const Var_Decl *var_decl, const uint is_ref) {
const Value v = var_decl->value;
- if(!decl->args) CHECK_BB(emit_instantiate_decl(emit, v->type, decl->var.td, is_ref));
+ if(!decl->args) CHECK_b(emit_instantiate_decl(emit, v->type, decl->var.td, is_ref));
else CHECK_BB(emit_exp(emit, decl->args));
CHECK_BB(emit_dot_static_data(emit, v, 1));
emit_add_instr(emit, Assign);
const bool is_obj = isa(type, emit->gwion->type[et_object]) > 0;
const bool emit_addr = (!is_obj || is_ref) ? emit_var : true;
if (is_obj && !is_ref && !exp_self(decl)->ref) {
- if(!decl->args) CHECK_BB(emit_instantiate_decl(emit, type, decl->var.td, is_ref));
+ if(!decl->args) CHECK_b(emit_instantiate_decl(emit, type, decl->var.td, is_ref));
else CHECK_BB(emit_exp(emit, decl->args));
}
f_instr *exec = (f_instr *)allocmember;
const bool is_obj = isa(type, emit->gwion->type[et_object]) > 0;
const bool emit_addr = (!is_obj || is_ref) ? emit_var : true;
if (is_obj && !is_ref) {
- if(!decl->args) CHECK_BB(emit_instantiate_decl(emit, type, decl->var.td, is_ref));
+ if(!decl->args) CHECK_b(emit_instantiate_decl(emit, type, decl->var.td, is_ref));
else CHECK_BB(emit_exp(emit, decl->args));
}
if (type->size > SZ_INT)
else emit_regpushmem(emit, offset, t->size, true);
if(tflag(t, tflag_ctor)) emit_ext_ctor(emit, t);
emit_add_instr(emit, NoOp);
- CHECK_BB(emit_exp_call1(emit, call->func->type->info->func, t->size, is_static_call(emit->gwion, call->func))); // is a ctor, is_static is true
+ CHECK_b(emit_exp_call1(emit, call->func->type->info->func, t->size, is_static_call(emit->gwion, call->func))); // is a ctor, is_static is true
return GW_OK;
}
if (f != emit->env->func || (f && f->value_ref->from->owner_class))
CHECK_BB(prepare_call(emit, call));
else CHECK_BB(emit_func_args(emit, call));
- CHECK_BB(emit_exp_call1(emit, f, exp_self(call)->type->size, is_static_call(emit->gwion, call->func)));
+ CHECK_b(emit_exp_call1(emit, f, exp_self(call)->type->size, is_static_call(emit->gwion, call->func)));
}
return GW_OK;
}
return emit_func_def(emit, fdef);
}
-ANN m_bool traverse_dot_tmpl(const Emitter emit, const Func_Def fdef, const Value v) {
+ANN bool traverse_dot_tmpl(const Emitter emit, const Func_Def fdef, const Value v) {
const m_uint scope = emit->env->scope->depth;
const bool shadowing = emit->env->scope->shadowing;
emit->env->scope->shadowing = true;
emit_pop(emit, scope);
envset_pop(&es, v->from->owner_class);
emit->env->scope->shadowing = shadowing;
- return ret ? GW_OK : GW_ERROR;
+ return ret;
}
static INSTR(fptr_call) {
instr->m_val2 = offset;
}
-ANN m_bool emit_exp_call1(const Emitter emit, const Func f,
+ANN bool emit_exp_call1(const Emitter emit, const Func f,
const m_uint size, const bool is_static) {
const EmitterStatus status = emit->status;
emit->status = (EmitterStatus){};
if(unlikely(fflag(f, fflag_fptr))) emit_fptr_call(emit, f);
else if (unlikely(!f->code && emit->env->func != f)) {
- if (fflag(f, fflag_tmpl)) CHECK_BB(emit_template_code(emit, f));
+ if (fflag(f, fflag_tmpl)) CHECK_b(emit_template_code(emit, f));
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))
//!is_new(f->def) || f->value_ref->from->owner_class->array_depth)
//if(f->value_ref->from->owner_class->array_depth)
-CHECK_BB(emit_ensure_func(emit, f));
+CHECK_b(emit_ensure_func(emit, f));
}
} else if(is_static)
push_func_code(emit, f);
const Type t = actual_type(emit->gwion, sp->exp->d.exp_call.func->type);
const Func f = t->info->func;
if(!f->code && f != emit->env->func)
- CHECK_BB(emit_ensure_func(emit, f));
+ CHECK_b(emit_ensure_func(emit, f));
push_spork_code(emit, sp->is_spork ? SPORK_FUNC_PREFIX : FORK_CODE_PREFIX,
sp->exp->loc);
- return emit_exp_call1(emit, f, f->def->base->ret_type->size, false);
+ return emit_exp_call1(emit, f, f->def->base->ret_type->size, false) ? GW_OK : GW_ERROR;
}
ANN static VM_Code spork_prepare(const Emitter emit, const struct Sporker *sp) {
instr->m_val2 = (m_uint)sp->type;
}
-ANN m_bool emit_exp_spork(const Emitter emit, const Exp_Unary *unary) {
+ANN bool emit_exp_spork(const Emitter emit, const Exp_Unary *unary) {
struct Sporker sporker = {
.exp = unary->unary_type == unary_exp ? unary->exp : NULL,
.code = unary->unary_type == unary_code ? unary->code : NULL,
.loc = exp_self(unary)->loc,
.is_spork = (unary->op == insert_symbol("spork")),
.emit_var = exp_getvar(exp_self(unary))};
- CHECK_OB((sporker.vm_code = spork_prepare(emit, &sporker)));
+ CHECK_B((sporker.vm_code = spork_prepare(emit, &sporker)));
if(!sporker.is_spork)
emit_local_exp(emit, exp_self(unary));
spork_ini(emit, &sporker);
.type = emit->env->class_def,
.exp_type = ae_exp_primary
};
- CHECK_BB(emit_exp(emit, &exp));
+ CHECK_b(emit_exp(emit, &exp));
offset += SZ_INT;
}
if(sporker.captures) {
};
if(cap->is_ref) exp_setvar(&exp, true);
offset += exp_size(&exp);
- CHECK_BB(emit_exp(emit, &exp));
+ CHECK_b(emit_exp(emit, &exp));
// emit_exp_addref(emit, &exp, -exp_size(&exp));
}
}
args->m_val = offset;
}
(unary->unary_type == unary_code ? spork_code : spork_func)(emit, &sporker);
- return GW_OK;
+ return true;
}
ANN static m_bool emit_exp_unary(const Emitter emit, const Exp_Unary *unary) {
return escape;
}
-static int get_escape(const Emitter emit, const char c, const loc_t loc) {
- if (emit->info->escape[(int)c]) return emit->info->escape[(int)c];
+static bool get_escape(const Emitter emit, const char c, char *out, const loc_t loc) {
+ *out = emit->info->escape[(int)c];
+ if(out) return true;
env_err(emit->env, loc, _("unrecognized escape sequence '\\%c'"), c);
- return GW_ERROR;
+ return false;
}
-m_bool escape_str(const Emitter emit, const m_str base, const loc_t loc) {
+bool escape_str(const Emitter emit, const m_str base, const loc_t loc) {
unsigned char *str_lit = (unsigned char *)base;
m_str str = base;
while (*str_lit) {
c1, c3);
return GW_ERROR;
}
- } else
- CHECK_BB((*str++ = (char)get_escape(emit, (char)c, loc)));
+ } else {
+ char out;
+ CHECK_B((*str++ = (char)get_escape(emit, (char)c, &out, loc)));
+ }
} else
*str++ = (char)*str_lit;
++str_lit;
}
*str = '\0';
- return GW_OK;
+ return true;
}
-ANN char str2char(const Emitter emit, const m_str c, const loc_t loc) {
- return c[0] != '\\' ? c[0] : get_escape(emit, c[1], loc);
+ANN bool str2char(const Emitter emit, const m_str c, char *out, const loc_t loc) {
+ if(c[0] != '\\') {
+ *out = c[0];
+ return true;
+ }
+ return get_escape(emit, c[1], out, loc);
}
gwion->type = (Type *)xcalloc(MAX_TYPE, sizeof(struct Type_ *));
arg->si = gwion->vm->bbq->si = new_soundinfo(gwion->mp);
new_passes(gwion);
- CHECK_BB(arg_parse(gwion, arg));
+ CHECK_b(arg_parse(gwion, arg));
if (arg->color == COLOR_NEVER)
tcol_override_color_checks(0);
else if (arg->color == COLOR_AUTO)
#include "import.h"
#include "gwi.h"
-ANN m_bool ck_ini(const Gwi gwi, const enum importck_type t) {
+ANN bool ck_ini(const Gwi gwi, const enum importck_type t) {
if (gwi->ck) // TODO: improve error message
GWI_ERR_B(_("already importing"))
gwi->ck = mp_calloc2(gwi->gwion->mp, sizeof(ImportCK));
gwi->ck->type = t;
- return GW_OK;
+ return true;
}
-ANN m_bool ck_ok(const Gwi gwi, const enum importck_type t) {
+ANN bool ck_ok(const Gwi gwi, const enum importck_type t) {
if (!gwi->ck) GWI_ERR_B(_("import not started"))
- if (gwi->ck->type == t) return GW_OK;
+ if (gwi->ck->type == t) return true;
// TODO: improve error message
GWI_ERR_B(_("already importing"))
}
ANN2(1, 2)
Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent) {
struct ImportCK ck = {.name = name};
- CHECK_BO(check_typename_def(gwi, &ck));
+ CHECK_O(check_typename_def(gwi, &ck));
DECL_OO(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));
ANN Type gwi_struct_ini(const Gwi gwi, const m_str name) {
struct ImportCK ck = {.name = name};
- CHECK_BO(check_typename_def(gwi, &ck));
+ CHECK_O(check_typename_def(gwi, &ck));
const Type t =
new_type(gwi->gwion->mp, s_name(ck.sym), gwi->gwion->type[et_compound]);
t->size = 0;
m_uint depth;
};
-ANN static m_bool ac_run(const Gwion gwion, struct AC *const ac);
+ANN static bool ac_run(const Gwion gwion, struct AC *const ac);
ANN static Array_Sub mk_array(MemPool mp, struct AC *ac) {
const Array_Sub array = new_array_sub(mp, ac->base);
array->depth = ac->depth;
return _str2sym(gwion, &tdc, path);
}
-ANN m_bool str2var(const Gwion gwion, Var_Decl *vd, const m_str path, const loc_t loc) {
+ANN bool str2var(const Gwion gwion, Var_Decl *vd, const m_str path, const loc_t loc) {
struct td_checker tdc = {.str = path, .loc = loc};
- DECL_OB(const Symbol, sym, = __str2sym(gwion, &tdc));
+ DECL_B(const Symbol, sym, = __str2sym(gwion, &tdc));
struct AC ac = {.str = tdc.str, .loc = loc};
- CHECK_BB(ac_run(gwion, &ac));
+ CHECK_B(ac_run(gwion, &ac));
vd->tag = MK_TAG(sym, loc);
vd->value = NULL;
- return GW_OK;
+ return true;
}
#define SPEC_ERROR (Specialized_List) GW_ERROR
return sl;
}
-ANN m_bool check_typename_def(const Gwi gwi, ImportCK *ck) {
+ANN bool check_typename_def(const Gwi gwi, ImportCK *ck) {
struct td_checker tdc = {.str = ck->name, .loc = gwi->loc};
- if (!(ck->sym = _str2sym(gwi->gwion, &tdc, tdc.str))) return GW_ERROR;
+ if (!(ck->sym = _str2sym(gwi->gwion, &tdc, tdc.str))) return false;
Specialized_List sl = __tmpl_list(gwi->gwion, &tdc);
- if (sl == SPEC_ERROR) return GW_ERROR;
+ if (sl == SPEC_ERROR) return false;
ck->sl = sl;
ck->name = s_name(ck->sym);
- return GW_OK;
+ return true;
}
ANN static Type_Decl *_str2td(const Gwion gwion, struct td_checker *tdc);
}
tdc->str += 2;
struct AC ac = {.str = tdc->str, .loc = tdc->loc};
- if(ac_run(gwion, &ac) < 0 ) {
+ if(!ac_run(gwion, &ac)) {
if(tl) free_tmplarg_list(gwion->mp, tl);
if(args) free_arg_list(gwion->mp, args);
return NULL;
DECL_OO(const Symbol, sym, = __str2sym(gwion, tdc));
TmplArg_List tl = td_tmpl(gwion, tdc);
struct AC ac = {.str = tdc->str, .loc = tdc->loc};
- CHECK_BO(ac_run(gwion, &ac));
+ CHECK_O(ac_run(gwion, &ac));
tdc->str = ac.str;
if (tl == (TmplArg_List)GW_ERROR) return NULL;
const uint option = get_n(tdc, '?');
return base;
}
-ANN static m_bool td_info_run(const Env env, struct td_info *info) {
+ANN static bool td_info_run(const Env env, struct td_info *info) {
const Gwion gwion = env->gwion;
TmplArg_List tl = info->tl;
for(uint32_t i = 0; i < tl->len; i++) {
text_init(&ls.text, gwion->mp);
Gwfmt l = {.mp = gwion->mp, .st = gwion->st, .ls = &ls, .line = 1, .last = cht_nl };
struct td_info info = {.tl = tl, .fmt = &l };
- CHECK_BO(td_info_run(gwion->env, &info));
+ CHECK_O(td_info_run(gwion->env, &info));
return ls.text.str;
}
-ANN static inline m_bool ac_finish(const Gwion gwion, const struct AC *ac) {
- if (*ac->str == ']') return GW_OK;
+ANN static inline bool ac_finish(const Gwion gwion, const struct AC *ac) {
+ if (*ac->str == ']') return true;
GWION_ERR_B(ac->loc, "unfinished array");
}
-ANN static inline m_bool ac_num(const Gwion gwion, const struct AC *ac,
+ANN static inline bool ac_num(const Gwion gwion, const struct AC *ac,
const m_int num) {
- if (num >= 0) return GW_OK;
+ if (num >= 0) return true;
GWION_ERR_B(ac->loc, "negative array dimension")
}
-ANN static inline m_bool ac_exp(const Gwion gwion, const struct AC *ac) {
- if (!ac->depth || ac->base) return GW_OK;
+ANN static inline bool ac_exp(const Gwion gwion, const struct AC *ac) {
+ if (!ac->depth || ac->base) return true;
GWION_ERR_B(ac->loc, "malformed array [][...]")
}
ac->base = ac->exp = exp;
}
-ANN static inline m_bool ac_noexp(const Gwion gwion, struct AC *ac) {
- if (!ac->exp) return GW_OK;
+ANN static inline bool ac_noexp(const Gwion gwion, struct AC *ac) {
+ if (!ac->exp) return true;
GWION_ERR_B(ac->loc, "malformed array [...][]")
}
-ANN static m_bool _ac_run(const Gwion gwion, struct AC *const ac) {
+ANN static bool _ac_run(const Gwion gwion, struct AC *const ac) {
const m_str str = ac->str;
const m_int num = strtol(str, &ac->str, 10);
- CHECK_BB(ac_finish(gwion, ac));
+ CHECK_B(ac_finish(gwion, ac));
if (str != ac->str) {
- CHECK_BB(ac_num(gwion, ac, num));
- CHECK_BB(ac_exp(gwion, ac));
+ CHECK_B(ac_num(gwion, ac, num));
+ CHECK_B(ac_exp(gwion, ac));
Exp* exp = new_prim_int(gwion->mp, num, ac->loc);
// set type: otherwise could fail at emit time
exp->type = gwion->type[et_int];
ac_add_exp(ac, exp);
} else
- CHECK_BB(ac_noexp(gwion, ac));
+ CHECK_B(ac_noexp(gwion, ac));
++ac->str;
- return GW_OK;
+ return true;
}
-ANN static m_bool ac_run(const Gwion gwion, struct AC *const ac) {
+ANN static bool ac_run(const Gwion gwion, struct AC *const ac) {
while (*ac->str) {
if (*ac->str != '[') break;
++ac->str;
- CHECK_BB(_ac_run(gwion, ac));
+ CHECK_B(_ac_run(gwion, ac));
++ac->depth;
}
- return GW_OK;
+ return true;
}
//! \arg string defining a primitive type
//! why is return type m_int ?
ANN m_int gwi_enum_ini(const Gwi gwi, const m_str type) {
- CHECK_BB(ck_ini(gwi, ck_edef));
+ CHECK_b(ck_ini(gwi, ck_edef));
CHECK_OB((gwi->ck->xid = gwi_str2sym(gwi, type)));
gwi->ck->tmpl = new_mp_vector(gwi->gwion->mp, EnumValue, 0);
return GW_OK;
//! \arg name of the entry
//! TODO: change return type to m_bool
ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint i) {
- CHECK_BB(ck_ok(gwi, ck_edef));
+ CHECK_B(ck_ok(gwi, ck_edef));
DECL_OB(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);
//! finish enum import
//! \arg the importer
ANN Type gwi_enum_end(const Gwi gwi) {
- CHECK_BO(ck_ok(gwi, ck_edef));
+ CHECK_O(ck_ok(gwi, ck_edef));
if (!gwi->ck->tmpl->len) GWI_ERR_O("Enum is empty");
const Gwion gwion = gwi->gwion;
const Enum_Def edef =
ANN2(1, 2, 3)
static m_bool dl_func_init(const Gwi gwi, const restrict m_str t,
const restrict m_str n) {
- CHECK_BB(ck_ini(gwi, ck_fdef));
+ CHECK_b(ck_ini(gwi, ck_fdef));
gwi->ck->name = n;
- CHECK_BB(check_typename_def(gwi, gwi->ck));
+ CHECK_b(check_typename_def(gwi, gwi->ck));
CHECK_OB((gwi->ck->td = gwi_str2td(gwi, t)));
gwi->ck->mpv = new_mp_vector(gwi->gwion->mp, Arg, 0);
return GW_OK;
}
ANN m_int gwi_func_end(const Gwi gwi, const f_xfun addr, const ae_flag flag) {
- CHECK_BB(ck_ok(gwi, ck_fdef));
+ CHECK_b(ck_ok(gwi, ck_fdef));
gwi->ck->addr = addr;
gwi->ck->flag = flag;
const m_bool ret = gwi_func_valid(gwi, gwi->ck);
ANN m_int gwi_func_arg(const Gwi gwi, const restrict m_str t,
const restrict m_str n) {
- CHECK_BB(ck_ok(gwi, ck_fdef));
+ CHECK_b(ck_ok(gwi, ck_fdef));
DECL_OB(Type_Decl *, td, = gwi_str2td(gwi, t));
struct Var_Decl_ var;
- if(gwi_str2var(gwi, &var, n) > 0) {
+ 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;
}
ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) {
- CHECK_BO(ck_ok(gwi, ck_fdef));
+ CHECK_O(ck_ok(gwi, ck_fdef));
DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi));
fptr->base->flag |= flag;
if (gwi->gwion->data->cdoc) {
ANN m_int gwi_item_ini(const Gwi gwi, const restrict m_str type,
const restrict m_str name) {
- CHECK_BB(ck_ini(gwi, ck_item));
+ CHECK_b(ck_ini(gwi, ck_item));
if ((gwi->ck->exp = make_exp(gwi, type, name))) return GW_OK;
GWI_ERR_B(_(" ... during var import '%s.%s'."), gwi->gwion->env->name, name)
}
#undef gwi_item_end
ANN2(1)
m_int gwi_item_end(const Gwi gwi, const ae_flag flag, union value_data addr) {
- CHECK_BB(ck_ok(gwi, ck_item));
+ 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) {
ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type,
const restrict m_str name) {
- CHECK_BB(ck_ini(gwi, ck_tdef));
+ CHECK_b(ck_ini(gwi, ck_tdef));
gwi->ck->name = name;
- CHECK_BB(check_typename_def(gwi, gwi->ck));
+ CHECK_b(check_typename_def(gwi, gwi->ck));
return (gwi->ck->td = gwi_str2td(gwi, type)) ? GW_OK : GW_ERROR;
}
ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) {
- CHECK_BO(ck_ok(gwi, ck_tdef));
+ CHECK_O(ck_ok(gwi, ck_tdef));
Type_Decl *td = gwi->ck->td;
td->flag |= flag;
const Type_Def tdef =
ANN Exp* make_exp(const Gwi gwi, const m_str type, const m_str name) {
DECL_OO(Type_Decl *, td, = gwi_str2td(gwi, type));
struct Var_Decl_ vd;
- if(gwi_str2var(gwi, &vd, name) < 0) {
+ if(!gwi_str2var(gwi, &vd, name)) {
free_type_decl(gwi->gwion->mp, td);
return NULL;
}
}
ANN m_int gwi_union_ini(const Gwi gwi, const m_str name) {
- CHECK_BB(ck_ini(gwi, ck_udef));
+ CHECK_b(ck_ini(gwi, ck_udef));
gwi->ck->name = name;
- CHECK_BB(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 GW_OK;
}
ANN m_int gwi_union_add(const Gwi gwi, const restrict m_str type,
const restrict m_str name) {
- CHECK_BB(ck_ok(gwi, ck_udef));
+ CHECK_b(ck_ok(gwi, ck_udef));
DECL_OB(Type_Decl *, td, = str2td(gwi->gwion, type, gwi->loc));
DECL_OB(const Symbol, xid, = str2sym(gwi->gwion, name, gwi->loc));
Variable um = { .td = td, .vd = { .tag = MK_TAG(xid, gwi->loc) } };
}
ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) {
- CHECK_BO(ck_ok(gwi, ck_udef));
+ CHECK_O(ck_ok(gwi, ck_udef));
if (!gwi->ck->mpv->len) GWI_ERR_O(_("union is empty"));
const Union_Def udef = new_union_def(gwi->gwion->mp, gwi->ck->mpv, gwi->loc);
gwi->ck->list = NULL;
return GW_OK;
}
-ANN m_bool get_emit_var(const Emitter emit, const Type t, bool is_var) {
+ANN bool get_emit_var(const Emitter emit, const Type t, bool is_var) {
const Env env = emit->env;
bool vars[2] = { is_var };
struct Op_Import opi = {.op = insert_symbol("@array_init"),
.lhs = t,
.data = (uintptr_t)vars};
- CHECK_BB(op_emit(emit, &opi));
+ if(op_emit(emit, &opi) != GW_OK)
+ return false;
return vars[1];
}
return exp_is_zero(e);
}
-ANN2(1,2) m_bool check_array_instance(const Env env, Type_Decl *td, Exp* args) {
+#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)
ERR_B(td->tag.loc, "declaration of abstract type arrays needs lambda");
gwerr_warn("array is empty", "no need to provide a lambda",
NULL, env->name, td->array->exp->loc);
}
- return GW_OK;
+ return true;
}
static OP_EMIT(opem_op_impl) {
struct Implicit *impl = (struct Implicit *)data;
if(!impl->e->type->info->func->code)
- emit_ensure_func(emit, impl->e->type->info->func);
+ CHECK_b(emit_ensure_func(emit, impl->e->type->info->func));
emit_pushimm(emit, (m_uint)impl->e->type->info->func->code);
return emit_fptr_assign(emit, impl->e->type, impl->t);
}
emit_add_instr(emit, hmap_grow_dec);
const Instr endgrow = emit_add_instr(emit, BranchNeqInt);
CHECK_BB(emit_exp(emit, call.d.exp_call.func));
- CHECK_BB(emit_exp_call1(emit, call.d.exp_call.func->type->info->func,
+ CHECK_b(emit_exp_call1(emit, call.d.exp_call.func->type->info->func,
call.d.exp_call.func->type->info->func->def->base->ret_type->size, true));
emit_add_instr(emit, hmap_find);
const Instr regrow = emit_add_instr(emit, BranchEqInt);
const Func_Def def = cpy_func_def(env->gwion->mp, v->d.func_ref->def);
if (vflag(v, vflag_builtin)) v->d.func_ref->def->d.dl_func_ptr = xfun;
def->base->tmpl->call = cpy_tmplarg_list(env->gwion->mp, fbase->base->tmpl->call);
- CHECK_BO(traverse_dot_tmpl(emit, def, v));
+ CHECK_O(traverse_dot_tmpl(emit, def, v));
if (vflag(v, vflag_builtin)) builtin_func(emit->gwion, def->base->func, xfun);
return def;
}
const Exp_Dot *member = (Exp_Dot *)data;
const Type t_base = member_type(emit->gwion, member->base->type);
const Value value = find_value(t_base, member->xid);
-// if(!tflag(t_base, tflag_emit) /*&& emit->env->class_def != t_base*/)
-// ensure_emit(emit, t_base);
if (is_class(emit->gwion, value->type)) {
emit_pushimm(emit, (m_uint)value->type);
return GW_OK;
if(GET_FLAG(base, abstract))
CHECK_ON(abstract_array(env, array));
if(GET_FLAG(base, abstract))
- CHECK_BN(check_array_instance(env, unary->ctor.td, unary->ctor.exp));
+ CHECK_ON(check_array_instance(env, unary->ctor.td, unary->ctor.exp));
}
CHECK_ON(ensure_traverse(env, t));
if (type_ref(t))
OP_EMIT(opem_new) {
const Exp_Unary *unary = (Exp_Unary *)data;
if(!tflag(exp_self(unary)->type, tflag_struct))
- CHECK_BB(emit_instantiate_object(emit, exp_self(unary)->type,
+ CHECK_b(emit_instantiate_object(emit, exp_self(unary)->type,
unary->ctor.td->array, 0));
if(!unary->ctor.exp)
emit_local_exp(emit, exp_self(unary));
static OP_EMIT(opem_spork) {
const Exp_Unary *unary = (Exp_Unary *)data;
- return emit_exp_spork(emit, unary);
+ return emit_exp_spork(emit, unary) ? GW_OK : GW_ERROR;
}
static FREEARG(freearg_xork) { vmcode_remref((VM_Code)instr->m_val, gwion); }
}
ANN static bool check_stmt_code(const Env env, const Stmt_Code stmt) {
- if (stmt->stmt_list) { RET_NSPC_B(check_stmt_list(env, stmt->stmt_list)) }
+ if (stmt->stmt_list) { RET_NSPC(check_stmt_list(env, stmt->stmt_list)) }
return true;
}
ANN static inline bool _check_breaks(const Env env, Stmt* b) {
- RET_NSPC_B(check_stmt(env, b))}
+ RET_NSPC(check_stmt(env, b))}
ANN static bool check_breaks(const Env env, Stmt* a, Stmt* b) {
vector_add(&env->scope->breaks, (vtype)a);
}
#define stmt_func_xxx(name, type, prolog, exp) \
- describe_stmt_func_b(check, name, type, prolog, exp)
+ describe_stmt_func(check, name, type, prolog, exp)
stmt_func_xxx(if, Stmt_If,, !(!check_flow(env, stmt->cond) ||
!check_stmt(env, stmt->if_body) ||
(stmt->else_body && !check_stmt(env, stmt->else_body))) ? true : false)
}
ANN static bool check_stmt_case(const Env env, const Stmt_Match stmt) {
- RET_NSPC_B(_check_stmt_case(env, stmt))}
+ RET_NSPC(_check_stmt_case(env, stmt))}
ANN static bool case_loop(const Env env, const Stmt_Match stmt) {
bool ok = true;
ANN static inline bool check_handler(const restrict Env env,
const Handler *handler) {
- RET_NSPC_B(check_stmt(env, handler->stmt));
+ RET_NSPC(check_stmt(env, handler->stmt));
}
ANN static inline bool check_handler_list(const restrict Env env,
ANN static inline bool check_stmt_try_start(const restrict Env env,
const Stmt_Try stmt) {
- RET_NSPC_B(check_stmt(env, stmt->stmt))
+ RET_NSPC(check_stmt(env, stmt->stmt))
}
ANN static inline bool check_stmt_try(const restrict Env env, const Stmt_Try stmt) {
ANN static inline bool handle_where(const Env env, const Stmt_Match stmt) {
if (stmt->where) CHECK_B(check_stmt(env, stmt->where));
- RET_NSPC_B(_check_stmt_match(env, stmt))
+ RET_NSPC(_check_stmt_match(env, stmt))
}
ANN static bool check_stmt_match(const Env env, const Stmt_Match stmt) {
- RET_NSPC_B(handle_where(env, stmt))
+ RET_NSPC(handle_where(env, stmt))
}
#define check_stmt_while check_stmt_flow
}
ANN static bool check_trait_def(const Env env, const Trait_Def pdef) {
- RET_NSPC_B(_check_trait_def(env, pdef));
+ RET_NSPC(_check_trait_def(env, pdef));
}
ANN bool check_fptr_def(const Env env, const Fptr_Def fptr) {
ANN static inline bool scan1_stmt_match_case(const restrict Env env,
const Stmt_Match stmt) {
- RET_NSPC_B(_scan1_stmt_match_case(env, stmt))}
+ RET_NSPC(_scan1_stmt_match_case(env, stmt))}
ANN static inline bool
_scan1_stmt_match(const restrict Env env, const Stmt_Match stmt) {
ANN static inline bool scan1_stmt_match(const restrict Env env,
const Stmt_Match stmt) {
CHECK_B(scan1_exp(env, stmt->cond));
- RET_NSPC_B(_scan1_stmt_match(env, stmt))
+ RET_NSPC(_scan1_stmt_match(env, stmt))
}
ANN static inline bool scan1_handler(const restrict Env env,
const Handler *handler) {
- RET_NSPC_B(scan1_stmt(env, handler->stmt));
+ RET_NSPC(scan1_stmt(env, handler->stmt));
}
ANN static inline bool scan1_handler_list(const restrict Env env,
ANN static inline bool scan1_stmt_try(const restrict Env env,
const Stmt_Try stmt) {
CHECK_B(scan1_handler_list(env, stmt->handler));
- RET_NSPC_B(scan1_stmt(env, stmt->stmt))
+ RET_NSPC(scan1_stmt(env, stmt->stmt))
}
ANN static inline bool stmt_each_defined(const restrict Env env,
}
#define describe_ret_nspc(name, type, prolog, exp) \
- describe_stmt_func_b(scan1, name, type, prolog, exp)
+ describe_stmt_func(scan1, name, type, prolog, exp)
describe_ret_nspc(flow, Stmt_Flow,, !(!scan1_exp(env, stmt->cond) ||
!scan1_stmt(env, stmt->body)) ? true : false)
describe_ret_nspc(for, Stmt_For,, !(!scan1_stmt(env, stmt->c1) ||
}
ANN static inline bool scan1_stmt_if(const Env env, const Stmt_If stmt) {
- RET_NSPC_B(_scan1_stmt_if(env, stmt));
+ RET_NSPC(_scan1_stmt_if(env, stmt));
return true;
}
ANN static inline bool scan1_stmt_code(const Env env, const Stmt_Code stmt) {
- if (stmt->stmt_list) { RET_NSPC_B(scan1_stmt_list(env, stmt->stmt_list)) }
+ if (stmt->stmt_list) { RET_NSPC(scan1_stmt_list(env, stmt->stmt_list)) }
return true;
}
else if (fbflag(fdef->base, fbflag_op) && env->class_def)
SET_FLAG(fdef->base, static);
if(!is_ctor(fdef)) {
- RET_NSPC_B(scan1_fbody(env, fdef))
+ RET_NSPC(scan1_fbody(env, fdef))
} else if(!fdef->builtin)
CHECK_B(scan1_stmt_list(env, fdef->d.code));
return true;
ANN static inline bool scan2_stmt_match_case(const restrict Env env,
const Stmt_Match stmt) {
- RET_NSPC_B(_scan2_stmt_match_case(env, stmt))}
+ RET_NSPC(_scan2_stmt_match_case(env, stmt))}
ANN static inline bool
_scan2_stmt_match(const restrict Env env, const Stmt_Match stmt) {
ANN static inline bool scan2_handler(const restrict Env env,
const Handler *handler) {
- RET_NSPC_B(scan2_stmt(env, handler->stmt));
+ RET_NSPC(scan2_stmt(env, handler->stmt));
}
ANN static inline bool scan2_handler_list(const restrict Env env,
ANN static inline bool scan2_stmt_try(const restrict Env env,
const Stmt_Try stmt) {
CHECK_B(scan2_handler_list(env, stmt->handler));
- RET_NSPC_B(scan2_stmt(env, stmt->stmt))
+ RET_NSPC(scan2_stmt(env, stmt->stmt))
}
ANN static inline bool scan2_stmt_match(const restrict Env env,
const Stmt_Match stmt) {
CHECK_B(scan2_exp(env, stmt->cond));
- RET_NSPC_B(_scan2_stmt_match(env, stmt))
+ RET_NSPC(_scan2_stmt_match(env, stmt))
}
#define scan2_exp_lambda bdummy_func
HANDLE_EXP_FUNC_B(scan2, bool, Env)
#define scan2_stmt_func(name, type, prolog, exp) \
- describe_stmt_func_b(scan2, name, type, prolog, exp)
+ describe_stmt_func(scan2, name, type, prolog, exp)
scan2_stmt_func(flow, Stmt_Flow,, !(!scan2_exp(env, stmt->cond) ||
!scan2_stmt(env, stmt->body)) ? true : false)
scan2_stmt_func(for, Stmt_For,, !(!scan2_stmt(env, stmt->c1) ||
(stmt->else_body && !scan2_stmt(env, stmt->else_body))) ? true : false)
ANN static inline bool scan2_stmt_code(const Env env, const Stmt_Code stmt) {
- if (stmt->stmt_list) { RET_NSPC_B(scan2_stmt_list(env, stmt->stmt_list)) }
+ if (stmt->stmt_list) { RET_NSPC(scan2_stmt_list(env, stmt->stmt_list)) }
return true;
}
#include "traverse.h"
#include "parse.h"
-ANN static inline bool _body(const Env e, Ast b, const _exp_func f) {
+ANN static inline bool _body(const Env e, Ast b, const _envset_func f) {
for(m_uint i = 0; i < b->len; i++) {
Section *section = mp_vector_at(b, Section, i);
CHECK_B(f(e, section));
map_set(&gwion->data->passes->map, (vtype)sym, (vtype)pass);
}
-ANN m_bool pass_set(const Gwion gwion, const Vector passes) {
+ANN bool pass_set(const Gwion gwion, const Vector passes) {
const Vector v = &gwion->data->passes->vec;
vector_clear(v);
for (m_uint i = 0; i < vector_size(passes); ++i) {
*/
gw_err("Failed to set compilation passes, back to default\n");
pass_default(gwion);
- return GW_ERROR;
+ return false;
}
vector_add(v, (vtype)pass);
}
- return GW_OK;
+ return true;
}
ANN void pass_default(const Gwion gwion) {