From: fennecdjay Date: Thu, 24 Oct 2019 16:22:22 +0000 (+0200) Subject: :art: split import => special X-Git-Tag: nightly~2116^2~27 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=fda74c9920b135e40d6331ed79b0ba095724141d;p=gwion.git :art: split import => special --- diff --git a/include/import.h b/include/import.h index 78fae8f3..241896c4 100644 --- a/include/import.h +++ b/include/import.h @@ -63,12 +63,8 @@ ANN m_int gwi_func_ini(const Gwi gwi, const __restrict__ m_str type, const __res ANN m_int gwi_func_arg(const Gwi gwi, const __restrict__ m_str t, const __restrict__ m_str n); ANN m_int gwi_func_end(const Gwi gwi, const ae_flag flag); -ANN2(1) m_int gwi_oper_ini(const Gwi gwi, const m_str l, const m_str r, const m_str t); -ANN m_int gwi_oper_add(const Gwi gwi, const opck); -ANN m_int gwi_oper_emi(const Gwi gwi, const opem); -ANN2(1) m_int gwi_oper_end(const Gwi gwi, const m_str op, const f_instr f); -ANN m_int gwi_oper_cond(const Gwi, const m_str, const f_instr, const f_instr); -ANN Type_Decl* str2decl(const Env, const m_str, m_uint* depth, const loc_t); +#include "import/oper.h" +#include "import/special.h" OP_CHECK(opck_const_rhs); OP_CHECK(opck_unary_meta); @@ -85,11 +81,4 @@ OP_EMIT(opem_new); ANN Type_List str2tl(const Env env, const m_str s, const loc_t); -#define FREEARG(a) ANN void a(Instr instr NUSED, void *gwion NUSED) -typedef void (*f_freearg)(Instr, void*); -ANN void register_freearg(const Gwi, const f_instr, const f_freearg); -ANN void gwi_reserve(const Gwi, const m_str); -typedef struct SpecialId_* SpecialId; -ANN void gwi_specialid(const Gwi gwi, const m_str id, const SpecialId); -ANN void gwi_set_loc(const Gwi, const m_str, const uint); #endif diff --git a/include/import/special.h b/include/import/special.h new file mode 100644 index 00000000..a3a56e8b --- /dev/null +++ b/include/import/special.h @@ -0,0 +1,14 @@ +#ifndef __IMPORT_SPECIAL +#define __IMPORT_SPECIAL + +#define FREEARG(a) ANN void a(Instr instr NUSED, void *gwion NUSED) +typedef void (*f_freearg)(Instr, void*); +ANN void register_freearg(const Gwi, const f_instr, const f_freearg); +ANN void gwi_reserve(const Gwi, const m_str); +typedef struct SpecialId_* SpecialId; +ANN void gwi_specialid(const Gwi gwi, const m_str id, const SpecialId); +ANN void gwi_set_loc(const Gwi, const m_str, const uint); + +ANN Type_Decl* str2decl(const Env env, const m_str s, m_uint *depth, const loc_t pos); + +#endif diff --git a/src/import/special.c b/src/import/special.c new file mode 100644 index 00000000..55634764 --- /dev/null +++ b/src/import/special.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include "gwion_util.h" +#include "gwion_ast.h" +#include "oo.h" +#include "vm.h" +#include "env.h" +#include "type.h" +#include "value.h" +#include "traverse.h" +#include "instr.h" +#include "object.h" +#include "emit.h" +#include "func.h" +#include "nspc.h" +#include "gwion.h" +#include "operator.h" +#include "import.h" +#include "gwi.h" +#include "gwi.h" +#include "parser.h" +#include "specialid.h" + +ANN void register_freearg(const Gwi gwi, const f_instr _exec, const f_freearg _free) { + map_set(&gwi->gwion->data->freearg, (vtype)_exec, (vtype)_free); +} + +ANN void gwi_reserve(const Gwi gwi, const m_str str) { + vector_add(&gwi->gwion->data->reserved, (vtype)insert_symbol(gwi->gwion->st, str)); +} + +ANN void gwi_specialid(const Gwi gwi, const m_str id, const SpecialId spid) { + struct SpecialId_ *a = mp_calloc(gwi->gwion->mp, SpecialId); + memcpy(a, spid, sizeof(struct SpecialId_)); + map_set(&gwi->gwion->data->id, (vtype)insert_symbol(gwi->gwion->st, id), (vtype)a); + gwi_reserve(gwi, id); +} + +ANN void gwi_set_loc(const Gwi gwi, const m_str file, const uint line) { + gwi->loc->first_line = gwi->loc->last_line = line; + gwi->gwion->env->name = file; +} diff --git a/src/lib/import.c b/src/lib/import.c index fcb311bc..53ff0fc6 100644 --- a/src/lib/import.c +++ b/src/lib/import.c @@ -702,23 +702,3 @@ ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) { gwi->union_data.type_name = NULL; return t; } - -ANN void register_freearg(const Gwi gwi, const f_instr _exec, const f_freearg _free) { - map_set(&gwi->gwion->data->freearg, (vtype)_exec, (vtype)_free); -} - -ANN void gwi_reserve(const Gwi gwi, const m_str str) { - vector_add(&gwi->gwion->data->reserved, (vtype)insert_symbol(gwi->gwion->st, str)); -} - -ANN void gwi_specialid(const Gwi gwi, const m_str id, const SpecialId spid) { - struct SpecialId_ *a = mp_calloc(gwi->gwion->mp, SpecialId); - memcpy(a, spid, sizeof(struct SpecialId_)); - map_set(&gwi->gwion->data->id, (vtype)insert_symbol(gwi->gwion->st, id), (vtype)a); - gwi_reserve(gwi, id); -} - -ANN void gwi_set_loc(const Gwi gwi, const m_str file, const uint line) { - gwi->loc->first_line = gwi->loc->last_line = line; - gwi->gwion->env->name = file; -}