From: Jérémie Astor Date: Fri, 5 Nov 2021 11:26:18 +0000 (+0100) Subject: :smile: Clang cleanup X-Git-Tag: nightly~414 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=2876bb39230c72bcaeac3347e904656158751edd;p=gwion.git :smile: Clang cleanup --- diff --git a/src/emit/emit.c b/src/emit/emit.c index 9e476de7..57224c1b 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1178,6 +1178,10 @@ ANN static inline void emit_return_pc(const Emitter emit, const m_uint val) { ANN static inline void pop_exp(const Emitter emit, Exp e); +ANN static m_bool scoped_stmt(const Emitter emit, const Stmt stmt, + const m_bool pop); + +#ifdef GWION_INLINE ANN static inline bool check_inline(const Emitter emit, const Func f) { const uint16_t caller_size = emit->env->func ? emit->env->func->weight : emit->env->class_def @@ -1240,8 +1244,6 @@ ANN static inline void inline_args_end(const Func f, const Vector v) { } } -ANN static m_bool scoped_stmt(const Emitter emit, const Stmt stmt, - const m_bool pop); ANN static inline m_bool inline_body(const Emitter emit, const Func f) { struct Vector_ v = {.ptr = emit->code->stack_return.ptr}; vector_init(&emit->code->stack_return); @@ -1284,7 +1286,7 @@ ANN static inline m_bool emit_inline(const Emitter emit, const Func f, emit->vararg_offset = vararg_offset; return ret; } - +#endif ANN static m_bool _emit_exp_call(const Emitter emit, const Exp_Call *exp_call) { /* #ifndef GWION_NOINLINE @@ -2714,13 +2716,6 @@ ANN static m_bool emit_exp_dot(const Emitter emit, const Exp_Dot *member) { return op_emit(emit, &opi); } -ANN static inline void emit_func_def_fglobal(const Emitter emit, - const Value value) { - const Instr set_mem = emit_add_instr(emit, MemSetImm); - set_mem->m_val = value->from->offset; - set_mem->m_val2 = (m_uint)value->d.func_ref->code; -} - ANN static inline void emit_func_def_init(const Emitter emit, const Func func) { emit_push_code(emit, func->name); } diff --git a/src/env/type.c b/src/env/type.c index 97b3302e..599b0c04 100644 --- a/src/env/type.c +++ b/src/env/type.c @@ -7,6 +7,9 @@ #include "gwion.h" #include "clean.h" #include "object.h" +#include "instr.h" +#include "operator.h" +#include "import.h" ANN static inline m_bool freeable(const Type a) { return tflag(a, tflag_tmpl) || GET_FLAG(a, global); @@ -91,9 +94,6 @@ ANN /*static */ Symbol array_sym(const Env env, const Type src, return insert_symbol(name); } -#include "instr.h" -#include "operator.h" -#include "import.h" ANN Type array_type(const Env env, const Type src, const m_uint depth) { const Symbol sym = array_sym(env, src, depth); const Type type = nspc_lookup_type1(src->info->value->from->owner, sym); @@ -170,9 +170,7 @@ ANN bool from_global_nspc(const Env env, const Nspc nspc) { } ANN bool type_global(const Env env, Type t) { - while(t) { - if(from_global_nspc(env, t->info->value->from->owner)) return true; - t = t->info->value->from->owner_class; - } + do if(from_global_nspc(env, t->info->value->from->owner)) return true; + while((t = t->info->value->from->owner_class)); return false; } diff --git a/src/lib/dict.c b/src/lib/dict.c index d1a74ff3..55ec0802 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -252,8 +252,6 @@ static INSTR(hmap_iter) { handle(shred, "InvalidMapAccess"); } -static inline size_t grow(size_t c) { return c * 2; } - static INSTR(hmap_grow) { const M_Object o = *(M_Object*)(shred->reg - SZ_INT); const HMap *hmap = (HMap*)o->data; diff --git a/src/lib/lib_func.c b/src/lib/lib_func.c index 5ba2f0ff..fb7291e6 100644 --- a/src/lib/lib_func.c +++ b/src/lib/lib_func.c @@ -36,10 +36,11 @@ ANN static inline Exp cpy_nonext(const Env env, const Exp e) { return ret; } -ANN static Exp order_curry(const Env env, Exp fn, Exp arg) { +ANN static Exp order_curry(const Env env, Exp fn, const Exp _arg) { const MemPool mp = env->gwion->mp; Exp base = NULL; Exp next = NULL; + Exp arg = _arg; do { const bool hole = is_hole(env, fn); const Exp curr = !hole ? fn : arg; diff --git a/src/parse/check.c b/src/parse/check.c index 8c09181d..b572a14e 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1163,19 +1163,6 @@ ANN static inline m_bool for_empty(const Env env, const Stmt_For stmt) { return GW_OK; } -ANN static inline Type foreach_type(const Env env, const Exp exp) { - const Type et = exp->type; - if (isa(et, env->gwion->type[et_array]) < 0) - ERR_O(exp->pos, - _("type '%s' is not array.\n" - " This is not allowed in foreach loop"), - et->name) - DECL_OO(Type, base, = typedef_base(et)); - DECL_OO(const Type, t, = array_base_simple(base)); - const m_uint depth = base->array_depth - 1; - return depth ? array_type(env, t, depth) : t; -} - ANN static void check_idx(const Env env, const Type base, struct EachIdx_ *const idx) { idx->v = new_value(env->gwion->mp, base, s_name(idx->sym)); valuefrom(env, idx->v->from, idx->pos); @@ -1188,7 +1175,7 @@ ANN static m_bool check_each_idx(const Env env, const Exp exp, struct EachIdx_ * struct Op_Import opi = { .lhs = exp->type, .op = insert_symbol("@each_idx"), - .data = exp, + .data = (m_uint)exp, .pos = idx->pos }; DECL_OB(const Type, t, = op_check(env, &opi));