#ifndef __IMPORT_SPECIAL
#define __IMPORT_SPECIAL
+#include "pass.h"
+
#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_register_freearg(const Gwi, const f_instr, const f_freearg);
+ANN void gwi_register_pass(const Gwi, const m_str, const compilation_pass);
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);
#ifndef __GWIONPASS
#define __GWIONPASS
+
+// change this to gwion ?
typedef m_bool (*compilation_pass)(Env, Ast);
ANN void pass_register(const Gwion, const m_str, const compilation_pass);
#include "gwi.h"
#include "parser.h"
#include "specialid.h"
+#include "pass.h"
-ANN void register_freearg(const Gwi gwi, const f_instr _exec, const f_freearg _free) {
+ANN void gwi_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_register_pass(const Gwi gwi, const m_str name, const compilation_pass pass) {
+ pass_register(gwi->gwion, name, pass);
+}
+
ANN void gwi_reserve(const Gwi gwi, const m_str str) {
vector_add(&gwi->gwion->data->reserved, (vtype)insert_symbol(gwi->gwion->st, str));
}
GWI_BB(gwi_oper_add(gwi, opck_array_cast))
GWI_BB(gwi_oper_emi(gwi, opem_basic_cast))
GWI_BB(gwi_oper_end(gwi, "$", NULL))
- register_freearg(gwi, ArrayAlloc, freearg_array);
+ gwi_register_freearg(gwi, ArrayAlloc, freearg_array);
return GW_OK;
}
GWI_BB(gwi_oper_add(gwi, opck_spork))
GWI_BB(gwi_oper_emi(gwi, opem_spork))
GWI_BB(gwi_oper_end(gwi, "fork", NULL))
- register_freearg(gwi, SporkIni, freearg_xork);
- register_freearg(gwi, ForkIni, freearg_xork);
- register_freearg(gwi, DotTmpl, freearg_dottmpl);
+ gwi_register_freearg(gwi, SporkIni, freearg_xork);
+ gwi_register_freearg(gwi, ForkIni, freearg_xork);
+ gwi_register_freearg(gwi, DotTmpl, freearg_dottmpl);
return GW_OK;
}
GWI_BB(gwi_oper_add(gwi, opck_at_tuple))
GWI_BB(gwi_oper_emi(gwi, opem_at_tuple))
GWI_BB(gwi_oper_end(gwi, "@=>", NULL))
- register_freearg(gwi, TupleUnpack, freearg_tuple_at);
+ gwi_register_freearg(gwi, TupleUnpack, freearg_tuple_at);
return GW_OK;
}
GWI_BB(gwi_oper_ini(gwi, "Object", "VarObject", NULL))
GWI_BB(gwi_oper_add(gwi, at_varobj))
GWI_BB(gwi_oper_end(gwi, "@=>", VarargAssign))
- register_freearg(gwi, VarargIni, freearg_vararg);
+ gwi_register_freearg(gwi, VarargIni, freearg_vararg);
struct SpecialId_ spid = { .type=t_vararg, .exec=RegPushImm, .is_const=1, .ck=idck_vararg};
gwi_specialid(gwi, "vararg", &spid);
return GW_OK;
--- /dev/null
+#include "gwion_util.h"
+#include "gwion_ast.h"
+#include "gwion_env.h"
+#include "vm.h"
+#include "object.h"
+#include "instr.h"
+#include "gwion.h"
+#include "operator.h"
+#include "import.h"
+#include "gwi.h"
+
+ANN static m_bool pass(Env nv NUSED, Ast ast NUSED) {
+ return GW_OK;
+}
+
+GWION_IMPORT(array_test) {
+ gwi_register_pass(gwi, "dummy", pass);
+ return GW_OK;
+}
#!/bin/bash
-# [test] #73
+# [test] #74
n=0
[ "$1" ] && n="$1"