} ArrayInfo;
ANN Type check_array_access(const Env env, const Array_Sub array);
-ANN m_bool emit_array_access(const Emitter emit,
+ANN 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);
#endif
+++ /dev/null
-#ifndef __CONSTANT
-#define __CONSTANT
-ANN m_bool constant_int(Exp* e);
-ANN m_bool constant_float(Exp* e);
-#endif
ANEW ANN Emitter new_emitter(MemPool);
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 bool emit_ast(const Env env, Ast *ast);
+ANN bool emit_func_def(const Emitter emit, const Func_Def fdef);
+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 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 bool emit_exp(const Emitter, Exp*);
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 bool ensure_emit(const Emitter, const Type);
+ANN 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 static inline void emit_regmove(const Emitter emit, const m_uint i) {
bool in_try;
bool in_loop;
bool shadowing;
+ bool poison;
};
typedef struct Env_ {
ANN static inline m_uint env_push_global(const Env env) {
return env_push(env, NULL, env->global_nspc);
}
-ANN void env_pop(const Env, const m_uint);
-ANN Type scan_type(const Env, const Type, Type_Decl *);
-ANN Value mk_class(const Env env, const Type base, const loc_t);
-ANN m_bool compat_func(const __restrict__ Func_Def,
+ANN void env_pop(const Env, const m_uint);
+ANN Type scan_type(const Env, const Type, Type_Decl *);
+ANN Value mk_class(const Env env, const Type base, const loc_t);
+ANN bool compat_func(const __restrict__ Func_Def,
const __restrict__ Func_Def);
-ANN Type known_type(const Env env, Type_Decl *);
-ANN Type prim_ref(const Env env, const Type t, const Type_Decl *td);
-ANN m_bool env_access(const Env env, const ae_flag flag, const loc_t);
-ANN m_bool env_storage(const Env env, ae_flag flag, const loc_t);
-ANN void env_add_type(const Env, const Type, const loc_t);
-ANN Type find_type(const Env, Type_Decl *);
-ANN m_bool traverse_func_template(const Env, const Func_Def);
-ANN void env_err(const Env, const loc_t, const m_str fmt, ...);
-ANN void env_warn(const Env, const loc_t, const m_str fmt, ...);
-ANN void env_error_footer(const Env env);
-ANN Value global_string(const Env env, const m_str str, const loc_t);
-ANN void release_ctx(struct Env_Scope_ *a, struct Gwion_ *gwion);
+ANN Type known_type(const Env env, Type_Decl *);
+ANN Type prim_ref(const Env env, const Type t, const Type_Decl *td);
+ANN bool env_access(const Env env, const ae_flag flag, const loc_t);
+ANN bool env_storage(const Env env, ae_flag flag, const loc_t);
+ANN void env_add_type(const Env, const Type, const loc_t);
+ANN Type find_type(const Env, Type_Decl *);
+ANN bool traverse_func_template(const Env, const Func_Def);
+ANN void env_err(const Env, const loc_t, const m_str fmt, ...);
+ANN void env_warn(const Env, const loc_t, const m_str fmt, ...);
+ANN void env_error_footer(const Env env);
+ANN Value global_string(const Env env, const m_str str, const loc_t);
+ANN void release_ctx(struct Env_Scope_ *a, struct Gwion_ *gwion);
struct ScopeEffect {
Symbol sym;
ANN void env_add_effect(const Env a, const Symbol effect, const loc_t);
ANN void call_add_effect(const Env env, const Func func, const loc_t);
-ANN m_bool already_defined(const Env env, const Symbol s, const loc_t);
+ANN bool already_defined(const Env env, const Symbol s, const loc_t);
#endif
#ifndef __ENVSET
#define __ENVSET
-typedef m_bool (*envset_func)(const void *, const void *);
+// couldbe _exp_func
+typedef bool (*envset_func)(const void *, const void *);
struct EnvSet {
const Env env;
const envset_func func;
bool run;
};
-ANN m_bool envset_run(struct EnvSet *, const Type);
-ANN2(1, 3) m_bool envset_push(struct EnvSet *, const Type, const Nspc);
-ANN static inline m_bool envset_pushv(struct EnvSet *es, const Value v) {
+ANN bool envset_run(struct EnvSet *, const Type);
+ANN2(1, 3) bool envset_push(struct EnvSet *, const Type, const Nspc);
+ANN static inline bool envset_pushv(struct EnvSet *es, const Value v) {
es->_ctx = es->env->context;
es->_filename = es->env->name;
- CHECK_BB(envset_push(es, v->from->owner_class, v->from->owner));
- return GW_OK;
+ CHECK_B(envset_push(es, v->from->owner_class, v->from->owner));
+ return true;
}
ANN2(1) void envset_pop(struct EnvSet *, const Type);
#endif
ANN2(1, 2)
Symbol func_symbol(const Env, const m_str, const m_str, const m_str,
const m_uint);
-ANN m_bool check_lambda(const Env, const Type, Exp_Lambda *);
+ANN bool check_lambda(const Env, const Type, Exp_Lambda *);
ANN Type check_op_call(const Env env, Exp_Call *const exp);
ANN void builtin_func(const Gwion gwion, const Func f, void *func_ptr);
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 m_bool isres(const Env, const Tag);
+ANN bool isres(const Env, const Tag);
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));
ANN Type array_base(Type) __attribute__((pure));
void a(const Type t NUSED, m_bit *const VALUE NUSED, \
const VM_Shred shred NUSED)
#define OP_CHECK(a) ANN Type a(const Env env NUSED, void *data NUSED)
-#define OP_EMIT(a) ANN m_bool a(const Emitter emit 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) \
{ \
m_str ret;
Symbol sym;
Type (*ck)(Env, void *); // oper
- m_bool (*em)(Emitter, void *); // oper
+ bool (*em)(Emitter, void *); // oper
m_str lhs; // oper
m_str rhs; // oper
struct Vector_ effect;
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);
} while (0)
typedef Type (*opck)(const Env, void *);
-typedef m_bool (*opem)(const Emitter, void *);
+typedef bool (*opem)(const Emitter, void *);
struct Op_Func {
opck ck;
};
ANN void op_cpy(const Env env, const struct Op_Import *opi);
-ANN m_bool add_op(const Gwion gwion, const struct Op_Import *);
+ANN bool add_op(const Gwion gwion, const struct Op_Import *);
ANN void* op_get(const Env env, struct Op_Import *opi);
-ANN Type op_check(const Env, struct Op_Import *);
-ANN m_bool op_emit(const Emitter, const struct Op_Import *);
-ANN m_bool operator_set_func(const struct Op_Import *);
-ANN void free_op_map(Map map, struct Gwion_ *gwion);
-ANN void free_op_tmpl(Vector v, struct Gwion_ *gwion);
+ANN Type op_check(const Env, struct Op_Import *);
+ANN bool op_emit(const Emitter, const struct Op_Import *);
+ANN bool operator_set_func(const struct Op_Import *);
+ANN void free_op_map(Map map, struct Gwion_ *gwion);
+ANN void free_op_tmpl(Vector v, struct Gwion_ *gwion);
ANN void operator_suspend(const Nspc, struct Op_Import *);
ANN static inline void operator_resume(struct Op_Import *opi) {
}
ANN void func_operator(const Func_Def fdef, struct Op_Import *opi);
-ANN m_bool add_op_func_check(const Env env, const Type t, const struct Op_Func *opfunc, const m_uint idx);
+ANN bool add_op_func_check(const Env env, const Type t, const struct Op_Func *opfunc, const m_uint idx);
#endif
#define ERR_B(a, b, ...) \
{ \
env_err(env, (a), (b), ##__VA_ARGS__); \
- return GW_ERROR; \
+ return false; \
}
#undef ERR_O
#define RET_NSPC(exp) \
++env->scope->depth; \
nspc_push_value(env->gwion->mp, env->curr); \
- const m_bool ret = exp; \
+ const bool ret = exp; \
nspc_pop_value(env->gwion->mp, env->curr); \
--env->scope->depth; \
return ret;
#define HANDLE_EXP_FUNC(prefix, type, Arg) \
DECL_EXP_FUNC(prefix, type, Arg) \
- ANN type prefix##_exp(const Arg arg, Exp* exp) { \
- do CHECK_BB(prefix##_exp_func[exp->exp_type](arg, &exp->d)); \
- while ((exp = exp->next)); \
- return GW_OK; \
+ ANN type prefix##_exp(const Arg arg, Exp* exp) { \
+ bool ok = true; \
+ do { \
+ if(exp->poison) continue; \
+ if(!prefix##_exp_func[exp->exp_type](arg, &exp->d)) { \
+ prefix##_poison(arg, exp); \
+ ok = false; \
+ } \
+ } while ((exp = exp->next)); \
+ return ok; \
}
-ANN m_bool scan1_exp(const Env, Exp*);
-ANN m_bool scan2_exp(const Env, Exp*);
+
+ANN static inline void scanx_poison(const Env env, Exp *e) {
+ env->scope->poison = true;
+ e->poison = true;
+}
#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) \
}
-ANN m_bool check_stmt(const Env env, Stmt* stmt);
-ANN m_bool check_stmt_list(const Env env, const Stmt_List);
+ANN bool check_stmt(const Env env, Stmt* stmt); // neeeded???
+ANN bool check_stmt_list(const Env env, const Stmt_List);
-typedef m_bool (*_exp_func)(const void *, const void *);
-ANN m_bool scanx_body(const Env env, const Class_Def cdef, const _exp_func f,
+typedef bool (*_exp_func)(const void *, const void *);
+ANN bool scanx_body(const Env env, const Class_Def cdef, const _exp_func f,
void *data);
-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 _exp_func f) {
return scanx_body(env, cdef, f, env);
}
#define env_body(a, b, c) env_body(a, b, (_exp_func)c)
-ANN m_bool scanx_cdef(const Env, void *, const Type, const _exp_func f_cdef,
+ANN bool scanx_cdef(const Env, void *, const Type, const _exp_func f_cdef,
const _exp_func f_union);
#define xxx_cdef(prefix) \
- static inline m_bool prefix##_cdef(const Env env, const Type t) { \
+ static inline bool prefix##_cdef(const Env env, const Type t) { \
return scanx_cdef(env, env, t, (_exp_func)prefix##_class_def, \
(_exp_func)prefix##_union_def); \
}
-xxx_cdef(scan0) xxx_cdef(scan1) xxx_cdef(scan2) xxx_cdef(check)
- xxx_cdef(traverse)
+xxx_cdef(scan0);
+xxx_cdef(scan1);
+xxx_cdef(scan2);
+xxx_cdef(check);
+xxx_cdef(traverse);
- ANN m_bool
- scanx_fdef(const Env, void *, const Func_Def, const _exp_func);
+ANN bool scanx_fdef(const Env, void *, const Func_Def, const _exp_func);
-ANN m_bool check_subscripts(const Env, const Array_Sub, const m_bool is_decl);
-ANN m_bool check_implicit(const Env env, Exp* e, const Type t);
-ANN m_bool ensure_traverse(const Env env, const Type t);
-ANN m_bool check_traverse_fdef(const Env env, const Func_Def fdef);
+ANN bool check_subscripts(const Env, const Array_Sub, const bool is_decl);
+ANN bool check_implicit(const Env env, Exp* e, const Type t);
+ANN bool ensure_traverse(const Env env, const Type t);
+ANN bool check_traverse_fdef(const Env env, const Func_Def fdef);
ANN static inline void env_weight(const Env env, const uint16_t weight) {
if (env->func)
nspc_lookup_value1(env->curr, insert_symbol(v->name));
}
-ANN m_bool abstract_array(const Env env, const Array_Sub array);
+ANN bool abstract_array(const Env env, const Array_Sub array);
ANN static inline bool is_static_call(const Gwion gwion, Exp* e) {
if (e->exp_type != ae_exp_dot) return true;
member->base->exp_type == ae_exp_cast;
}
+
+ANN bool template_push_types(const Env, const Tmpl *);
+static inline bool scanx_actual_tmpl(const Tmpl *tmpl) {
+ return tmpl && tmpl->call && tmpl->call != (TmplArg_List)1 && tmpl->list;
+}
+
+ANN static inline bool scanx_tmpl_push(const Env env, const Tmpl *tmpl) {
+ return scanx_actual_tmpl(tmpl) ? template_push_types(env, tmpl): false;
+}
+
+ANN static inline m_int scanx_push(const Env env, const Class_Def c) {
+ const m_int scope = env_push_type(env, c->base.type);
+ if(scope < 0) return -1;
+ return (!c->base.tmpl || scanx_tmpl_push(env, c->base.tmpl)) ? scope : -1;
+}
+
+ANN static inline void scanx_pop(const Env e, const Class_Def c, const m_uint s) {
+ if (scanx_actual_tmpl(c->base.tmpl))
+ nspc_pop_type(e->gwion->mp, e->curr);
+ env_pop(e, s);
+}
+
+
#define is_new(a) !strcmp(s_name((a)->base->tag.sym), "new")
#endif
struct Vector_ vec;
};
// change this to gwion ?
-typedef m_bool (*compilation_pass)(const Env, Ast*);
+typedef bool (*compilation_pass)(const Env, Ast*);
ANEW ANN struct Passes_ *new_passes(const Gwion);
ANN void free_passes(MemPool mp, struct Passes_ *);
return !strcmp(s_name(spec->tag.sym), "...");
}
-ANN m_bool spread_ast(const Env env, const Spread_Def spread, const Tmpl *tmpl);
+ANN bool spread_ast(const Env env, const Spread_Def spread, const Tmpl *tmpl);
ANN Stmt_List spread_func(const Env env, const Stmt_List body);
#endif
#ifndef __TEMPLATE
#define __TEMPLATE
-ANN m_bool template_push_types(const Env, const Tmpl *);
-ANN m_bool template_push(const Env env, const Type t);
+ANN bool template_push_types(const Env, const Tmpl *);
+ANN bool template_push(const Env env, const Type t);
ANN Tmpl *mk_tmpl(const Env, const Tmpl *, const TmplArg_List);
/*
//! returns the Tmpl of a class or enum def
return (a); \
}
-ANN m_bool const_generic_typecheck(const Env env, const Specialized *spec, const TmplArg *targ);
+ANN bool const_generic_typecheck(const Env env, const Specialized *spec, const TmplArg *targ);
#endif
ANN Func find_template_match(const Env env, const Value value,
Exp_Call *const exp);
ANN Func find_func_match(const Env env, const Func up, Exp_Call *const exp);
-ANN2(1,2) m_bool check_tmpl(const Env env, const TmplArg_List tl, const Specialized_List sl, const loc_t loc, const bool is_spread);
+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);
#endif
#ifndef __TRAVERSE
#define __TRAVERSE
-ANN m_bool traverse_ast(const Env, Ast *const);
-ANN m_bool traverse_class_def(const Env, const Class_Def);
-ANN m_bool traverse_func_def(const Env, const Func_Def);
-ANN m_bool traverse_union_def(const Env, const Union_Def);
-ANN m_bool traverse_enum_def(const Env, const Enum_Def);
-ANN m_bool traverse_fptr_def(const Env, const Fptr_Def);
-ANN m_bool traverse_type_def(const Env env, const Type_Def);
-ANN m_bool traverse_exp(const Env, Exp*);
-
-ANN m_bool scan0_ast(const Env, Ast*);
-ANN m_bool scan1_ast(const Env, Ast*);
-ANN m_bool scan2_ast(const Env, Ast*);
-ANN m_bool check_ast(const Env, Ast*);
-
-ANN m_bool scan1_exp(const Env, Exp*);
-ANN m_bool scan2_exp(const Env, Exp*);
-ANN Type check_exp(const Env, Exp*);
-
-ANN m_bool scan0_func_def(const Env, const Func_Def);
-ANN m_bool scan1_func_def(const Env, const Func_Def);
-ANN m_bool scan2_func_def(const Env, const Func_Def);
-ANN m_bool check_func_def(const Env, const Func_Def);
-
-ANN m_bool scan0_fptr_def(const Env, const Fptr_Def);
-ANN m_bool scan1_fptr_def(const Env, const Fptr_Def);
-ANN m_bool scan2_fptr_def(const Env, const Fptr_Def);
-ANN m_bool check_fptr_def(const Env, const Fptr_Def);
-
-ANN m_bool scan0_union_def(const Env, const Union_Def);
-ANN m_bool scan1_union_def(const Env, const Union_Def);
-ANN m_bool scan2_union_def(const Env, const Union_Def);
-ANN m_bool check_union_def(const Env, const Union_Def);
-
-ANN m_bool scan0_enum_def(const Env, const Enum_Def);
-ANN m_bool scan1_enum_def(const Env, const Enum_Def);
-// ANN m_bool scan2_enum_def(const Env, const Enum_Def);
-ANN m_bool check_enum_def(const Env, const Enum_Def);
-
-ANN m_bool scan0_type_def(const Env, const Type_Def);
-ANN m_bool scan1_type_def(const Env, const Type_Def);
-ANN m_bool scan2_type_def(const Env, const Type_Def);
-ANN m_bool check_type_def(const Env, const Type_Def);
-
-ANN m_bool scan0_class_def(const Env, const Class_Def);
-ANN m_bool scan1_class_def(const Env, const Class_Def);
-ANN m_bool scan2_class_def(const Env, const Class_Def);
-ANN m_bool check_class_def(const Env, const Class_Def);
+ANN bool traverse_ast(const Env, Ast *const);
+ANN bool traverse_class_def(const Env, const Class_Def);
+ANN bool traverse_func_def(const Env, const Func_Def);
+ANN bool traverse_union_def(const Env, const Union_Def);
+ANN bool traverse_enum_def(const Env, const Enum_Def);
+ANN bool traverse_fptr_def(const Env, const Fptr_Def);
+ANN bool traverse_type_def(const Env env, const Type_Def);
+ANN bool traverse_exp(const Env, Exp*);
+
+ANN bool scan0_ast(const Env, Ast*);
+ANN bool scan1_ast(const Env, Ast*);
+ANN bool scan2_ast(const Env, Ast*);
+ANN bool check_ast(const Env, Ast*);
+
+ANN bool scan1_exp(const Env, Exp*);
+ANN bool scan2_exp(const Env, Exp*);
+ANN Type check_exp(const Env, Exp*);
+
+ANN bool scan0_func_def(const Env, const Func_Def);
+ANN bool scan1_func_def(const Env, const Func_Def);
+ANN bool scan2_func_def(const Env, const Func_Def);
+ANN bool check_func_def(const Env, const Func_Def);
+
+ANN bool scan0_fptr_def(const Env, const Fptr_Def);
+ANN bool scan1_fptr_def(const Env, const Fptr_Def);
+ANN bool scan2_fptr_def(const Env, const Fptr_Def);
+ANN bool check_fptr_def(const Env, const Fptr_Def);
+
+ANN bool scan0_union_def(const Env, const Union_Def);
+ANN bool scan1_union_def(const Env, const Union_Def);
+ANN bool scan2_union_def(const Env, const Union_Def);
+ANN bool check_union_def(const Env, const Union_Def);
+
+ANN bool scan0_enum_def(const Env, const Enum_Def);
+ANN bool scan1_enum_def(const Env, const Enum_Def);
+// ANN bool scan2_enum_def(const Env, const Enum_Def);
+ANN bool check_enum_def(const Env, const Enum_Def);
+
+ANN bool scan0_type_def(const Env, const Type_Def);
+ANN bool scan1_type_def(const Env, const Type_Def);
+ANN bool scan2_type_def(const Env, const Type_Def);
+ANN bool check_type_def(const Env, const Type_Def);
+
+ANN bool scan0_class_def(const Env, const Class_Def);
+ANN bool scan1_class_def(const Env, const Class_Def);
+ANN bool scan2_class_def(const Env, const Class_Def);
+ANN bool check_class_def(const Env, const Class_Def);
ANN Type check_exp_call1(const Env env, Exp_Call *const exp);
-ANN m_bool scan0_prim_def(const Env env, const Prim_Def pdef);
+ANN bool scan0_prim_def(const Env env, const Prim_Def pdef);
#endif