From: fennecdjay Date: Sat, 26 Oct 2019 19:15:15 +0000 (+0200) Subject: :art: link gwi_typedef X-Git-Tag: nightly~2116^2~24 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=c7cb3e5dcb6f209a6b5e378cabb49eb2ee140078;p=gwion.git :art: link gwi_typedef --- diff --git a/src/import/typedef.c b/src/import/typedef.c deleted file mode 100644 index 15e1b6d2..00000000 --- a/src/import/typedef.c +++ /dev/null @@ -1,45 +0,0 @@ -#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" - -ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) { - gwi->val.type = type; - gwi->val.name = name; - return GW_OK; -} - -ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) { - struct func_checker ck = { .name=gwi->val.name, .flag=flag }; - CHECK_BO(check_typename_def(gwi, &ck)) - Type_Decl* td = import_td(gwi, gwi->val.type, 0); // TODO: make it GW_PASS - if(td) { - td->flag |= flag; - const Symbol sym = insert_symbol(gwi->gwion->st, ck.name); - const Type_Def tdef = new_type_def(gwi->gwion->mp, td, sym); - if(ck.tmpl) - tdef->tmpl = new_tmpl(gwi->gwion->mp, ck.tmpl, -1); - traverse_type_def(gwi->gwion->env, tdef); - const Type t = tdef->type; - free_type_def(gwi->gwion->mp, tdef); - return t; - } - func_checker_clean(gwi, &ck); - return NULL; -} diff --git a/src/lib/import.c b/src/lib/import.c index fb42cbdc..8d113151 100644 --- a/src/lib/import.c +++ b/src/lib/import.c @@ -335,3 +335,28 @@ ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) { free_fptr_def(gwi->gwion->mp, fptr); return t; } + +ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) { + gwi->val.type = type; + gwi->val.name = name; + return GW_OK; +} + +ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) { + struct func_checker ck = { .name=gwi->val.name, .flag=flag }; + CHECK_BO(check_typename_def(gwi, &ck)) + Type_Decl* td = import_td(gwi, gwi->val.type, 0); // TODO: make it GW_PASS + if(td) { + td->flag |= flag; + const Symbol sym = insert_symbol(gwi->gwion->st, ck.name); + const Type_Def tdef = new_type_def(gwi->gwion->mp, td, sym); + if(ck.tmpl) + tdef->tmpl = new_tmpl(gwi->gwion->mp, ck.tmpl, -1); + traverse_type_def(gwi->gwion->env, tdef); + const Type t = tdef->type; + free_type_def(gwi->gwion->mp, tdef); + return t; + } + func_checker_clean(gwi, &ck); + return NULL; +}