-Subproject commit 48c6d265b7d93dab3b0a70c20f2009cce191ef15
+Subproject commit 04455130567c1311a12ac408fb9b06e965cf66b7
+++ /dev/null
-#ifndef __CPY_AST
-#define __CPY_AST
-ANN Array_Sub cpy_array_sub(MemPool, Array_Sub);
-ANN Type_Decl* cpy_type_decl(MemPool, const Type_Decl*);
-ANN Type_List cpy_type_list(MemPool, const Type_List);
-ANN Func_Def cpy_func_def(MemPool, const Func_Def);
-ANN Func_Def cpy_func_def(MemPool, Func_Def);
-ANN struct Func_Base_* cpy_func_base(MemPool, const struct Func_Base_*);
-ANN Class_Def cpy_class_def(MemPool, Class_Def);
-ANN Type_List cpy_type_list(MemPool p, const Type_List src);
-ANN Decl_List cpy_decl_list(MemPool p, const Decl_List src);
-ANN ID_List cpy_id_list(MemPool p, const ID_List src);
-ANN Tmpl* cpy_tmpl(MemPool p, const Tmpl *src);
-#endif
ANN m_bool already_defined(const Env env, const Symbol s, const loc_t pos);
ANN m_bool type_engine_check_prog(const Env, const Ast);
ANN m_bool traverse_func_template(const Env, const Func_Def);
-ANN ID_List str2list(const Env, const m_str path, m_uint* array_depth, const loc_t);
ANN2(1,3) void env_err(const Env, const struct YYLTYPE *pos, const m_str fmt, ...);
#endif
#ifndef __GWI
#define __GWI
-typedef struct {
- Type_Decl *td;
- struct Var_Decl_List_ list;
- struct Var_Decl_ var;
- struct Exp_ exp;
- size_t array_depth;
-} DL_Var;
-typedef struct {
- m_str name;
- m_str type;
-} DL_Value;
-
-typedef struct {
- m_str name;
- m_str type;
- f_xfun addr;
- DL_Value args[DLARG_MAX];
- uint narg;
-} DL_Func;
-
-typedef struct {
- Symbol op;
- m_str ret, lhs, rhs;
- Type (*ck)(Env, void*, m_bool*);
- Instr (*em)(Emitter, void*);
-} DL_Oper;
-
-typedef struct {
- m_str* list;
- size_t n;
-} Templater;
-
-typedef struct {
- m_str t;
- ID_List base, curr;
- struct Vector_ addr;
-} DL_Enum;
-
-typedef struct {
- m_str type_name;
- m_str name;
- Decl_List list;
-} DL_Union;
+#define loc(gwi) loc_cpy(gwi->gwion->mp, gwi->loc)
struct Gwi_ {
struct Gwion_* gwion;
Class_Body body;
- DL_Value val;
- DL_Var var;
- DL_Func func;
- DL_Enum enum_data;
- DL_Union union_data;
- DL_Oper oper;
- void* addr;
- Templater templater;
+ struct ImportCK *ck;
+ struct OperCK *oper; // _misc
loc_t loc;
};
ANN m_int gwi_add_type(const Gwi gwi, Type type);
ANN m_int gwi_set_global_type(const Gwi gwi, const Type type, const type_enum te);
ANN m_bool gwi_gack(const Gwi gwi, const Type type, const f_gack d);
-ANN2(1,2)m_int gwi_class_ini(const Gwi gwi, const Type type, const f_xtor pre_ctor, const f_xtor dtor);
-ANN m_int gwi_class_ext(const Gwi gwi, Type_Decl* td);
-ANN m_int gwi_class_end(const Gwi gwi);
-#include "import/item.h"
+#include "import/checker.h"
-ANN m_int gwi_fptr_ini(const Gwi gwi, const m_str __restrict__ type, const __restrict__ m_str name);
-ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag);
+#include "import/class.h"
+#include "import/item.h"
#include "import/typedef.h"
-ANN m_int gwi_tmpl_ini(const Gwi gwi, const m_uint n, const m_str *name);
-ANN m_int gwi_tmpl_end(const Gwi gwi);
-
ANN2(1) m_int gwi_union_ini(const Gwi gwi, const m_str type, const m_str name);
ANN m_int gwi_union_add(const Gwi gwi, const __restrict__ m_str type, const __restrict__ m_str name);
ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag);
-
+ANN void ck_clean_udef(MemPool, ImportCK*);
#include "import/enum.h"
-
-ANN m_int gwi_func_ini(const Gwi gwi, const __restrict__ m_str type, const __restrict__ m_str name, const f_xfun addr);
-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);
+#include "import/func.h"
#include "import/oper.h"
#include "import/special.h"
-#include "import/checker.h"
OP_CHECK(opck_const_rhs);
OP_CHECK(opck_unary_meta);
OP_EMIT(opem_basic_cast);
OP_EMIT(opem_new);
-ANN Type_List str2tl(const Env env, const m_str s, const loc_t);
-
#endif
#ifndef __IMPORT_CHECKER
#define __IMPORT_CHECKER
-struct func_checker { // name_checker ?
- m_str name;
- ID_List tmpl;
- const ae_flag flag;
+enum importck_type {
+ ck_edef,
+ ck_udef,
+ ck_tdef,
+ ck_oper,
+ ck_item,
+ ck_fdef
};
+typedef struct ImportCK { // name_checker ?
+ m_str name;
+ Symbol sym;
+ union {
+ ID_List tmpl;
+ Type (*ck)(Env, void*, m_bool*); // oper
+ Exp exp;
+ };
+ union {
+ Symbol xid;// union name
+ Instr (*em)(Emitter, void*); // oper
+ f_xfun addr;
+ };
+ union {
+ Decl_List list;// union
+ struct Vector_ v;
+// ID_List curr;// enum
+ m_str lhs;// oper
+ };
+ union {
+ Type_Decl *td; // typedef
+ ID_List curr;// enum
+ m_str rhs;// oper
+ };
+ ae_flag flag; // ????
+ enum importck_type type;
+} ImportCK;
+
+typedef struct OperCK { // name_checker ?
+ m_str name;
+ Symbol sym;
+ Type (*ck)(Env, void*, m_bool*); // oper
+ Instr (*em)(Emitter, void*); // oper
+ union {
+ Decl_List list;// union
+ struct Vector_ v;
+// ID_List curr;// enum
+ m_str lhs;// oper
+ };
+ union {
+ Type_Decl *td; // typedef
+ ID_List curr;// enum
+ m_str rhs;// oper
+ };
+ ae_flag flag; // ????
+ enum importck_type type;
+} OperCK;
+
struct array_checker {
m_str str;
Exp base, exp;
m_uint depth;
- loc_t pos;
+ m_uint sz;
m_bool is_exp;
};
-ANN void func_checker_clean(const Gwi gwi, struct func_checker *ck);
-ANN Type_Decl* import_td(const Gwi gwi, const m_str name, const m_bool is_exp);
-ANN m_bool check_typename_def(const Gwi gwi, struct func_checker *ck);
+ANN void func_checker_clean(const Gwi gwi, struct ImportCK *ck);
+ANN m_bool check_typename_def(const Gwi gwi, struct ImportCK *ck);
ANN ID_List tmpl_valid(const Gwi gwi, const m_str str);
+ANN Symbol str2sym(const Gwi gwi, const m_str path);
+ANN ID_List str2symlist(const Gwi gwi, const m_str path);
+ANN ID_List ck2list(const Gwi gwi, struct array_checker *ck);
+
+ANN m_bool ck_ini(const Gwi, const enum importck_type);
+ANN m_bool ck_ok(const Gwi, const enum importck_type);
+ANN void ck_end(const Gwi gwi);
+ANN void ck_clean(const Gwi gwi);
#endif
--- /dev/null
+#ifndef __IMPORT_CLASS
+#define __IMPORT_CLASS
+ANN2(1,2) Type gwi_class_ini(const Gwi gwi, const m_str, const m_str parent);
+ANN2(1) void gwi_class_xtor(const Gwi gwi, const f_xtor ctor, const f_xtor dtor);
+ANN m_int gwi_class_end(const Gwi gwi);
+#endif
ANN2(1) m_int gwi_enum_ini(const Gwi gwi, const m_str type);
ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint value);
ANN Type gwi_enum_end(const Gwi gwi);
-
+ANN void ck_clean_edef(MemPool, ImportCK*);
#endif
--- /dev/null
+#ifndef __IMPORT_FUNC
+#define __IMPORT_FUNC
+
+ANN m_int gwi_func_ini(const Gwi gwi, const __restrict__ m_str type, const __restrict__ m_str name);
+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 f_xfun addr, const ae_flag flag);
+ANN m_int gwi_fptr_ini(const Gwi gwi, const m_str __restrict__ type, const __restrict__ m_str name);
+ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag);
+ANN m_int gwi_func_arg(const Gwi gwi, const restrict m_str t, const restrict m_str n);
+ANN void ck_clean_fdef(MemPool, ImportCK*);
+#endif
ANN m_bool name_valid(const Gwi, const m_str);
+ANN Exp make_exp(const Gwi gwi, const m_str type, const m_str name);
+
+ANN void gwi_reset(const Gwi gwi);
#endif
ANN m_int gwi_item_ini(const Gwi gwi, const m_str type, const m_str name);
ANN2(1) m_int gwi_item_end(const Gwi gwi, const ae_flag flag, const m_uint* addr);
#define gwi_item_end(a, b, c) gwi_item_end(a, (const ae_flag)(b), (const m_uint*)c)
-
+ANN void ck_clean_item(MemPool, ImportCK*);
#endif
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);
+// TODO: move me
+ANN Type_Decl* str2decl(const Gwi, const m_str);
+ANN Var_Decl str2var(const Gwi, const m_str);
+ANN Var_Decl_List str2varlist(const Gwi, const m_str);
#endif
ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name);
ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag);
-
+ANN void ck_clean_tdef(MemPool, ImportCK*);
#endif
ANN static void emit_pre_ctor(const Emitter emit, const Type type) {
if(type->e->parent)
emit_pre_ctor(emit, type->e->parent);
- if(type->nspc->pre_ctor && !GET_FLAG(type, nonnull))
+ if(type->nspc && type->nspc->pre_ctor && !GET_FLAG(type, nonnull))
emit_ext_ctor(emit, type->nspc->pre_ctor);
+/*
+ if(type->nspc && !GET_FLAG(type, nonnull)) {
+ if(type->nspc->pre_ctor)
+ emit_ext_ctor(emit, type->nspc->pre_ctor);
+ if(type->nspc->ctor)
+ emit_ext_ctor(emit, type->nspc->ctor);
+ }
+*/
+ if(GET_FLAG(type, typedef) && type->e->parent->array_depth)
+ emit_array_extend(emit, type->e->parent, type->e->def->base.ext->array->exp);
if(GET_FLAG(type, template) && GET_FLAG(type, builtin)) {
const Type t = template_parent(emit->env, type);
if(t->nspc->pre_ctor)
return GW_OK;
}
-ANN static m_bool emit_exp_decl(const Emitter emit, const Exp_Decl* decl) {
+ANN /*static */m_bool emit_exp_decl(const Emitter emit, const Exp_Decl* decl) {
if(GET_FLAG(decl->type, template))
CHECK_BB(emit_exp_decl_template(emit, decl))
const m_bool global = GET_FLAG(decl->td, global);
return GW_ERROR;
}
-ANN static Type_List tmpl_tl(const Env env, const m_str name, const loc_t pos) {
- const m_str start = strchr(name, '<');
- const m_str end = strchr(name, '@');
- char c[strlen(name)];
- strcpy(c, start + 2);
- c[strlen(start) - strlen(end) - 4] = '\0';
- return str2tl(env, c, pos);
-}
-
ANN static inline m_bool traverse_emit_func_def(const Emitter emit, const Func_Def fdef) {
if(!fdef->base->ret_type)
CHECK_BB(traverse_func_def(emit->env, fdef))
struct dottmpl_ *dt = mp_calloc(emit->gwion->mp, dottmpl);
dt->name = s_name(insert_symbol(c));
dt->vt_index = f->def->base->tmpl->base;
- dt->tl = tmpl_tl(emit->env, c, td_pos(f->def->base->td));
+ dt->tl = cpy_type_list(emit->gwion->mp, f->def->base->tmpl->call);
dt->base = f->def;
instr->opcode = eOP_MAX;
instr->m_val = (m_uint)dt;
char c[sz + 1];
memcpy(c, f->name, sz);
c[sz] = '\0';
- dt->tl = tmpl_tl(emit->env, c, td_pos(f->def->base->td));
+ dt->tl = cpy_type_list(emit->gwion->mp, f->def->base->tmpl->call);
dt->name = s_name(insert_symbol(c));
dt->vt_index = f->def->base->tmpl->base;
dt->base = f->def;
}
ANN static m_bool emit_exp_typeof(const Emitter emit, const Exp_Typeof *exp) {
- regpushi(emit, (m_uint)actual_type(emit->gwion, exp->exp->type));
+ regpushi(emit, (m_uint)(actual_type(emit->gwion, exp->exp->type)));
return GW_OK;
}
SET_FLAG(type, emit);
nspc_allocdata(emit->gwion->mp, nspc);
emit_class_code(emit, type->name);
- if(cdef->base.ext && cdef->base.ext->array)
- CHECK_BB(emit_array_extend(emit, type->e->parent, cdef->base.ext->array->exp))
if(cdef->body)
CHECK_BB(scanx_body(emit->env, cdef, (_exp_func)emit_section, emit))
emit_class_finish(emit, nspc);
+/** @file: checker.c *
+ * \brief: functions to check names in import module *
+ * */
#include <ctype.h>
#include "gwion_util.h"
#include "gwion_ast.h"
#include "import.h"
#include "gwi.h"
+ANN m_bool array_check(const Gwi gwi, struct array_checker *ck);
+
+__attribute__((returns_nonnull))
+ANN static Symbol gwisym(const Gwi gwi, const m_str str) {
+ return insert_symbol(gwi->gwion->st, str);
+}
+
+//! check that there is no illegal character in the string
+// TODO: get rid of second argument, make it useless
ANN static m_bool check_illegal(const char c, const m_uint i) {
return isalnum(c) || c == '_' || (!i && c == '@');
}
-ANN ID_List path_valid(const Env env, const m_str path, const loc_t pos) {
+/** convert a string to a symbol, with error checking **/
+//ANN Symbol str2sym(const Env env, const m_str path, const loc_t pos) {
+ANN Symbol str2sym(const Gwi gwi, const m_str path) {
const size_t sz = strlen(path);
- if(path[0] == '.' || path[sz] == '.')
- ENV_ERR_O(pos, _("path '%s' must not ini or end with '.'."), path)
- char curr[sz + 1];
m_uint i;
+ char curr[sz + 1];
for(i = 0; i < sz; ++i) {
const char c = path[i];
if(c != '.') {
if(!check_illegal(c, i))
- ENV_ERR_O(pos, _("illegal character '%c' in path '%s'."), c, path)
+ GWI_ERR_O(_("illegal character '%c' in path '%s'."), c, path)
curr[i] = c;
} else
break;
}
curr[i++] = '\0';
- const ID_List list = new_id_list(env->gwion->mp,
- insert_symbol(env->gwion->st, curr), loc_cpy(env->gwion->mp, pos));
- if(i < sz)
- list->next = path_valid(env, path + i, pos);
+ return gwisym(gwi, curr);
+}
+
+ANN ID_List str2symlist(const Gwi gwi, const m_str path) {
+ DECL_OO(const Symbol, sym, = str2sym(gwi, path))
+ return new_id_list(gwi->gwion->mp, sym, loc(gwi));
+}
+
+ANN ID_List path_valid(const Gwi gwi, const m_str path) {
+ const size_t sz = strlen(path);
+ if(path[0] == '.' || path[sz] == '.')
+ GWI_ERR_O(_("path '%s' must not ini or end with '.'."), path)
+// DECL_OO(const Symbol, sym, = str2sym(gwi, path))
+// const ID_List list = new_id_list(gwi->gwion->mp, sym, loc(gwi));
+ const ID_List list = str2symlist(gwi, path);
+ if(strlen(s_name(list->xid)) < sz)
+ list->next = path_valid(gwi, path + strlen(s_name(list->xid)));
return list;
}
+
+//
+// similar to import array_sub ?
+ANN Array_Sub ck_array(MemPool mp, const m_uint depth) {
+ if(!depth)
+ return NULL;
+ const Array_Sub array = new_array_sub(mp, NULL);
+ array->depth = depth;
+ return array;
+}
+
+ANN Var_Decl str2var(const Gwi gwi, const m_str path) {
+ struct array_checker ck = { .str=path };
+ CHECK_BO(array_check(gwi, &ck))
+ const m_uint sz = strlen(path);
+ const m_uint len = sz - ck.sz;
+ char curr[len + 1];
+ memcpy(curr, path, len);
+ curr[len] = '\0';
+ DECL_OO(const Symbol, sym, = str2sym(gwi, curr))
+ const Array_Sub array = ck_array(gwi->gwion->mp, ck.depth);
+ return new_var_decl(gwi->gwion->mp, sym, array, loc(gwi));
+}
+
+ANN Var_Decl_List str2varlist(const Gwi gwi, const m_str path) {
+ const Var_Decl var = str2var(gwi, path);
+ return new_var_decl_list(gwi->gwion->mp, var, NULL);
+}
+
struct tmpl_checker {
const m_str str;
ID_List list;
- const loc_t pos;
+// const loc_t pos;
};
-ANN static m_bool tmpl_list(const Gwion gwion, struct tmpl_checker *ck) {
+ANN static m_bool tmpl_list(const Gwi gwi, struct tmpl_checker *ck) {
m_str s = ck->str;
const size_t sz = strlen(s);
char c[sz + 1];
if(!i || s[i+1] != '>')
break;
c[i] = '\0';
- ck->list = new_id_list(gwion->mp, insert_symbol(gwion->st, c),
- loc_cpy(gwion->mp, ck->pos));
+ ck->list = new_id_list(gwi->gwion->mp, gwisym(gwi, c), loc(gwi));
return GW_OK;
}
if(s[i] == ',') {
if(!i)break;
c[i] = '\0';
- ck->list = new_id_list(gwion->mp, insert_symbol(gwion->st, c),
- loc_cpy(gwion->mp, ck->pos));
- struct tmpl_checker _ck = { .str=ck->str + i + 1, .pos=ck->pos };
- CHECK_BB(tmpl_list(gwion, &_ck))
+ ck->list = new_id_list(gwi->gwion->mp, gwisym(gwi, c), loc(gwi));
+ struct tmpl_checker _ck = { .str=ck->str + i + 1 };
+ CHECK_BB(tmpl_list(gwi, &_ck))
ck->list->next = _ck.list;
return GW_OK;
}
return (ID_List)GW_ERROR;
if(!ret)
return NULL;
- struct tmpl_checker ck = { .str=str+2, .pos=gwi->loc };
- if(tmpl_list(gwi->gwion, &ck) == GW_ERROR)
+ struct tmpl_checker ck = { .str=str+2 };
+ if(tmpl_list(gwi, &ck) == GW_ERROR)
return (ID_List)GW_ERROR;
return ck.list;
}
return ret;
}
-ANN ID_List str2list(const Env env, const m_str path,
- m_uint* array_depth, const loc_t pos) {
- const m_uint sz = strlen(path);
- m_uint len = sz, depth = 0;
- while(len > 2 && path[len - 1] == ']' && path[len - 2] == '[') {
- depth++;
- len -= 2;
- }
- *array_depth = depth;
- char curr[sz + 1];
- memcpy(curr, path, len);
+ANN ID_List ck2list(const Gwi gwi, struct array_checker *ck) {
+ const m_str base = ck->str;
+ CHECK_BO(array_check(gwi, ck))
+ const m_uint sz = strlen(base);
+ const m_uint len = sz - ck->sz;
+ char curr[len + 1];
+ memcpy(curr, base, len);
curr[len] = '\0';
- return path_valid(env, curr, pos);
+ return path_valid(gwi, curr);
}
-ANN Type_List _str2tl(const Env env, const m_str s, const loc_t pos) {
- m_uint depth;
- DECL_OO(Type_Decl*, td, = str2decl(env, s, &depth, pos))
- if(depth) {
- td->array = new_array_sub(env->gwion->mp, NULL);
- td->array->depth = depth;
- }
-// td->array = import_array(env->gwion->mp, NULL, &depth, 0);
- return new_type_list(env->gwion->mp, td, NULL);
+ANN static Type_List str2tl(const Gwi gwi, const m_str s);
+ANN static Type_List _str2tl(const Gwi gwi, const m_str s) {
+ DECL_OO(Type_Decl*, td, = str2decl(gwi, s))
+ return new_type_list(gwi->gwion->mp, td, NULL);
}
-ANN Type_List tlnext(const Env env, const m_str s, size_t split, const loc_t pos) {
+ANN Type_List tlnext(const Gwi gwi, const m_str s, size_t split) {
char curr[split+1];
strncpy(curr, s, split);
curr[split] = '\0';
- const Type_List tl = _str2tl(env, curr, pos);
- tl->next = str2tl(env, s + split + 1, pos);
+ const Type_List tl = _str2tl(gwi, curr);
+ tl->next = str2tl(gwi, s + split + 1);
return tl;
}
const size_t sz;
};
+//! a funtion factory to open/close the template
#define tl_xxx(name, tgt, op) \
ANN m_bool tl_##name(struct GetTl *gtl, const m_uint i) { \
if(!(i < gtl->sz && gtl->str[i] == tgt)) \
tl_xxx(open, '~', ++)
tl_xxx(close, '>', --)
-ANN Type_List str2tl(const Env env, const m_str s, const loc_t pos) {
+ANN static Type_List str2tl(const Gwi gwi, const m_str s) {
struct GetTl gtl = { .str=s, .sz = strlen(s) };
for(m_uint i = 0; i < gtl.sz; ++i) {
if(s[i] == '<')
else if(s[i] == '~')
CHECK_BO(tl_close(>l, ++i))
else if(s[i] == ',' && !gtl.lvl)
- return tlnext(env, s, i, pos);
+ return tlnext(gwi, s, i);
}
- return _str2tl(env, s, pos);
+ return _str2tl(gwi, s);
}
-ANN Type_Decl* str2decl(const Env env, const m_str s, m_uint *depth, const loc_t pos) {
- DECL_OO(const m_str, type_name, = get_type_name(env, s, 0))
- DECL_OO(ID_List, id, = str2list(env, type_name, depth, pos))
- Type_Decl* td = new_type_decl(env->gwion->mp, id);
- const m_str tl_name = get_type_name(env, s, 1);
+//! convert a string to a Type_Decl
+ANN Type_Decl* str2decl(const Gwi gwi, const m_str s) {
+// we can do better
+ DECL_OO(const m_str, type_name, = get_type_name(gwi->gwion->env, s, 0))
+ struct array_checker ck = { .str=type_name };
+ const ID_List id = ck2list(gwi, &ck);
+ if(id == (ID_List)GW_ERROR)
+ return NULL;
+ Type_Decl* td = new_type_decl(gwi->gwion->mp, id);
+ const m_str tl_name = get_type_name(gwi->gwion->env, s, 1);
if(tl_name) {
- if(!(td->types = str2tl(env, tl_name, pos))) {
- free_type_decl(env->gwion->mp, td);
+ if(!(td->types = str2tl(gwi, tl_name))) {
+ free_type_decl(gwi->gwion->mp, td);
return NULL;
}
}
+ if(ck.depth) {
+ td->array = new_array_sub(gwi->gwion->mp, ck.exp);
+ td->array->depth = ck.depth;
+ }
return td;
}
++ck->is_exp;
}
-ANN m_bool array_check(const Env env, struct array_checker *ck) {
+ANN m_bool _array_check(const Gwi gwi, struct array_checker *ck) {
const size_t sz = strlen(ck->str);
char tmp[sz + 1];
for(m_uint i = 0; i < sz; ++i) {
const m_bool is_end = ck->str[i + 1] == '\0';
if(!is_end && ck->str[i + 1] != '[')
break;
- ck->str += i + 1;
- ++ck->depth;
+ ck->str += i + 2;
+ ck->sz += i + 2;
if(i) {
- if(ck->is_exp == GW_ERROR)
- ENV_ERR_B(ck->pos, _("subscript must be empty"))
if(!ck->is_exp && ck->depth)
break;
tmp[i] = '\0';
const m_uint num = strtol(tmp, NULL, 10);// migth use &endptr and check errno
- const Exp exp = new_exp_prim_int(env->gwion->mp, num, loc_cpy(env->gwion->mp, ck->pos));
+ const Exp exp = new_exp_prim_int(gwi->gwion->mp, num, loc(gwi));
array_add_exp(ck, exp);
} else {
if(ck->is_exp > 0)
break;
}
- return is_end ? GW_OK : array_check(env, ck);
+ ++ck->depth;
+ return is_end ? GW_OK : array_check(gwi, ck);
}
if(isdigit(c))
tmp[i] = c;
else
- ENV_ERR_B(ck->pos, _("invalid subscript '%c' in '%s'"), c, ck->str)
+ GWI_ERR_B(_("invalid subscript '%c' in '%s'"), c, ck->str)
}
- ENV_ERR_B(ck->pos, _("incoherent subscript '%s'"), ck->str)
+ GWI_ERR_B(_("incoherent subscript '%s'"), ck->str)
}
-ANN void func_checker_clean(const Gwi gwi, struct func_checker *ck) {
- if(ck->tmpl)
- free_id_list(gwi->gwion->mp, ck->tmpl);
+ANN m_bool array_check(const Gwi gwi, struct array_checker *ck) {
+ ck->str = ck->str ? strchr(ck->str, '[') : NULL;
+ if(!ck->str)
+ return GW_OK;
+ ++ck->str;
+ return _array_check(gwi, ck);
}
-ANN m_bool check_typename_def(const Gwi gwi, struct func_checker *ck) {
+ANN m_bool check_typename_def(const Gwi gwi, ImportCK *ck) {
const m_str base = ck->name;
- const m_str c = strchr(ck->name, '>');
- ck->name = !c ? ck->name : c + 1;
- CHECK_BB(name_valid(gwi, ck->name))
- if((ck->tmpl = tmpl_valid(gwi, base)) == (ID_List)GW_ERROR)
+ char str[strlen(base) + 1];
+ const m_str c = strchr(ck->name, '<');
+ strncpy(str, base, strlen(base) - (c ? strlen(c) : 0));
+ str[strlen(base) - (c ? strlen(c) : 0)] = '\0';
+ ck->name = str;
+ CHECK_OB((ck->sym = str2sym(gwi, str)))
+ if(c && (ck->tmpl = tmpl_valid(gwi, c)) == (ID_List)GW_ERROR)
return GW_ERROR;
+ ck->name = base;
return GW_OK;
}
+ANN m_bool ck_ini(const Gwi gwi, const enum importck_type t) {
+ if(gwi->ck) // TODO: improve error message
+ GWI_ERR_B(_("already importing"))
+ gwi->ck = mp_calloc2(gwi->gwion->mp, sizeof(ImportCK));
+ gwi->ck->type = t;
+ return GW_OK;
+}
-ANN Array_Sub import_array_sub(const Gwi gwi, const m_str str, const m_bool is_exp) {
- struct array_checker ck = { .str=str + 1, .pos=gwi->loc, .is_exp=is_exp };
- CHECK_BO(array_check(gwi->gwion->env, &ck))
- return new_array_sub(gwi->gwion->mp, ck.exp);
+ANN m_bool ck_ok(const Gwi gwi, const enum importck_type t) {
+ if(!gwi->ck)
+ GWI_ERR_B(_("import not started"))
+ if(gwi->ck->type == t)
+ return GW_OK;
+ // TODO: improve error message
+ GWI_ERR_B(_("already importing"))
}
-ANN Type_Decl* import_td(const Gwi gwi, const m_str name, const m_bool is_exp) {
- const m_str subscript = strchr(name, '[');
- const size_t sz = strlen(name), sub_sz = subscript ? strlen(subscript) : 0,
- tmp_sz = sz - sub_sz;
- char str[tmp_sz + 1];
- strncpy(str, name, tmp_sz);
- str[tmp_sz] = '\0';
- DECL_OO(const ID_List, type_path, = path_valid(gwi->gwion->env, str, gwi->loc))
- Type_Decl* td = new_type_decl(gwi->gwion->mp, type_path);
- if(subscript && !(td->array = import_array_sub(gwi, subscript, is_exp))) {
- free_type_decl(gwi->gwion->mp, td);
- return NULL;
- }
- return td;
+ANN void ck_end(const Gwi gwi) {
+ mp_free2(gwi->gwion->mp, sizeof(ImportCK), gwi->ck);
+ gwi->ck = NULL;
}
+
+typedef void (*cleaner) (MemPool, ImportCK*);
+static cleaner cleaners[] =
+{
+ ck_clean_edef,
+ ck_clean_udef,
+ ck_clean_tdef,
+NULL,// ck_clean_oper,
+ ck_clean_item,
+ ck_clean_fdef
+};
+
+ANN void ck_clean(const Gwi gwi) {
+ cleaners[gwi->ck->type](gwi->gwion->mp, gwi->ck);
+}
+
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#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 "mpool.h"
+#include "specialid.h"
+#include "template.h"
+
+ANN static m_bool mk_xtor(MemPool p, const Type type, const m_uint d, const ae_flag e) {
+ VM_Code* code = e == ae_flag_ctor ? &type->nspc->pre_ctor : &type->nspc->dtor;
+ const m_str name = type->name;
+ *code = new_vm_code(p, NULL, SZ_INT, e | ae_flag_member | ae_flag_builtin, name);
+ (*code)->native_func = (m_uint)d;
+ type->flag |= e;
+ return GW_OK;
+}
+
+ANN2(1,2) static void import_class_ini(const Env env, const Type t) {
+ t->nspc = new_nspc(env->gwion->mp, t->name);
+ t->nspc->parent = env->curr;
+ if(t->e->parent && t->e->parent->nspc) {
+ t->nspc->info->offset = t->e->parent->nspc->info->offset;
+ if(t->e->parent->nspc->info->vtable.ptr)
+ vector_copy2(&t->e->parent->nspc->info->vtable, &t->nspc->info->vtable);
+ }
+ t->e->owner = env->curr;
+ SET_FLAG(t, checked);
+ env_push_type(env, t);
+}
+
+
+ANN2(1) void gwi_class_xtor(const Gwi gwi, const f_xtor ctor, const f_xtor dtor) {
+ const Type t = gwi->gwion->env->class_def;
+ if(ctor)
+ mk_xtor(gwi->gwion->mp, t, (m_uint)ctor, ae_flag_ctor);
+ if(dtor)
+ mk_xtor(gwi->gwion->mp, t, (m_uint)dtor, ae_flag_dtor);
+}
+
+ANN2(1,2) Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent) {
+ struct ImportCK ck = { .name=name };
+ CHECK_BO(check_typename_def(gwi, &ck))
+ Type_Decl *td = str2decl(gwi, parent ?: "Object"); // check
+ Tmpl* tmpl = ck.tmpl ? new_tmpl(gwi->gwion->mp, ck.tmpl, -1) : NULL;
+ if(tmpl)
+ template_push_types(gwi->gwion->env, tmpl);
+ const Type p = known_type(gwi->gwion->env, td); // check
+ if(tmpl)
+ nspc_pop_type(gwi->gwion->mp, gwi->gwion->env->curr);
+ const Type t = new_type(gwi->gwion->mp, gwi->gwion->env->scope->type_xid, s_name(ck.sym), p);
+ t->e->def = new_class_def(gwi->gwion->mp, 0, ck.sym, td, NULL, loc(gwi));
+ t->e->def->base.tmpl = tmpl;
+ t->e->def->base.type = t;
+ t->e->parent = p;
+ if(td->array)
+ SET_FLAG(t, typedef);
+ if(ck.tmpl)
+ SET_FLAG(t, template);
+ else
+ SET_FLAG(t, scan1 | ae_flag_scan2 | ae_flag_check | ae_flag_emit);
+ gwi_add_type(gwi, t);
+ import_class_ini(gwi->gwion->env, t);
+ return t;
+}
+
+ANN m_int gwi_class_end(const Gwi gwi) {
+ if(!gwi->gwion->env->class_def)
+ GWI_ERR_B(_("import: too many class_end called."))
+ nspc_allocdata(gwi->gwion->mp, gwi->gwion->env->class_def->nspc);
+ env_pop(gwi->gwion->env, 0);
+ return GW_OK;
+}
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
+//! \file enum.c
+//! \brief enumerations utils
+
#include "gwion_util.h"
#include "gwion_ast.h"
#include "oo.h"
#include "import.h"
#include "gwi.h"
+//! start an enum definition
+//! \arg the importer
+//! \arg string defining a primitive type
+//! why is return type m_int ?
ANN2(1) m_int gwi_enum_ini(const Gwi gwi, const m_str type) {
- gwi->enum_data.t = type;
- vector_init(&gwi->enum_data.addr);
+ CHECK_BB(ck_ini(gwi, ck_edef))
+ if(type)
+ CHECK_OB((gwi->ck->sym = str2sym(gwi, type)))
+ vector_init(&gwi->ck->v);
return GW_OK;
}
-ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint i) {
- CHECK_BB(name_valid(gwi, name))
- const Gwion gwion = gwi->gwion;
- const ID_List list = new_id_list(gwion->mp, insert_symbol(gwion->st, name),
- loc_cpy(gwion->mp, gwi->loc));
- DL_Enum* d = &gwi->enum_data;
- ALLOC_PTR(gwion->mp, addr, m_int, i);
- vector_add(&gwi->enum_data.addr, (vtype)addr);
- if(!d->base)
- d->base = list;
+// adds the id_list to the enum
+// change that algo?
+ANN static void add2list(struct ImportCK* ck, const ID_List list) {
+ if(!ck->tmpl)
+ ck->tmpl = list;
else
- d->curr->next = list;
- d->curr = list;
- return list ? 1 : -1;
+ ck->curr->next = list;
+ ck->curr = list;
+}
+/*
+void Append(DL_Enum* d, const ID_List list) {
+ List* next = &d->base;
+ while (*next != NULL) next = &(*next)->Next;
+ *next = list;
+ next->next = NULL;
+}
+*/
+//! add an enum entry
+//! \arg the importer
+//! \arg name of the entry
+//! TODO: change return type to m_bool
+ANN m_int gwi_enum_add(const Gwi gwi, const m_str name, const m_uint i) {
+ CHECK_BB(ck_ok(gwi, ck_edef))
+ DECL_OB(const ID_List, list, = str2symlist(gwi, name))
+ add2list(gwi->ck, list);
+ ALLOC_PTR(gwi->gwion->mp, addr, m_int, i);
+ vector_add(&gwi->ck->v, (vtype)addr);
+ return GW_OK;
}
+//! set enum values
+//! \arg the importer
+//! \arg a vector of values
+//! \note [internal]
ANN static void import_enum_end(const Gwi gwi, const Vector v) {
- DL_Enum* d = &gwi->enum_data;
+ ImportCK *ck = gwi->ck;
for(m_uint i = 0; i < vector_size(v); i++) {
- Value value = (Value)vector_at(v, i);
- const m_uint addr = vector_at(&d->addr, i);
+ const Value value = (Value)vector_at(v, i);
+ const m_uint addr = vector_at(&ck->v, i);
SET_FLAG(value, builtin);
- ADD_REF(value->type);
+// ADD_REF(value->type); // what ?
if(!gwi->gwion->env->class_def)
value->d.ptr = (m_uint*)(addr ? addr : i);
else
value->d.ptr = (m_uint*)(addr ? *(m_uint*)addr : i);
}
- d->t = NULL;
- d->base = NULL;
- vector_release(&d->addr);
+ // better clean ?
}
+//! finish enum import
+//! \arg the importer
+//! TODO: check what happens in inside template class
ANN Type gwi_enum_end(const Gwi gwi) {
+ CHECK_BO(ck_ok(gwi, ck_edef))
const Gwion gwion = gwi->gwion;
- DL_Enum* d = &gwi->enum_data;
- const Enum_Def edef = new_enum_def(gwion->mp, d->base,
- d->t ? insert_symbol(gwion->st, d->t) : NULL, loc_cpy(gwion->mp, gwi->loc));
+ const Enum_Def edef = new_enum_def(gwion->mp, gwi->ck->tmpl,
+ gwi->ck->xid, loc(gwi));
const m_bool ret = traverse_enum_def(gwion->env, edef);
import_enum_end(gwi, &edef->values);
const Type t = ret > 0 ? edef->t : NULL;
free_enum_def(gwion->mp, edef);
+ vector_release(&gwi->ck->v);
+ ck_end(gwi);
return t;
}
+
+ANN void ck_clean_edef(MemPool mp, ImportCK *ck) {
+ if(ck->tmpl)
+ free_id_list(mp, ck->tmpl);
+ if(ck->v.ptr) {
+ for(m_uint i = 0; i < vector_size(&ck->v); ++i)
+ mp_free2(mp, SZ_INT, (m_uint*)vector_at(&ck->v, i));
+ vector_release(&ck->v);
+ }
+}
+
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#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"
+
+ANN2(1,2,3) static m_bool dl_func_init(const Gwi gwi, const restrict m_str t,
+ const restrict m_str n) {
+ CHECK_BB(ck_ini(gwi, ck_fdef))
+ gwi->ck->name = n;
+ CHECK_BB(check_typename_def(gwi, gwi->ck))
+ CHECK_OB((gwi->ck->td = str2decl(gwi, t)))
+ vector_init(&gwi->ck->v);
+ return GW_OK;
+}
+
+ANN m_int gwi_func_ini(const Gwi gwi, const restrict m_str t, const restrict m_str n) {
+ return dl_func_init(gwi, t, n);
+}
+
+ANN Arg_List make_dll_arg_list(const Vector v) {
+ Arg_List base = (Arg_List)vector_front(v), arg_list = base;
+ for(m_uint i = 1; i < vector_size(v); ++i)
+ arg_list = (arg_list->next = (Arg_List)vector_at(v, i));
+ vector_release(v);
+ return base;
+}
+
+ANEW ANN static Func_Base* gwi_func_base(const Gwi gwi, const ImportCK *ck) {
+ const Arg_List arg_list = make_dll_arg_list(&gwi->ck->v);
+ Func_Base *base = new_func_base(gwi->gwion->mp, ck->td, ck->sym, arg_list);
+ if(ck->tmpl)
+ base->tmpl = new_tmpl(gwi->gwion->mp, ck->tmpl, -1);
+ return base;
+}
+
+ANN static Func_Def import_fdef(const Gwi gwi, const ImportCK *ck) {
+ Func_Base* base = gwi_func_base(gwi, ck);
+ const Func_Def fdef = new_func_def(gwi->gwion->mp, base,
+ NULL, ck->flag | ae_flag_builtin, loc(gwi));
+ fdef->d.dl_func_ptr = (void*)(m_uint)ck->addr;
+ if(ck->tmpl)
+ SET_FLAG(fdef, template);
+ return fdef;
+}
+
+ANN static m_bool section_fdef(const Gwi gwi, const Func_Def fdef) {
+ Section* section = new_section_func_def(gwi->gwion->mp, fdef);
+ const Class_Body body = new_class_body(gwi->gwion->mp, section, NULL);
+ gwi_body(gwi, body);
+ return GW_OK;
+}
+
+ANN static m_bool error_fdef(const Gwi gwi, const Func_Def fdef) {
+ fdef->d.dl_func_ptr = NULL;
+ free_func_def(gwi->gwion->mp, fdef);
+ return GW_ERROR;
+}
+
+ANN m_int gwi_func_valid(const Gwi gwi, const ImportCK *ck) {
+ DECL_OB(Func_Def, fdef, = import_fdef(gwi, ck))
+ if(SAFE_FLAG(gwi->gwion->env->class_def, template))
+ /*return*/ section_fdef(gwi, fdef);
+ if(traverse_func_def(gwi->gwion->env, fdef) < 0)
+ return error_fdef(gwi, fdef);
+ ck_end(gwi);
+ return GW_OK;
+}
+
+ANN m_int gwi_func_end(const Gwi gwi, const f_xfun addr, const ae_flag flag) {
+ CHECK_BB(ck_ok(gwi, ck_fdef))
+ gwi->ck->addr = addr;
+ gwi->ck->flag = flag;
+ if(gwi_func_valid(gwi, gwi->ck) > 0)
+ return GW_OK;
+ return GW_ERROR;
+}
+
+ANN m_int gwi_func_arg(const Gwi gwi, const restrict m_str t, const restrict m_str n) {
+ CHECK_BB(ck_ok(gwi, ck_fdef))
+ DECL_OB(Type_Decl*, td, = str2decl(gwi, t))
+ const Var_Decl var = str2var(gwi, n);
+ if(var) {
+ const Arg_List arg = new_arg_list(gwi->gwion->mp, td, var, NULL);
+ vector_add(&gwi->ck->v, (vtype)arg);
+ return GW_OK;
+ }
+ free_type_decl(gwi->gwion->mp, td);
+ return GW_ERROR;
+}
+
+ANN m_int gwi_fptr_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) {
+ return dl_func_init(gwi, type, name);
+}
+
+ANN static Fptr_Def import_fptr(const Gwi gwi, ae_flag flag) {
+ Func_Base *base = gwi_func_base(gwi, gwi->ck);
+ return new_fptr_def(gwi->gwion->mp, base, flag | ae_flag_builtin);
+}
+
+ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) {
+ CHECK_BO(ck_ok(gwi, ck_fdef))
+ DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi, flag))
+ // what happens if it is in a template class ?
+ const m_bool ret = traverse_fptr_def(gwi->gwion->env, fptr);
+ if(fptr->base->func)
+ SET_FLAG(fptr->base->func, builtin);
+ const Type t = ret > 0 ? fptr->type : NULL;
+ free_fptr_def(gwi->gwion->mp, fptr);
+ ck_end(gwi);
+ return t;
+}
+
+ANN void ck_clean_fdef(MemPool mp, ImportCK *ck) {
+ if(ck->td)
+ free_type_decl(mp, ck->td);
+ if(ck->v.ptr) {
+ for(m_uint i = 0; i < vector_size(&ck->v); ++i) {
+ Arg_List list = (Arg_List)vector_at(&ck->v, i);
+ list->next = NULL;
+ free_arg_list(mp, list);
+ }
+ vector_release(&ck->v);
+ }
+ if(ck->tmpl)
+ free_id_list(mp, ck->tmpl);
+}
ANN m_bool name_valid(const Gwi gwi, const m_str a) {
return _name_valid(gwi, a[0] != '@' ? a : a + 1);
}
+
+ANN void gwi_reset(const Gwi gwi) {
+ if(gwi->ck)
+ ck_clean(gwi);
+ env_reset(gwi->gwion->env);
+}
#include "operator.h"
#include "import.h"
#include "gwi.h"
-#include "cpy_ast.h"
-
-#define GWI_ERR_B(a,...) { env_err(gwi->gwion->env, gwi->loc, (a), ## __VA_ARGS__); return GW_ERROR; }
-#define GWI_ERR_O(a,...) { env_err(gwi->gwion->env, gwi->loc, (a), ## __VA_ARGS__); return NULL; }
-#define ENV_ERR_B(pos, a,...) { env_err(env, pos, (a), ## __VA_ARGS__); return GW_ERROR; }
-#define ENV_ERR_O(pos, a,...) { env_err(env, pos, (a), ## __VA_ARGS__); return NULL; }
-
-ANN static void dl_var_new_exp_array(MemPool p, DL_Var* v) {
- v->td->array = new_array_sub(p, NULL);
- v->td->array->depth = v->array_depth;
-}
-
-ANN static void dl_var_set(MemPool p, DL_Var* v, const ae_flag flag) {
- v->list.self = &v->var;
- v->td->flag = flag;
- v->exp.exp_type = ae_exp_decl;
- v->exp.d.exp_decl.td = v->td;
- v->exp.d.exp_decl.list = &v->list;
- if(v->array_depth)
- dl_var_new_exp_array(p, v);
-}
-
-ANN static void dl_var_release(MemPool p, const DL_Var* v) {
- free_type_decl(p, v->td);
-}
ANN m_int gwi_item_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) {
- DL_Var* v = &gwi->var;
- memset(v, 0, sizeof(DL_Var));
- CHECK_BB(name_valid(gwi, name))
- v->var.xid = insert_symbol(gwi->gwion->st, name);
- if((v->td = str2decl(gwi->gwion->env, type, &v->array_depth, gwi->loc)))
+ CHECK_BB(ck_ini(gwi, ck_item))
+ if((gwi->ck->exp = make_exp(gwi, type, name)))
return GW_OK;
GWI_ERR_B(_(" ... during var import '%s.%s'."), gwi->gwion->env->name, name)
}
-ANN2(1) m_int gwi_item_tmpl(const Gwi gwi) {
+ANN static m_int gwi_item_tmpl(const Gwi gwi) {
const MemPool mp = gwi->gwion->mp;
- DL_Var* v = &gwi->var;
- Type_Decl *td = cpy_type_decl(mp, v->td);
- const Var_Decl var = new_var_decl(mp, v->var.xid, v->var.array,
- loc_cpy(mp, gwi->loc));
- const Var_Decl_List vlist = new_var_decl_list(mp, var, NULL);
- const Exp exp = new_exp_decl(mp, td, vlist);
- const Stmt stmt = new_stmt_exp(mp, ae_stmt_exp, exp);
+ const Stmt stmt = new_stmt_exp(mp, ae_stmt_exp, gwi->ck->exp);
const Stmt_List slist = new_stmt_list(mp, stmt, NULL);
Section* section = new_section_stmt_list(mp, slist);
const Class_Body body = new_class_body(mp, section, NULL);
gwi_body(gwi, body);
+ mp_free2(gwi->gwion->mp, sizeof(ImportCK), gwi->ck);
+ gwi->ck = NULL;
return GW_OK;
}
#undef gwi_item_end
ANN2(1) m_int gwi_item_end(const Gwi gwi, const ae_flag flag, const m_uint* addr) {
+ CHECK_BB(ck_ok(gwi, ck_item))
const Env env = gwi->gwion->env;
- DL_Var* v = &gwi->var;
- dl_var_set(gwi->gwion->mp, v, flag | ae_flag_builtin);
- v->var.addr = (void*)addr;
+ gwi->ck->exp->d.exp_decl.list->self->addr = (m_uint*)addr;
+ gwi->ck->exp->d.exp_decl.td->flag = flag;
if(env->class_def && GET_FLAG(env->class_def, template))
return gwi_item_tmpl(gwi);
- v->exp.pos = gwi->loc;
- CHECK_BB(traverse_decl(env, &v->exp.d.exp_decl))
- SET_FLAG(v->var.value, builtin);
- dl_var_release(gwi->gwion->mp, v);
- return (m_int)v->var.value->from->offset;
+ CHECK_BB(traverse_decl(env, &gwi->ck->exp->d.exp_decl))
+ const Value value = gwi->ck->exp->d.exp_decl.list->self->value;
+ SET_FLAG(value, builtin);
+ const m_uint offset = value->from->offset;
+ free_exp(gwi->gwion->mp, gwi->ck->exp);
+ ck_end(gwi);
+ return offset;
+}
+
+ANN void ck_clean_item(MemPool mp, ImportCK* ck) {
+ if(ck->exp)
+ free_exp(mp, ck->exp);
}
#include "mpool.h"
#include "specialid.h"
-ANN2(1,3) static Type _get_type(const Env env, const m_str str, const loc_t pos) {
- m_uint depth = 0;
- const ID_List list = (str && str != (m_str)OP_ANY_TYPE) ? str2list(env, str, &depth, pos) : NULL;
- const Type t = (str == (m_str) OP_ANY_TYPE) ? OP_ANY_TYPE : list ? find_type(env, list) : NULL;
+ANN static Type _get_type(const Gwi gwi, const m_str str) {
+ if(str == (m_str)OP_ANY_TYPE)
+ return OP_ANY_TYPE;
+ struct array_checker ck = { .str=str };
+ const ID_List list = ck2list(gwi, &ck);
+ const Type t = find_type(gwi->gwion->env, list);
if(list)
- free_id_list(env->gwion->mp, list);
- return t ? (depth ? array_type(env, t, depth) : t) : NULL;
+ free_id_list(gwi->gwion->mp, list);
+ return t ? (ck.depth ? array_type(gwi->gwion->env, t, ck.depth) : t) : NULL;
}
-ANN2(1,3) static inline Type get_type(const Env env, const m_str str, const loc_t pos) {
- return str ? _get_type(env, str, pos) : NULL;
+ANN2(1) static inline Type get_type(const Gwi gwi, const m_str str) {
+ return str ? _get_type(gwi, str) : NULL;
}
-ANN2(1,2) static int import_op(const Gwi gwi, const DL_Oper* op,
+ANN2(1,2) static int import_op(const Gwi gwi, const struct OperCK* op,
const f_instr f) {
- const Env env = gwi->gwion->env;
- const Type lhs = get_type(env, op->lhs, gwi->loc),
- rhs = get_type(env, op->rhs, gwi->loc),
- ret = _get_type(env, op->ret, gwi->loc);
+ const Type lhs = get_type(gwi, op->lhs),
+ rhs = get_type(gwi, op->rhs),
+ ret = get_type(gwi, op->name);
const struct Op_Import opi = { lhs, rhs, ret,
- op->ck, op->em, (uintptr_t)f, gwi->loc, op->op };
+ op->ck, op->em, (uintptr_t)f, gwi->loc, op->sym };
return add_op(gwi->gwion, &opi);
}
ANN2(1) m_int gwi_oper_ini(const Gwi gwi, const restrict m_str l,
const restrict m_str r, const restrict m_str t) {
- gwi->oper.ret = t;
- gwi->oper.rhs = r;
- gwi->oper.lhs = l;
+ gwi->oper->name = t;
+ gwi->oper->rhs = r;
+ gwi->oper->lhs = l;
return GW_OK;
}
ANN m_int gwi_oper_add(const Gwi gwi, Type (*ck)(Env, void*, m_bool*)) {
- gwi->oper.ck = ck;
+ gwi->oper->ck = ck;
return GW_OK;
}
ANN m_int gwi_oper_emi(const Gwi gwi, const opem em) {
- gwi->oper.em = em;
+ gwi->oper->em = em;
return GW_OK;
}
ANN m_int gwi_oper_end(const Gwi gwi, const m_str op, const f_instr f) {
- gwi->oper.op = insert_symbol(gwi->gwion->st, op);
- const m_bool ret = import_op(gwi, &gwi->oper, f);
- gwi->oper.ck = NULL;
- gwi->oper.em = NULL;
+ gwi->oper->sym = insert_symbol(gwi->gwion->st, op);
+ const m_bool ret = import_op(gwi, gwi->oper, f);
+ gwi->oper->ck = NULL;
+ gwi->oper->em = NULL;
return ret;
}
gwi->loc->first_line = gwi->loc->last_line = line;
gwi->gwion->env->name = file;
}
+
+ANN static m_bool mk_gack(MemPool p, const Type type, const f_gack d) {
+ const VM_Code code = new_vm_code(p, NULL, SZ_INT, ae_flag_member | ae_flag_builtin, "@gack");
+ code->native_func = (m_uint)d;
+ type->e->gack = code;
+ return GW_OK;
+}
+
+ANN m_bool gwi_gack(const Gwi gwi, const Type type, const f_gack d) {
+ return mk_gack(gwi->gwion->mp, type, d);
+}
+
+ANN VM* gwi_vm(const Gwi gwi) {
+ return gwi->gwion->vm;
+}
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#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"
+
+ANN2(1,2) Type gwi_mk_type(const Gwi gwi NUSED, const m_str name, const m_uint size, const m_str parent_name) {
+ CHECK_OO(str2sym(gwi, name))
+ Type_Decl* td = parent_name ? str2decl(gwi, parent_name) : NULL;
+ if(td) {
+ if(td->array || td->types) {
+ free_type_decl(gwi->gwion->mp, td);
+ GWI_ERR_O(_("can't use gwi_mk_type to extend %s types"),
+ td->array ? "array" : "template")
+ }
+ }
+ const Type parent = td ? known_type(gwi->gwion->env, td) : NULL;
+ const Type t = new_type(gwi->gwion->mp, 0, name, parent);
+ t->size = size;
+ return t;
+}
+
+ANN m_int gwi_add_type(const Gwi gwi, const Type type) {
+ env_add_type(gwi->gwion->env, type);
+ return (m_int)type->xid;
+}
+
+ANN m_int gwi_set_global_type(const Gwi gwi, const Type type, const type_enum te) {
+ gwi->gwion->type[te] = type;
+ return gwi_add_type(gwi, type);
+}
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#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 "mpool.h"
+#include "specialid.h"
+
+ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) {
+ CHECK_BB(ck_ini(gwi, ck_tdef))
+ gwi->ck->name = name;
+ if(check_typename_def(gwi, gwi->ck) > 0)
+ return (gwi->ck->td = str2decl(gwi, type)) ? GW_OK : GW_ERROR;
+ return GW_ERROR;
+}
+
+ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) {
+ CHECK_BO(ck_ok(gwi, ck_tdef))
+ Type_Decl *td = gwi->ck->td;
+ td->flag |= flag;
+ const Type_Def tdef = new_type_def(gwi->gwion->mp, td, gwi->ck->sym);
+ if(td->types)
+ tdef->tmpl = new_tmpl(gwi->gwion->mp, gwi->ck->tmpl, -1);
+ const m_bool ret = traverse_type_def(gwi->gwion->env, tdef);
+ const Type t = tdef->type;
+ free_type_def(gwi->gwion->mp, tdef);
+ ck_end(gwi);
+ return ret > 0 ? t : NULL;
+}
+
+ANN void ck_clean_tdef(MemPool mp, ImportCK *ck) {
+ if(ck->td)
+ free_type_decl(mp, ck->td);
+ if(ck->tmpl)
+ free_id_list(mp, ck->tmpl);
+}
#include "import.h"
#include "gwi.h"
-ANN static Exp make_exp(const Gwi gwi, const m_str type, const m_str name) {
- const Env env = gwi->gwion->env;
- m_uint array_depth;
- Array_Sub array = NULL;
- DECL_OO(const ID_List, id_list, = str2list(env, type, &array_depth, gwi->loc))
- if(array_depth) {
- array = new_array_sub(env->gwion->mp, NULL);
- array->depth = array_depth;
- }
- Type_Decl *type_decl = new_type_decl(env->gwion->mp, id_list);
- const Var_Decl var_decl = new_var_decl(env->gwion->mp,
- insert_symbol(env->gwion->st, name), array, loc_cpy(env->gwion->mp, gwi->loc));
- const Var_Decl_List var_decl_list = new_var_decl_list(env->gwion->mp, var_decl, NULL);
- return new_exp_decl(env->gwion->mp, type_decl, var_decl_list);
+// move me
+ANN Exp make_exp(const Gwi gwi, const m_str type, const m_str name) {
+ DECL_OO(Type_Decl*, td, = str2decl(gwi, type))
+ const Var_Decl_List vlist = str2varlist(gwi, name);
+ if(vlist)
+ return new_exp_decl(gwi->gwion->mp, td, vlist);
+ free_type_decl(gwi->gwion->mp, td);
+ return NULL;
}
ANN2(1) m_int gwi_union_ini(const Gwi gwi, const m_str type, const m_str name) {
- gwi->union_data.type_name = type;
- gwi->union_data.name = name;
+ CHECK_BB(ck_ini(gwi, ck_udef))
+ if(name)
+ CHECK_OB((gwi->ck->sym = str2sym(gwi, name)))
+// gwi->ck->name = name;
+ gwi->ck->name = type;
+ if(type)
+ CHECK_BB(check_typename_def(gwi, gwi->ck))
return GW_OK;
}
ANN m_int gwi_union_add(const Gwi gwi, const restrict m_str type, const restrict m_str name) {
+ CHECK_BB(ck_ok(gwi, ck_udef))
DECL_OB(const Exp, exp, = make_exp(gwi, type, name))
- SET_FLAG(exp->d.exp_decl.td, ref);
- gwi->union_data.list = new_decl_list(gwi->gwion->mp, exp, gwi->union_data.list);
+ SET_FLAG(exp->d.exp_decl.td, ref); // might not be needed
+ gwi->ck->list = new_decl_list(gwi->gwion->mp, exp, gwi->ck->list);
return GW_OK;
}
emit_union_offset(udef->l, udef->o);
if(gwi->gwion->env->class_def && !GET_FLAG(udef, static))
gwi->gwion->env->class_def->nspc->info->offset =
- udef->o + udef->s;
+ udef->o + udef->s;
if(udef->xid || !udef->type_xid) {
SET_FLAG(udef->value, builtin);
const M_Object o = new_object(gwi->gwion->mp, NULL, udef->value->type);
}
ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) {
- if(!gwi->union_data.list)
+ CHECK_BO(ck_ok(gwi, ck_udef))
+ if(!gwi->ck->list)
GWI_ERR_O(_("union is empty"));
- if(gwi->union_data.name)
- CHECK_BO(name_valid(gwi, gwi->union_data.name))
- struct func_checker ck = { .name=gwi->union_data.type_name, .flag=flag };
- if(gwi->union_data.type_name)
- CHECK_BO(check_typename_def(gwi, &ck))
- const Symbol xid = gwi->union_data.name ? insert_symbol(gwi->gwion->st, gwi->union_data.name) : NULL;
- const Symbol type_xid = gwi->union_data.type_name ? insert_symbol(gwi->gwion->st, ck.name) : NULL;
- const Union_Def udef = new_union_def(gwi->gwion->mp, gwi->union_data.list, loc_cpy(gwi->gwion->mp, gwi->loc));
+ const Union_Def udef = new_union_def(gwi->gwion->mp, gwi->ck->list, loc(gwi));
udef->flag = flag;
- udef->xid = xid;
- udef->type_xid = type_xid;
- if(ck.tmpl) {
+ udef->xid = gwi->ck->xid;
+ udef->type_xid = gwi->ck->sym;
+ if(gwi->ck->tmpl) {
if(udef->xid)
- GWI_ERR_O(_("Template union type can't declare union"));
- udef->tmpl = new_tmpl(gwi->gwion->mp, ck.tmpl, -1);
+ GWI_ERR_O(_("Template union type can't declare instance at declaration"));
+ udef->tmpl = new_tmpl(gwi->gwion->mp, gwi->ck->tmpl, -1);
}
const Type t = union_type(gwi, udef);
if(!SAFE_FLAG(t, template))
free_union_def(gwi->gwion->mp, udef);
- gwi->union_data.list = NULL;
- gwi->union_data.name = NULL;
- gwi->union_data.type_name = NULL;
+ ck_end(gwi);
return t;
}
+
+ANN void ck_clean_udef(MemPool mp, ImportCK* ck) {
+ if(ck->list)
+ free_decl_list(mp, ck->list);
+ if(ck->tmpl)
+ free_id_list(mp, ck->tmpl);
+ if(ck->td)
+ free_type_decl(mp, ck->td);
+}
}
GWION_IMPORT(array) {
- const Type t_array = gwi_mk_type(gwi, "@Array", SZ_INT, "Object");
+ const Type t_array = gwi_class_ini(gwi, "@Array", NULL);
gwi->gwion->type[et_array] = t_array;
- GWI_BB(gwi_class_ini(gwi, t_array, NULL, array_dtor))
+ gwi_class_xtor(gwi, NULL, array_dtor);
- GWI_BB(gwi_item_ini(gwi, "int", "@array"))
+ GWI_BB(gwi_item_ini(gwi, "@internal", "@array"))
GWI_BB(gwi_item_end(gwi, 0, NULL))
- GWI_BB(gwi_func_ini(gwi, "int", "size", vm_vector_size))
- GWI_BB(gwi_func_end(gwi, 0))
- GWI_BB(gwi_func_ini(gwi, "int", "depth", vm_vector_depth))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_ini(gwi, "int", "size"))
+ GWI_BB(gwi_func_end(gwi, vm_vector_size, ae_flag_none))
+ GWI_BB(gwi_func_ini(gwi, "int", "depth"))
+ GWI_BB(gwi_func_end(gwi, vm_vector_depth, ae_flag_none))
- GWI_BB(gwi_func_ini(gwi, "int", "cap", vm_vector_cap))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_ini(gwi, "int", "cap"))
+ GWI_BB(gwi_func_end(gwi, vm_vector_cap, ae_flag_none))
- GWI_BB(gwi_func_ini(gwi, "int", "remove", vm_vector_rem))
+ GWI_BB(gwi_func_ini(gwi, "int", "remove"))
GWI_BB(gwi_func_arg(gwi, "int", "index"))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, vm_vector_rem, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
GWI_BB(gwi_oper_ini(gwi, "@Array", (m_str)OP_ANY_TYPE, NULL))
polar_def2_r(Mul, *, +)
polar_def2_r(Div, /, -)
+static GACK(gack_complex) {
+ printf("#(%.4f, %.4f)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT));
+}
+
+static GACK(gack_polar) {
+ printf("%%(%.4f, %.4f*pi)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT) / M_PI);
+}
+
GWION_IMPORT(complex) {
- GWI_BB(gwi_class_ini(gwi, gwi->gwion->type[et_complex], NULL, NULL))
+// should be special
+ const Type t_complex = gwi_class_ini(gwi, "complex", NULL);
+ t_complex->e->parent = NULL;
+ GWI_BB(gwi_gack(gwi, t_complex, gack_complex))
+ gwi->gwion->type[et_complex] = t_complex; // use func
gwi_item_ini(gwi, "float", "re");
GWI_BB(gwi_item_end(gwi, ae_flag_member, NULL))
gwi_item_ini(gwi, "float", "im");
GWI_BB(gwi_item_end(gwi, ae_flag_member, NULL))
GWI_BB(gwi_class_end(gwi))
- GWI_BB(gwi_class_ini(gwi, gwi->gwion->type[et_polar], NULL, NULL))
+// should be special
+ const Type t_polar = gwi_class_ini(gwi, "polar", NULL);
+ t_polar->e->parent = NULL;
+ gwi->gwion->type[et_polar] = t_polar;
+ GWI_BB(gwi_gack(gwi, t_polar, gack_polar))
GWI_BB(gwi_item_ini(gwi, "float", "mod"))
GWI_BB(gwi_item_end(gwi, ae_flag_member, NULL))
GWI_BB(gwi_item_ini(gwi, "float", "phase"))
printf("%.4f", *(m_float*)VALUE);
}
-// we where using m_complex
-static GACK(gack_complex) {
- printf("#(%.4f, %.4f)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT));
-}
-static GACK(gack_polar) {
- printf("%%(%.4f, %.4f*pi)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT) / M_PI);
-}
-static GACK(gack_vec3) {
- printf("%%(%.4f, %.4f, %.4f)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT), *(m_float*)(VALUE + SZ_FLOAT*2));
-}
-static GACK(gack_vec4) {
- printf("%%(%.4f, %.4f, %.4f, %.4f)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT), *(m_float*)(VALUE + SZ_FLOAT*2), *(m_float*)(VALUE + SZ_FLOAT*3));
-}
-
#define mk_class_instr(op, arg0, arg1, ...) \
static INSTR(instr_class_##op) { \
POP_REG(shred, SZ_INT); \
GWI_BB(gwi_add_type(gwi, t_now))
struct SpecialId_ spid = { .type=t_now, .exec=RegPushNow, .is_const=1 };
gwi_specialid(gwi, "now", &spid);
- const Type t_complex = gwi_mk_type(gwi, "complex", SZ_COMPLEX , NULL);
- gwi->gwion->type[et_complex] = t_complex;
- GWI_BB(gwi_gack(gwi, t_complex, gack_complex))
- const Type t_polar = gwi_mk_type(gwi, "polar", SZ_COMPLEX , NULL);
- gwi->gwion->type[et_polar] = t_polar;
- GWI_BB(gwi_gack(gwi, t_polar, gack_polar))
- const Type t_vec3 = gwi_mk_type(gwi, "Vec3", SZ_VEC3, NULL);
- gwi->gwion->type[et_vec3] = t_vec3;
- GWI_BB(gwi_gack(gwi, t_vec3, gack_vec3))
- const Type t_vec4 = gwi_mk_type(gwi, "Vec4", SZ_VEC4, NULL);
- gwi->gwion->type[et_vec4] = t_vec4;
- GWI_BB(gwi_gack(gwi, t_vec4, gack_vec4))
+
+ GWI_BB(gwi_typedef_ini(gwi, "int", "@internal"))
+ GWI_BB(gwi_typedef_end(gwi, ae_flag_none))
+
GWI_BB(import_object(gwi))
- const Type t_union = gwi_mk_type(gwi, "@Union", SZ_INT, "Object");
+
+// TODO: check me
+ const Type t_union = gwi_class_ini(gwi, "@Union", NULL);
gwi->gwion->type[et_union] = t_union;
- GWI_BB(gwi_class_ini(gwi, t_union, NULL, NULL))
GWI_BB(gwi_class_end(gwi))
+
GWI_BB(import_tuple(gwi))
GWI_BB(import_array(gwi))
GWI_BB(import_event(gwi))
ANN m_bool type_engine_init(VM* vm, const Vector plug_dirs) {
vm->gwion->env->name = "[builtin]";
struct YYLTYPE loc = {};
- struct Gwi_ gwi = { .gwion=vm->gwion, .loc=&loc };
+ OperCK oper = {};
+ struct Gwi_ gwi = { .gwion=vm->gwion, .loc=&loc, .oper=&oper };
CHECK_BB(import_core_libs(&gwi))
vm->gwion->env->name = "[imported]";
for(m_uint i = 0; i < vector_size(plug_dirs); ++i) {
m_bool (*import)(Gwi) = (m_bool(*)(Gwi))vector_at(plug_dirs, i);
if(import && import(&gwi) < 0)
- env_reset(gwi.gwion->env);
+ gwi_reset(&gwi);
}
return GW_OK;
}
}
GWION_IMPORT(event) {
- const Type t_event = gwi_mk_type(gwi, "Event", SZ_INT, "Object");
- gwi->gwion->type[et_event] = t_event;
- GWI_BB(gwi_class_ini(gwi, t_event, event_ctor, event_dtor))
- GWI_BB(gwi_item_ini(gwi, "int", "@shreds"))
+ const Type t_event = gwi_class_ini(gwi, "Event", "Object");
+ gwi_class_xtor(gwi, event_ctor, event_dtor);
+ gwi->gwion->type[et_event] = t_event; // use func
+
+ GWI_BB(gwi_item_ini(gwi, "@internal", "@shreds"))
GWI_BB(gwi_item_end(gwi, ae_flag_member, NULL))
- GWI_BB(gwi_func_ini(gwi, "void", "signal", event_signal))
- GWI_BB(gwi_func_end(gwi, 0))
- GWI_BB(gwi_func_ini(gwi, "void", "broadcast", event_broadcast))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_ini(gwi, "void", "signal"))
+ GWI_BB(gwi_func_end(gwi, event_signal, ae_flag_none))
+ GWI_BB(gwi_func_ini(gwi, "void", "broadcast"))
+ GWI_BB(gwi_func_end(gwi, event_broadcast, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
GWI_BB(gwi_oper_ini(gwi, "Event", "@now", "int"))
_CHECK_OP("=>", eventwait, EventWait)
+++ /dev/null
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#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 "mpool.h"
-#include "specialid.h"
-
-#define GWI_ERR_B(a,...) { env_err(gwi->gwion->env, gwi->loc, (a), ## __VA_ARGS__); return GW_ERROR; }
-#define GWI_ERR_O(a,...) { env_err(gwi->gwion->env, gwi->loc, (a), ## __VA_ARGS__); return NULL; }
-#define ENV_ERR_B(pos, a,...) { env_err(env, pos, (a), ## __VA_ARGS__); return GW_ERROR; }
-#define ENV_ERR_O(pos, a,...) { env_err(env, pos, (a), ## __VA_ARGS__); return NULL; }
-
-#include "parser.h"
-struct Path {
- m_str path, curr;
- m_uint len;
- loc_t loc;
-};
-
-ANN static ID_List templater_def(SymTable *st, const Gwi gwi) {
- const Templater* templater = &gwi->templater;
- ID_List list[templater->n];
- list[0] = new_id_list(st->p, insert_symbol(st, templater->list[0]), loc_cpy(gwi->gwion->mp, gwi->loc));
- for(m_uint i = 1; i < templater->n; i++) {
- list[i] = new_id_list(st->p, insert_symbol(st, templater->list[i]), loc_cpy(gwi->gwion->mp, gwi->loc));
- list[i - 1]->next = list[i];
- }
- return list[0];
-}
-
-ANN VM* gwi_vm(const Gwi gwi) {
- return gwi->gwion->vm;
-}
-
-ANN m_int gwi_tmpl_end(const Gwi gwi) {
- gwi->templater.n = 0;
- gwi->templater.list = NULL;
- return GW_OK;
-}
-
-ANN m_int gwi_tmpl_ini(const Gwi gwi, const m_uint n, const m_str* list) {
- gwi->templater.n = n;
- gwi->templater.list = (m_str*)list;
- return GW_OK;
-}
-
-ANN2(1,2,3) static void dl_func_init(DL_Func* a, const restrict m_str t,
- const restrict m_str n, const f_xfun addr) {
- a->name = n;
- a->type = t;
- a->addr = addr;
- a->narg = 0;
-}
-
-ANN m_int gwi_func_ini(const Gwi gwi, const restrict m_str t, const restrict m_str n, const f_xfun addr) {
- dl_func_init(&gwi->func, t, n, addr);
- return GW_OK;
-}
-
-ANN static void dl_func_func_arg(DL_Func* a, const restrict m_str t, const restrict m_str n) {
- a->args[a->narg].type = t;
- a->args[a->narg++].name = n;
-}
-
-ANN m_int gwi_func_arg(const Gwi gwi, const restrict m_str t, const restrict m_str n) {
- if(gwi->func.narg == DLARG_MAX - 1)
- GWI_ERR_B(_("too many arguments for function '%s'."), gwi->func.name)
- dl_func_func_arg(&gwi->func, t, n);
- return GW_OK;
-}
-
-ANN static m_bool mk_gack(MemPool p, const Type type, const f_gack d) {
- const VM_Code code = new_vm_code(p, NULL, SZ_INT, ae_flag_member | ae_flag_builtin, "@gack");
- code->native_func = (m_uint)d;
- type->e->gack = code;
- return GW_OK;
-}
-
-ANN m_bool gwi_gack(const Gwi gwi, const Type type, const f_gack d) {
- return mk_gack(gwi->gwion->mp, type, d);
-}
-
-ANN static m_bool mk_xtor(MemPool p, const Type type, const m_uint d, const ae_flag e) {
- VM_Code* code = e == ae_flag_ctor ? &type->nspc->pre_ctor : &type->nspc->dtor;
- const m_str name = type->name;
- *code = new_vm_code(p, NULL, SZ_INT, e | ae_flag_member | ae_flag_builtin, name);
- (*code)->native_func = (m_uint)d;
- type->flag |= e;
- return GW_OK;
-}
-
-ANN2(1,2) Type gwi_mk_type(const Gwi gwi NUSED, const m_str name, const m_uint size, const m_str parent_name) {
- m_uint depth = 0;
- Type_Decl* td = parent_name ? str2decl(gwi->gwion->env, parent_name, &depth, gwi->loc) : NULL;
- if(depth) {
- free_type_decl(gwi->gwion->mp, td);
- GWI_ERR_O(_("can't create a type with explicit array parent. use typedef for that"))
- }
- const Type parent = td ? known_type(gwi->gwion->env, td) : NULL;
- const Type t = new_type(gwi->gwion->mp, 0, name, parent);
- t->size = size;
- return t;
-}
-
-ANN m_int gwi_add_type(const Gwi gwi, const Type type) {
- CHECK_BB(name_valid(gwi, type->name));
- env_add_type(gwi->gwion->env, type);
- return (m_int)type->xid;
-}
-
-ANN m_int gwi_set_global_type(const Gwi gwi, const Type type, const type_enum te) {
- GWI_BB(gwi_add_type(gwi, type))
- gwi->gwion->type[te] = type;
- return GW_OK;
-}
-
-ANN2(1,2) static void import_class_ini(const Env env, const Type type,
- const f_xtor pre_ctor, const f_xtor dtor) {
- type->nspc = new_nspc(env->gwion->mp, type->name);
- type->nspc->parent = env->curr;
- if(pre_ctor)
- mk_xtor(env->gwion->mp, type, (m_uint)pre_ctor, ae_flag_ctor);
- if(dtor)
- mk_xtor(env->gwion->mp, type, (m_uint)dtor, ae_flag_dtor);
- if(type->e->parent) {
- type->nspc->info->offset = type->e->parent->nspc->info->offset;
- if(type->e->parent->nspc->info->vtable.ptr)
- vector_copy2(&type->e->parent->nspc->info->vtable, &type->nspc->info->vtable);
- }
- type->e->owner = env->curr;
- SET_FLAG(type, checked);
- env_push_type(env, type);
-}
-
-ANN2(1,2) m_int gwi_class_ini(const Gwi gwi, const Type type, const f_xtor pre_ctor, const f_xtor dtor) {
- if(type->nspc)
- GWI_ERR_B(_("during import: class '%s' already imported."), type->name)
- if(gwi->templater.n) {
- const ID_List types = templater_def(gwi->gwion->st, gwi);
- type->e->def = new_class_def(gwi->gwion->mp, 0, insert_symbol(gwi->gwion->st, type->name), NULL, NULL, loc_cpy(gwi->gwion->mp, gwi->loc));
- type->e->def->base.tmpl = new_tmpl(gwi->gwion->mp, types, -1);
- type->e->def->base.type = type;
- SET_FLAG(type, template);
- } else
- SET_FLAG(type, scan1 | ae_flag_scan2 | ae_flag_check | ae_flag_emit);
- gwi_add_type(gwi, type);
- import_class_ini(gwi->gwion->env, type, pre_ctor, dtor);
- return (m_int)type->xid;
-}
-
-ANN m_int gwi_class_ext(const Gwi gwi, Type_Decl* td) {
- if(!gwi->gwion->env->class_def)
- GWI_ERR_B(_("gwi_class_ext invoked before gwi_class_ini"))
- const VM_Code ctor = gwi->gwion->env->class_def->nspc->pre_ctor;
- if(gwi->gwion->env->class_def->e->parent ||
- (gwi->gwion->env->class_def->e->def && gwi->gwion->env->class_def->e->def->base.ext))
- GWI_ERR_B(_("class extend already set"))
- if(td->array && !td->array->exp)
- GWI_ERR_B(_("class extend array can't be empty"))
- if(!gwi->gwion->env->class_def->e->def) {
- DECL_OB(const Type, t, = known_type(gwi->gwion->env, td))
- if(td->array)
- SET_FLAG(gwi->gwion->env->class_def, typedef);
- gwi->gwion->env->class_def->e->parent = t;
- gwi->gwion->env->class_def->nspc->info->offset = t->nspc->info->offset;
- if(t->nspc->info->vtable.ptr)
- vector_copy2(&t->nspc->info->vtable, &gwi->gwion->env->class_def->nspc->info->vtable);
- CHECK_OB((gwi->gwion->emit->code = emit_class_code(gwi->gwion->emit,
- gwi->gwion->env->class_def->name)))
- if(td->array)
- CHECK_BB(emit_array_extend(gwi->gwion->emit, t, td->array->exp))
- if(ctor)
- emit_ext_ctor(gwi->gwion->emit, ctor);
- emit_class_finish(gwi->gwion->emit, gwi->gwion->env->class_def->nspc);
- free_type_decl(gwi->gwion->mp, td);
- } else {
- SET_FLAG(td, typedef);
- gwi->gwion->env->class_def->e->def->base.ext = td;
- }
- return GW_OK;
-}
-
-ANN m_int gwi_class_end(const Gwi gwi) {
- if(!gwi->gwion->env->class_def)
- GWI_ERR_B(_("import: too many class_end called."))
- nspc_allocdata(gwi->gwion->mp, gwi->gwion->env->class_def->nspc);
- env_pop(gwi->gwion->env, 0);
- return GW_OK;
-}
-
-static Array_Sub make_dll_arg_list_array(MemPool p, Array_Sub array_sub,
- m_uint* array_depth, const m_uint array_depth2) {
- if(array_depth2)
- *array_depth = array_depth2;
- if(*array_depth) { // TODO: clean me
- array_sub = new_array_sub(p, NULL);
- for(m_uint i = 1; i < *array_depth; i++)
- array_sub = prepend_array_sub(array_sub, NULL);
- }
- return array_sub;
-}
-
-ANN static Arg_List make_dll_arg_list(const Gwi gwi, DL_Func * dl_fun) {
- const Env env = gwi->gwion->env;
- Arg_List arg_list = NULL;
- for(m_uint i = dl_fun->narg + 1; --i; ) {
- m_uint array_depth = 0, array_depth2 = 0;
- Type_Decl* type_decl = NULL;
- DL_Value* arg = &dl_fun->args[i-1];
- ID_List type_path2;
- if(!(type_decl = str2decl(env, arg->type, &array_depth, gwi->loc))) {
- if(arg_list)
- free_arg_list(env->gwion->mp, arg_list);
- GWI_ERR_O(_(" ... at argument '%"UINT_F"'"), i + 1)
- }
- if((type_path2 = str2list(env, arg->name, &array_depth2, gwi->loc)))
- free_id_list(env->gwion->mp, type_path2);
- if(array_depth && array_depth2) {
- free_type_decl(env->gwion->mp, type_decl);
- if(arg_list)
- free_arg_list(env->gwion->mp, arg_list);
- GWI_ERR_O(_("array subscript specified incorrectly for built-in module"));
- }
- const Array_Sub array_sub = make_dll_arg_list_array(env->gwion->mp, NULL, &array_depth, array_depth2);
- const Var_Decl var_decl = new_var_decl(env->gwion->mp, insert_symbol(env->gwion->st, arg->name), array_sub, loc_cpy(gwi->gwion->mp, gwi->loc));
- arg_list = new_arg_list(env->gwion->mp, type_decl, var_decl, arg_list);
- }
- return arg_list;
-}
-
-ANN static Func_Def make_dll_as_fun(const Gwi gwi, const struct func_checker *ck) {
- const MemPool mp = gwi->gwion->mp;
- DECL_OO(Type_Decl*, type_decl, = import_td(gwi, gwi->func.type, GW_ERROR))
- const m_str name = gwi->func.name;
- const Arg_List arg_list = make_dll_arg_list(gwi, &gwi->func);
- const Func_Def func_def = new_func_def(mp, new_func_base(mp, type_decl, insert_symbol(gwi->gwion->st, name), arg_list),
- NULL, ck->flag | ae_flag_builtin, loc_cpy(mp, gwi->loc));
- func_def->d.dl_func_ptr = (void*)(m_uint)gwi->func.addr;
- return func_def;
-}
-
-ANN static m_bool section_fdef(const Gwi gwi, const Func_Def fdef) {
- Section* section = new_section_func_def(gwi->gwion->mp, fdef);
- const Class_Body body = new_class_body(gwi->gwion->mp, section, NULL);
- gwi_body(gwi, body);
- return GW_OK;
-}
-
-ANN static m_bool error_fdef(const Gwi gwi, const Func_Def fdef) {
- fdef->d.dl_func_ptr = NULL;
- free_func_def(gwi->gwion->mp, fdef);
- return GW_ERROR;
-}
-
-ANN2(1) static Func_Def template_fdef(const Gwi gwi, const struct func_checker *ck) {
- const Arg_List arg_list = make_dll_arg_list(gwi, &gwi->func);
- m_uint depth;
- Type_Decl *td = str2decl(gwi->gwion->env, gwi->func.type, &depth, gwi->loc);
- if(depth)
- td->array = make_dll_arg_list_array(gwi->gwion->mp, NULL, &depth, 0);
- const Func_Def fdef = new_func_def(gwi->gwion->mp, new_func_base(gwi->gwion->mp,
- td, insert_symbol(gwi->gwion->st, ck->name), arg_list), NULL, ae_flag_builtin, loc_cpy(gwi->gwion->mp, gwi->loc));
- fdef->base->tmpl = new_tmpl(gwi->gwion->mp, ck->tmpl, -1);
- fdef->d.dl_func_ptr = (void*)(m_uint)gwi->func.addr;
- SET_FLAG(fdef, template | ae_flag_builtin);
- return fdef;
-}
-
-ANN m_int gwi_func_valid(const Gwi gwi, const struct func_checker *ck) {
- gwi->func.name = ck->name;
- DECL_OB(Func_Def, fdef, = (!ck->tmpl ? make_dll_as_fun : template_fdef)(gwi, ck))
- if(gwi->gwion->env->class_def && GET_FLAG(gwi->gwion->env->class_def, template))
- return section_fdef(gwi, fdef);
- if(traverse_func_def(gwi->gwion->env, fdef) < 0)
- return error_fdef(gwi, fdef);
- return GW_OK;
-}
-
-ANN m_int gwi_func_end(const Gwi gwi, const ae_flag flag) {
- struct func_checker ck = { .name=gwi->func.name, .flag=flag };
- CHECK_BB(check_typename_def(gwi, &ck))
- if(gwi_func_valid(gwi, &ck) > 0)
- return GW_OK;
- func_checker_clean(gwi, &ck);
- return GW_ERROR;
-}
-
-ANN m_int gwi_fptr_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) {
- dl_func_init(&gwi->func, type, name, 0);
- return GW_OK;
-}
-
-ANN static Fptr_Def import_fptr(const Gwi gwi, DL_Func* dl_fun, ae_flag flag) {
- const Env env = gwi->gwion->env;
- struct func_checker ck = { .name=gwi->func.name, .flag=flag };
- CHECK_BO(check_typename_def(gwi, &ck))
- m_uint depth;
- const ID_List type_path = str2list(env, dl_fun->type, &depth, gwi->loc);
- if(type_path) {
- Type_Decl *td = new_type_decl(env->gwion->mp, type_path);
- td->array = make_dll_arg_list_array(env->gwion->mp, NULL, &depth, 0);
- const Arg_List args = make_dll_arg_list(gwi, dl_fun);
- Func_Base *base = new_func_base(env->gwion->mp, td, insert_symbol(env->gwion->st, ck.name), args);
- if(ck.tmpl)
- base->tmpl = new_tmpl(gwi->gwion->mp, ck.tmpl, -1);
- return new_fptr_def(env->gwion->mp, base, flag | ae_flag_builtin);
- }
- func_checker_clean(gwi, &ck);
- return NULL;
-}
-
-ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) {
- DECL_OO(const Fptr_Def, fptr, = import_fptr(gwi, &gwi->func, flag))
- const m_bool ret = traverse_fptr_def(gwi->gwion->env, fptr);
- if(ret > 0)
- SET_FLAG(fptr->base->func, builtin);
- const Type t = ret > 0 ? fptr->type : NULL;
- 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;
-}
#include "value.h"
#include "operator.h"
#include "import.h"
-#include "cpy_ast.h"
INSTR(DTOR_EOC) {
const M_Object o = *(M_Object*)MEM(0);
}
static GWION_IMPORT(gain) {
- const Type t_gain = gwi_mk_type(gwi, "Gain", SZ_INT, "UGen");
- GWI_BB(gwi_class_ini(gwi, t_gain, gain_ctor, basic_dtor))
- gwi_func_ini(gwi, "float", "gain", gain_get_gain);
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "float", "gain", gain_set_gain);
+ GWI_OB(gwi_class_ini(gwi, "Gain", NULL))
+ gwi_class_xtor(gwi, gain_ctor, basic_dtor);
+ gwi_func_ini(gwi, "float", "gain");
+ GWI_BB(gwi_func_end(gwi, gain_get_gain, ae_flag_none))
+ gwi_func_ini(gwi, "float", "gain");
gwi_func_arg(gwi, "float", "arg0");
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, gain_set_gain, ae_flag_none))
return gwi_class_end(gwi);
}
}
static GWION_IMPORT(impulse) {
- const Type t_impulse = gwi_mk_type(gwi, "Impulse", SZ_INT, "UGen");
- GWI_BB(gwi_class_ini(gwi, t_impulse, impulse_ctor, basic_dtor))
- gwi_func_ini(gwi, "float", "next", impulse_get_next);
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "float", "next", impulse_set_next);
+ GWI_OB(gwi_class_ini(gwi, "Impulse", "UGen"))
+ gwi_class_xtor(gwi, impulse_ctor, basic_dtor);
+ gwi_func_ini(gwi, "float", "next");
+ GWI_BB(gwi_func_end(gwi, impulse_get_next, ae_flag_none))
+ gwi_func_ini(gwi, "float", "next");
gwi_func_arg(gwi, "float", "arg0");
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, impulse_set_next, ae_flag_none))
return gwi_class_end(gwi);
}
}
static GWION_IMPORT(fullrect) {
- const Type t_fullrect = gwi_mk_type(gwi, "FullRect", SZ_INT, "UGen");
- GWI_BB(gwi_class_ini(gwi, t_fullrect, fullrect_ctor, basic_dtor))
+ GWI_OB(gwi_class_ini(gwi, "FullRect", "UGen"))
+ gwi_class_xtor(gwi, fullrect_ctor, basic_dtor);
return gwi_class_end(gwi);
}
}
static GWION_IMPORT(halfrect) {
- const Type t_halfrect = gwi_mk_type(gwi, "HalfRect", SZ_INT, "UGen");
- GWI_BB(gwi_class_ini(gwi, t_halfrect, halfrect_ctor, basic_dtor))
+ GWI_OB(gwi_class_ini(gwi, "HalfRect", "UGen"))
+ gwi_class_xtor(gwi, halfrect_ctor, basic_dtor);
return gwi_class_end(gwi);
}
}
static GWION_IMPORT(step) {
- const Type t_step = gwi_mk_type(gwi, "Step", SZ_INT, "UGen");
- GWI_BB(gwi_class_ini(gwi, t_step, step_ctor, basic_dtor))
- gwi_func_ini(gwi, "float", "next", step_get_next);
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "float", "next", step_set_next);
+ GWI_OB(gwi_class_ini(gwi, "Step", "UGen"))
+ gwi_class_xtor(gwi, step_ctor, basic_dtor);
+ gwi_func_ini(gwi, "float", "next");
+ GWI_BB(gwi_func_end(gwi, step_get_next, ae_flag_none))
+ gwi_func_ini(gwi, "float", "next");
gwi_func_arg(gwi, "float", "arg0");
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, step_set_next, ae_flag_none))
return gwi_class_end(gwi);
}
}
static GWION_IMPORT(zerox) {
- const Type t_zerox = gwi_mk_type(gwi, "ZeroX", SZ_INT, "UGen");
- GWI_BB(gwi_class_ini(gwi, t_zerox, zerox_ctor, basic_dtor))
+ GWI_OB(gwi_class_ini(gwi, "ZeroX", "UGen"))
+ gwi_class_xtor(gwi, zerox_ctor, basic_dtor);
return gwi_class_end(gwi);
}
const M_Object a = mp_calloc(p, M_Object);
a->ref = 1;
a->type_ref = t;
- a->vtable = &t->nspc->info->vtable;
- if(t->nspc->info->offset)
- a->data = (m_bit*)_mp_calloc(p, t->nspc->info->offset);
+ if(t->nspc) {
+ a->vtable = &t->nspc->info->vtable;
+ if(t->nspc->info->offset)
+ a->data = (m_bit*)_mp_calloc(p, t->nspc->info->offset);
+ }
if(shred)
vector_add(&shred->gc, (vtype)a);
return a;
do {
if(GET_FLAG(t, nonnull))
t = t->e->parent;
+ if(!t->nspc)
+ continue; // return ?
struct scope_iter iter = { t->nspc->info->value, 0, 0 };\
Value v;
while(scope_iter(&iter, &v) > 0) {
}
ANN void free_object(MemPool p, const M_Object o) {
- if(o->type_ref->nspc->info->offset)
+ if(o->type_ref->nspc && o->type_ref->nspc->info->offset)
mp_free2(p, o->type_ref->nspc->info->offset, o->data);
mp_free(p, M_Object, o);
}
}
GWION_IMPORT(object) {
- const Type t_object = gwi_mk_type(gwi, "Object", SZ_INT, NULL);
+const Type t_object = gwi_mk_type(gwi, "Object", SZ_INT, NULL);
+gwi_add_type(gwi, t_object);
GWI_BB(gwi_gack(gwi, t_object, gack_object))
+//assert(GET_FLAG(t_object, checked));
+ SET_FLAG(t_object, checked); // should be set by gwi_add_type
gwi->gwion->type[et_object] = t_object;
- GWI_BB(gwi_class_ini(gwi, t_object, NULL, NULL))
- GWI_BB(gwi_class_end(gwi))
+
GWI_BB(gwi_oper_cond(gwi, "Object", BranchEqInt, BranchNeqInt))
GWI_BB(gwi_oper_ini(gwi, "@null", "Object", "Object"))
GWI_BB(gwi_oper_add(gwi, at_object))
}
GWION_IMPORT(ptr) {
- const m_str list[] = { "A" };
- const Type t_ptr = gwi_mk_type(gwi, "Ptr", SZ_INT, "Object");
+ const Type t_ptr = gwi_class_ini(gwi, "Ptr<~A~>", NULL);
gwi->gwion->type[et_ptr] = t_ptr;
- GWI_BB(gwi_tmpl_ini(gwi, 1, list))
- GWI_BB(gwi_class_ini(gwi, t_ptr, NULL, NULL))
- GWI_BB(gwi_tmpl_end(gwi))
- GWI_BB(gwi_item_ini(gwi, "int", "@val"))
+ GWI_BB(gwi_item_ini(gwi, "@internal", "@val"))
GWI_BB(gwi_item_end(gwi, 0, NULL))
GWI_BB(gwi_class_end(gwi))
t_ptr->nspc->info->offset = SZ_INT; // TODO: should be an assert
}
#include "nspc.h"
GWION_IMPORT(shred) {
- const Type t_shred = gwi_mk_type(gwi, "Shred", SZ_INT, "Object");
+ const Type t_shred = gwi_class_ini(gwi, "Shred", NULL);
+ gwi_class_xtor(gwi, NULL, shred_dtor);
gwi->gwion->type[et_shred] = t_shred;
- GWI_BB(gwi_class_ini(gwi, t_shred, NULL, shred_dtor))
gwi_item_ini(gwi, "int", "@me");
GWI_BB(gwi_item_end(gwi, ae_flag_const, NULL))
gwi_item_ini(gwi, "int", "cancel");
GWI_BB((o_shred_cancel = gwi_item_end(gwi, ae_flag_const, NULL)))
- gwi_func_ini(gwi, "void", "exit", gw_shred_exit);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "void", "exit");
+ GWI_BB(gwi_func_end(gwi, gw_shred_exit, ae_flag_none))
- gwi_func_ini(gwi, "int", "running", vm_shred_is_running);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "int", "running");
+ GWI_BB(gwi_func_end(gwi, vm_shred_is_running, ae_flag_none))
- gwi_func_ini(gwi, "int", "done", vm_shred_is_done);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "int", "done");
+ GWI_BB(gwi_func_end(gwi, vm_shred_is_done, ae_flag_none))
- gwi_func_ini(gwi, "int", "id", vm_shred_id);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "int", "id");
+ GWI_BB(gwi_func_end(gwi, vm_shred_id, ae_flag_none))
- gwi_func_ini(gwi, "Shred", "fromId", vm_shred_from_id);
+ gwi_func_ini(gwi, "Shred", "fromId");
gwi_func_arg(gwi, "int", "id");
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
+ GWI_BB(gwi_func_end(gwi, vm_shred_from_id, ae_flag_static))
- gwi_func_ini(gwi, "void", "yield", shred_yield);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "void", "yield");
+ GWI_BB(gwi_func_end(gwi, shred_yield, ae_flag_none))
- gwi_func_ini(gwi, "int", "args", shred_args);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "int", "args");
+ GWI_BB(gwi_func_end(gwi, shred_args, ae_flag_none))
- gwi_func_ini(gwi, "string", "arg", shred_arg);
+ gwi_func_ini(gwi, "string", "arg");
gwi_func_arg(gwi, "int", "n");
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, shred_arg, ae_flag_none))
- gwi_func_ini(gwi, "string", "name", shred_name);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "string", "name");
+ GWI_BB(gwi_func_end(gwi, shred_name, ae_flag_none))
- gwi_func_ini(gwi, "string", "path", shred_path);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "string", "path");
+ GWI_BB(gwi_func_end(gwi, shred_path, ae_flag_none))
- gwi_func_ini(gwi, "string", "dir", shred_dir);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "string", "dir");
+ GWI_BB(gwi_func_end(gwi, shred_dir, ae_flag_none))
- gwi_func_ini(gwi, "string", "code_name", shred_code_name);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "string", "code_name");
+ GWI_BB(gwi_func_end(gwi, shred_code_name, ae_flag_none))
- gwi_func_ini(gwi, "string", "code_path", shred_code_path);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "string", "code_path");
+ GWI_BB(gwi_func_end(gwi, shred_code_path, ae_flag_none))
- gwi_func_ini(gwi, "string", "code_dir", shred_code_dir);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "string", "code_dir");
+ GWI_BB(gwi_func_end(gwi, shred_code_dir, ae_flag_none))
- gwi_func_ini(gwi, "void", "set_cancel", shred_cancel);
+ gwi_func_ini(gwi, "void", "set_cancel");
gwi_func_arg(gwi, "int", "n");
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "test_cancel", shred_test_cancel);
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "lock", shred_lock);
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "unlock", shred_unlock);
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, shred_cancel, ae_flag_none))
+ gwi_func_ini(gwi, "void", "test_cancel");
+ GWI_BB(gwi_func_end(gwi, shred_test_cancel, ae_flag_none))
+ gwi_func_ini(gwi, "void", "lock");
+ GWI_BB(gwi_func_end(gwi, shred_lock, ae_flag_none))
+ gwi_func_ini(gwi, "void", "unlock");
+ GWI_BB(gwi_func_end(gwi, shred_unlock, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
struct SpecialId_ spid = { .type=t_shred, .exec=RegPushMe, .is_const=1 };
SET_FLAG((t_shred), abstract);
- const Type t_fork = gwi_mk_type(gwi, "Fork", SZ_INT, "Shred");
+ const Type t_fork= gwi_class_ini(gwi, "Fork", "Shred");
+ gwi_class_xtor(gwi, NULL, fork_dtor);
gwi->gwion->type[et_fork] = t_fork;
- GWI_BB(gwi_class_ini(gwi, t_fork, NULL, fork_dtor))
+
gwi_item_ini(gwi, "int", "@thread");
GWI_BB((o_fork_thread = gwi_item_end(gwi, ae_flag_const, NULL)))
gwi_item_ini(gwi, "int", "is_done");
GWI_BB(gwi_union_add(gwi, "Vec4", "w"))
GWI_BB(gwi_union_add(gwi, "VarObject", "o"))
GWI_OB(gwi_union_end(gwi, ae_flag_const))
- gwi_func_ini(gwi, "int", "join", fork_join);
- GWI_BB(gwi_func_end(gwi, 0))
+ gwi_func_ini(gwi, "int", "join");
+ GWI_BB(gwi_func_end(gwi, fork_join, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
SET_FLAG((t_fork), abstract);
return GW_OK;
printf("%s", obj ? STRING(obj) : "(null string)");
}
GWION_IMPORT(string) {
- const Type t_string = gwi_mk_type(gwi, "string", SZ_INT, "Object");
+ const Type t_string = gwi_class_ini(gwi, "string", NULL);
+ gwi_class_xtor(gwi, string_ctor, NULL);
GWI_BB(gwi_gack(gwi, t_string, gack_string))
- GWI_BB(gwi_class_ini(gwi, t_string, string_ctor, NULL))
- gwi->gwion->type[et_string] = t_string;
- gwi_item_ini(gwi, "int", "@data");
+ gwi->gwion->type[et_string] = t_string; // use func
+
+ gwi_item_ini(gwi, "@internal", "@data");
GWI_BB(gwi_item_end(gwi, ae_flag_const, NULL))
GWI_BB(gwi_class_end(gwi))
#include "value.h"
#include "object.h"
#include "parse.h"
-#include "cpy_ast.h"
#include "tuple.h"
struct TupleEmit {
static INSTR(TupleUnpack) {
const M_Object o = *(M_Object*)(shred->reg - SZ_INT);
struct UnpackInfo_ *info = (struct UnpackInfo_*)instr->m_val;
- memcpy(shred->mem + info->mem_offset, o->data + shred->info->vm->gwion->type[et_tuple]->nspc->info->offset + info->obj_offset, info->size);
+// memcpy(shred->mem + info->mem_offset, o->data + shred->info->vm->gwion->type[et_tuple]->nspc->info->offset + info->obj_offset, info->size);
+ memcpy(shred->mem + info->mem_offset, o->data + info->obj_offset, info->size);
}
INSTR(TupleMember) {
INSTR(TupleCtor) {
const Type t = (Type)instr->m_val;
const M_Object o = new_object(shred->info->vm->gwion->mp, shred, t);
- const size_t sz = shred->info->vm->gwion->type[et_tuple]->nspc->info->offset;
- memcpy(o->data + shred->info->vm->gwion->type[et_tuple]->nspc->info->offset,
- shred->reg - (t->nspc->info->offset - sz), (t->nspc->info->offset - sz));
- shred->reg -= (t->nspc->info->offset - sz - SZ_INT);
+ const m_uint sz = t->nspc->info->offset;
+ memcpy(o->data, shred->reg - sz, sz);
+ shred->reg -= (sz - SZ_INT);
*(M_Object*)(shred->reg - SZ_INT) = o;
}
GWION_IMPORT(tuple) {
const Type t_tuple = gwi_mk_type(gwi, "Tuple", SZ_INT, "Object");
+// const Type t_tuple = gwi_mk_type(gwi, "Tuple", SZ_INT, NULL);
+gwi_add_type(gwi, t_tuple);
+SET_FLAG(t_tuple, checked | ae_flag_scan2 | ae_flag_check | ae_flag_emit);
+//assert(!t_tuple->e->def);
+// const Type t_tuple = gwi_class_ini(gwi, "Tuple", NULL);
+// this is a sign we should make the class_def optionnal
+// free def
+//t_tuple->e->def = NULL;
gwi->gwion->type[et_tuple] = t_tuple;
- GWI_BB(gwi_class_ini(gwi, t_tuple, NULL, NULL))
- GWI_BB(gwi_class_end(gwi))
+// GWI_BB(gwi_class_end(gwi))
SET_FLAG(t_tuple, abstract | ae_flag_template);
GWI_BB(gwi_oper_ini(gwi, "Object", "Tuple", NULL))
GWI_BB(gwi_oper_add(gwi, opck_at_tuple))
}
GWION_IMPORT(ugen) {
- const Type t_ugen = gwi_mk_type(gwi, "UGen", SZ_INT, "Object");
- gwi->gwion->type[et_ugen] = t_ugen;
- GWI_BB(gwi_class_ini(gwi, t_ugen, ugen_ctor, ugen_dtor))
- GWI_BB(gwi_item_ini(gwi, "int", "@ugen"))
+ const Type t_ugen = gwi_class_ini(gwi, "UGen", NULL);
+ gwi_class_xtor(gwi, ugen_ctor, ugen_dtor);
+ gwi->gwion->type[et_ugen] = t_ugen; // use func
+
+ GWI_BB(gwi_item_ini(gwi, "@internal", "@ugen"))
GWI_BB(gwi_item_end(gwi, ae_flag_member, NULL))
- GWI_BB(gwi_func_ini(gwi, "UGen", "chan", ugen_channel))
+ GWI_BB(gwi_func_ini(gwi, "UGen", "chan"))
GWI_BB(gwi_func_arg(gwi, "int", "arg0"))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, ugen_channel, ae_flag_none))
- GWI_BB(gwi_func_ini(gwi, "int", "op", ugen_get_op))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_ini(gwi, "int", "op"))
+ GWI_BB(gwi_func_end(gwi, ugen_get_op, ae_flag_none))
- GWI_BB(gwi_func_ini(gwi, "int", "op", ugen_set_op))
+ GWI_BB(gwi_func_ini(gwi, "int", "op"))
GWI_BB(gwi_func_arg(gwi, "int", "arg0"))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, ugen_set_op, ae_flag_none))
- GWI_BB(gwi_func_ini(gwi, "float", "last", ugen_get_last))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_ini(gwi, "float", "last"))
+ GWI_BB(gwi_func_end(gwi, ugen_get_last, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
GWI_BB(gwi_oper_ini(gwi, "UGen", "UGen", "UGen"))
}
GWION_IMPORT(vararg) {
- const Type t_vararg = gwi_mk_type(gwi, "@Vararg", SZ_INT, "Object");
const Type t_varobj = gwi_mk_type(gwi, "VarObject", SZ_INT, "Object");
SET_FLAG(t_varobj, abstract);
const Type t_varloop = gwi_mk_type(gwi, "@VarLoop", SZ_INT, NULL);
GWI_BB(gwi_add_type(gwi, t_varobj))
GWI_BB(gwi_set_global_type(gwi, t_varloop, et_varloop))
- GWI_BB(gwi_class_ini(gwi, t_vararg, NULL, NULL))
- gwi->gwion->type[et_vararg] = t_vararg;
+ const Type t_vararg = gwi_class_ini(gwi, "@Vararg", NULL);
+ gwi->gwion->type[et_vararg] = t_vararg; // use func
GWI_BB(gwi_union_ini(gwi, NULL, NULL))
GWI_BB(gwi_union_add(gwi, "@VarLoop", "start"))
GWI_BB(gwi_union_add(gwi, "@VarLoop", "end"))
gwi_item_end(gwi, ae_flag_member, NULL);
}
+static GACK(gack_vec3) {
+ printf("%%(%.4f, %.4f, %.4f)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT), *(m_float*)(VALUE + SZ_FLOAT*2));
+}
+
GWION_IMPORT(vec3) {
- GWI_BB(gwi_class_ini(gwi, gwi->gwion->type[et_vec3], NULL, NULL))
+ const Type t_vec3 = gwi_class_ini(gwi, "Vec3", NULL);
+t_vec3->size = SZ_VEC3;
+t_vec3->e->parent = NULL;
+ gwi->gwion->type[et_vec3] = t_vec3;
+ GWI_BB(gwi_gack(gwi, t_vec3, gack_vec3))
vecx_base(gwi);
- gwi_func_ini(gwi, "void", "set", vec3_set);
+ gwi_func_ini(gwi, "void", "set");
gwi_func_arg(gwi, "float", "x");
gwi_func_arg(gwi, "float", "y");
gwi_func_arg(gwi, "float", "z");
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "setAll", vec3_setAll);
+ GWI_BB(gwi_func_end(gwi, vec3_set, ae_flag_none))
+ gwi_func_ini(gwi, "void", "setAll");
gwi_func_arg(gwi, "float", "x");
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "float", "magnitude", vec3_magnitude);
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "normalize", vec3_normalize);
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "float", "interp", vec3_interp);
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "float", "interp", vec3_float);
+ GWI_BB(gwi_func_end(gwi, vec3_setAll, ae_flag_none))
+ gwi_func_ini(gwi, "float", "magnitude");
+ GWI_BB(gwi_func_end(gwi, vec3_magnitude, ae_flag_none))
+ gwi_func_ini(gwi, "void", "normalize");
+ GWI_BB(gwi_func_end(gwi, vec3_normalize, ae_flag_none))
+ gwi_func_ini(gwi, "float", "interp");
+ GWI_BB(gwi_func_end(gwi, vec3_interp, ae_flag_none))
+ gwi_func_ini(gwi, "float", "interp");
gwi_func_arg(gwi, "float", "delta");
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "float", "interp", vec3_dur);
+ GWI_BB(gwi_func_end(gwi, vec3_float, ae_flag_none))
+ gwi_func_ini(gwi, "float", "interp");
gwi_func_arg(gwi, "dur", "delta");
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "update", vec3_update);
+ GWI_BB(gwi_func_end(gwi, vec3_dur, ae_flag_none))
+ gwi_func_ini(gwi, "void", "update");
gwi_func_arg(gwi, "float", "goal");
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "update", vec3_update_slew);
+ GWI_BB(gwi_func_end(gwi, vec3_update, ae_flag_none))
+ gwi_func_ini(gwi, "void", "update");
gwi_func_arg(gwi, "float", "goal");
gwi_func_arg(gwi, "float", "slew");
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "supdate", vec3_update_set);
+ GWI_BB(gwi_func_end(gwi, vec3_update_slew, ae_flag_none))
+ gwi_func_ini(gwi, "void", "supdate");
gwi_func_arg(gwi, "float", "goalAndValue");
- GWI_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "supdate", vec3_update_set_slew);
+ GWI_BB(gwi_func_end(gwi, vec3_update_set, ae_flag_none))
+ gwi_func_ini(gwi, "void", "supdate");
gwi_func_arg(gwi, "float", "goalAndValue");
gwi_func_arg(gwi, "float", "slew");
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, vec3_update_set_slew, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
GWI_BB(gwi_oper_ini(gwi, "Vec3", "Vec3", "Vec3"))
*(m_vec4*)REG(0) = *r;
}
+static GACK(gack_vec4) {
+ printf("%%(%.4f, %.4f, %.4f, %.4f)",
+ *(m_float*)VALUE,
+ *(m_float*)(VALUE + SZ_FLOAT),
+ *(m_float*)(VALUE + SZ_FLOAT*2),
+ *(m_float*)(VALUE + SZ_FLOAT*3));
+}
+
GWION_IMPORT(vec4) {
- CHECK_BB(gwi_class_ini(gwi, gwi->gwion->type[et_vec4], NULL, NULL))
+// should be special (gwi, "Vec4", SZ_VEC4)
+ const Type t_vec4 = gwi_class_ini(gwi, "Vec4", NULL);
+t_vec4->size = SZ_VEC4;
+t_vec4->e->parent = NULL;
+ gwi->gwion->type[et_vec4] = t_vec4;
+ GWI_BB(gwi_gack(gwi, t_vec4, gack_vec4))
vecx_base(gwi);
gwi_item_ini(gwi, "float", "w");
gwi_item_end(gwi, ae_flag_member, NULL);
- gwi_func_ini(gwi, "void", "set", vec4_set);
+ gwi_func_ini(gwi, "void", "set");
gwi_func_arg(gwi, "float", "x");
gwi_func_arg(gwi, "float", "y");
gwi_func_arg(gwi, "float", "z");
gwi_func_arg(gwi, "float", "w");
- CHECK_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "setAll", vec4_setAll);
+ CHECK_BB(gwi_func_end(gwi, vec4_set, ae_flag_none))
+ gwi_func_ini(gwi, "void", "setAll");
gwi_func_arg(gwi, "float", "x");
- CHECK_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "float", "magnitude", vec4_magnitude);
- CHECK_BB(gwi_func_end(gwi, 0))
- gwi_func_ini(gwi, "void", "normalize", vec4_normalize);
- CHECK_BB(gwi_func_end(gwi, 0))
+ CHECK_BB(gwi_func_end(gwi, vec4_setAll, ae_flag_none))
+ gwi_func_ini(gwi, "float", "magnitude");
+ CHECK_BB(gwi_func_end(gwi, vec4_magnitude, ae_flag_none))
+ gwi_func_ini(gwi, "void", "normalize");
+ CHECK_BB(gwi_func_end(gwi, vec4_normalize, ae_flag_none))
CHECK_BB(gwi_class_end(gwi))
CHECK_BB(gwi_oper_ini(gwi, "Vec4", "Vec4", "Vec4"))
CHECK_BB(gwi_oper_end(gwi, "+", Vec4Add))
return t->e->d.base_type;
}
-ANN Type array_type(const Env env, const Type base, const m_uint depth) {
+ANN Type array_type(const Env env, const Type src, const m_uint depth) {
m_uint i = depth + 1;
if(depth > 1)
- array_type(env, base, depth-1);
- size_t len = strlen(base->name);
+ array_type(env, src, depth-1);
+ size_t len = strlen(src->name);
char name[len + 2* depth + 1];
- strcpy(name, base->name);
+ strcpy(name, src->name);
while(--i) {
strcpy(name+len, "[]");
len += 2;
}
const Symbol sym = insert_symbol(name);
- const Type type = nspc_lookup_type1(base->e->owner, sym);
+ const Type type = nspc_lookup_type1(src->e->owner, sym);
if(type)
return type;
- const Type t = new_type(env->gwion->mp, env->gwion->type[et_array]->xid, base->name, env->gwion->type[et_array]);
+ const Type t = new_type(env->gwion->mp, env->gwion->type[et_array]->xid, src->name, env->gwion->type[et_array]);
t->name = s_name(sym);
t->size = SZ_INT;
- t->array_depth = depth + base->array_depth;
- t->e->d.base_type = base;
+ t->array_depth = depth + src->array_depth;
+ t->e->d.base_type = array_base(src) ?: src;
t->nspc = env->gwion->type[et_array]->nspc;
ADD_REF(t->nspc);
SET_FLAG(t, checked);
- t->e->owner = base->e->owner;
- nspc_add_type_front(base->e->owner, sym, t);
+ t->e->owner = src->e->owner;
+ nspc_add_type_front(src->e->owner, sym, t);
return t;
}
#include "parse.h"
#include "nspc.h"
#include "match.h"
-#include "cpy_ast.h"
#include "tuple.h"
#include "emit.h"
#include "specialid.h"
if(f)
return f;
Type t = value->from->owner_class;
- while(t) {
+ while(t && t->nspc) {
const Value v = nspc_lookup_value0(t->nspc, value->d.func_ref->def->base->xid);
if(!v)
goto next;
ANN static inline void inherit(const Type t) {
const Nspc nspc = t->nspc, parent = t->e->parent->nspc;
+ if(!parent)
+ return;
nspc->info->offset = parent->info->offset;
if(parent->info->vtable.ptr)
vector_copy2(&parent->info->vtable, &nspc->info->vtable);
+++ /dev/null
-#include "gwion_util.h"
-#include "gwion_ast.h"
-#include "cpy_ast.h"
-
-ANN static Stmt cpy_stmt(MemPool p, const Stmt src);
-ANN static Exp cpy_exp(MemPool p, const Exp src);
-ANN Type_List cpy_type_list(MemPool p, const Type_List src);
-ANN static Arg_List cpy_arg_list(MemPool p, const Arg_List src);
-ANN Class_Def cpy_class_def(MemPool p, const Class_Def src);
-ANN static Stmt_List cpy_stmt_list(MemPool p, const Stmt_List src);
-
-ANN static void cpy_exp_dot(MemPool p, Exp_Dot *a, const Exp_Dot *src) {
- a->base = cpy_exp(p, src->base);
- a->xid = src->xid;
-}
-
-ANN static void cpy_exp_lambda(MemPool p, Exp_Lambda *a, const Exp_Lambda *src) {
- if(src->args)
- a->args = cpy_arg_list(p, src->args);
- a->code = cpy_stmt(p, src->code);
- a->name = src->name;
-}
-
-ANN Array_Sub cpy_array_sub(MemPool p, const Array_Sub src) {
- Array_Sub a = mp_calloc(p, Array_Sub);
- if(src->exp)
- a->exp = cpy_exp(p, src->exp);
- a->depth = src->depth;
- return a;
-}
-
-ANN static void cpy_exp_array(MemPool p, Exp_Array *a, const Exp_Array *src) {
- a->base = cpy_exp(p, src->base);
- a->array = cpy_array_sub(p, src->array);
-}
-
-ANN static Var_Decl cpy_var_decl(MemPool p, const Var_Decl src) {
- Var_Decl a = mp_calloc(p, Var_Decl);
- a->xid = src->xid; // 1
- if(src->array)
- a->array = cpy_array_sub(p, src->array); // 1
- a->pos = loc_cpy(p, src->pos); // 1
- return a;
-}
-
-ANN static Var_Decl_List cpy_var_decl_list(MemPool p, const Var_Decl_List src) {
- Var_Decl_List a = mp_calloc(p, Var_Decl_List);
- a->self = cpy_var_decl(p, src->self); // 1
- if(src->next)
- a->next = cpy_var_decl_list(p, src->next); // 1
- return a;
-}
-
-ANN Type_Decl* cpy_type_decl(MemPool p, const Type_Decl* src) {
- Type_Decl* a = mp_calloc(p, Type_Decl);
- if(src->xid)
- a->xid = cpy_id_list(p, src->xid); // 1
- if(src->exp)
- a->exp = cpy_exp(p, src->exp); // 1
- if(src->array)
- a->array = cpy_array_sub(p, src->array); // 1
- if(src->types)
- a->types = cpy_type_list(p, src->types); // 1
- a->flag = src->flag; // 1
- return a;
-}
-
-ANN ID_List cpy_id_list(MemPool p, const ID_List src) {
- ID_List a = mp_calloc(p, ID_List);
- a->xid = src->xid; // 1
- if(src->next)
- a->next = cpy_id_list(p, src->next); // 1
- if(src->pos)
- a->pos = loc_cpy(p, src->pos); // 1
- return a;
-}
-
-ANN Type_List cpy_type_list(MemPool p, const Type_List src) {
- Type_List a = mp_calloc(p, Type_List);
- if(src->td)
- a->td = cpy_type_decl(p, src->td); // 1
- if(src->next)
- a->next = cpy_type_list(p, src->next); // 1
- return a;
-}
-
-ANN static void cpy_vec(MemPool p, Vec* a, const Vec* src) {
- a->exp = cpy_exp(p, src->exp);
- a->dim = src->dim;
-}
-
-ANN static Arg_List cpy_arg_list(MemPool p, const Arg_List src) {
- Arg_List a = mp_calloc(p, Arg_List);
- if(src->td)
- a->td = cpy_type_decl(p, src->td); // 1
- if(src->var_decl)
- a->var_decl = cpy_var_decl(p, src->var_decl); // 1
- if(src->next)
- a->next = cpy_arg_list(p, src->next); // 1
- return a;
-}
-
-ANN static void cpy_exp_decl(MemPool p, Exp_Decl *a, const Exp_Decl *src) {
- a->td = cpy_type_decl(p, src->td);
- a->list = cpy_var_decl_list(p, src->list);
-}
-
-ANN static void cpy_exp_primary(MemPool p, Exp_Primary *a, const Exp_Primary *src) {
- switch(src->primary_type) {
- case ae_primary_id:
- a->d.var = src->d.var;
- break;
- case ae_primary_num:
- a->d.num = src->d.num;
- break;
- case ae_primary_float:
- a->d.fnum = src->d.fnum;
- break;
- case ae_primary_char:
- a->d.chr = src->d.chr;
- break;
- case ae_primary_str:
- a->d.str = src->d.str;
- break;
- case ae_primary_array:
- a->d.array = cpy_array_sub(p, src->d.array);
- break;
- case ae_primary_vec:
- cpy_vec(p, &a->d.vec, &src->d.vec);
- break;
- default:
- if(src->d.exp)
- a->d.exp = cpy_exp(p, src->d.exp);
- break;
- }
- a->primary_type = src->primary_type;
-}
-
-ANN Tmpl* cpy_tmpl(MemPool p, const Tmpl *src) {
- Tmpl *a = mp_calloc(p, Tmpl);
- if(src->list)
- a->list = cpy_id_list(p, src->list);
- if(src->call)
- a->call = cpy_type_list(p, src->call);
- a->base = src->base;
- return a;
-}
-
-ANN static void cpy_exp_call(MemPool p, Exp_Call *a, const Exp_Call *src) {
- a->func = cpy_exp(p, src->func);
- if(src->args)
- a->args = cpy_exp(p, src->args);
- if(src->tmpl)
- a->tmpl = cpy_tmpl(p, src->tmpl);
-}
-
-ANN static void cpy_exp_cast(MemPool p, Exp_Cast *a, const Exp_Cast *src) {
- a->td = cpy_type_decl(p, src->td);
- a->exp = cpy_exp(p, src->exp);
-}
-
-ANN static void cpy_exp_binary(MemPool p, Exp_Binary *a, const Exp_Binary *src) {
- a->lhs = cpy_exp(p, src->lhs);
- a->rhs = cpy_exp(p, src->rhs);
- a->op = src->op;
-}
-
-ANN static void cpy_exp_postfix(MemPool p, Exp_Postfix *a, const Exp_Postfix *src) {
- a->op = src->op;
- a->exp = cpy_exp(p, src->exp);
-}
-
-ANN static void cpy_exp_if(MemPool p, Exp_If *a, const Exp_If *src) {
- a->cond = cpy_exp(p, src->cond);
- if(src->if_exp)
- a->if_exp = cpy_exp(p, src->if_exp);
- if(src->else_exp)
- a->else_exp = cpy_exp(p, src->else_exp);
-}
-
-
-// TODO check me
-ANN static void cpy_exp_unary(MemPool p, Exp_Unary *a, const Exp_Unary *src) {
- a->op = src->op;
- if(src->exp)
- a->exp = cpy_exp(p, src->exp);
- if(src->td)
- a->td = cpy_type_decl(p, src->td);
- if(src->code)
- a->code = cpy_stmt(p, src->code);
-}
-
-ANN static void cpy_exp_typeof(MemPool p, Exp_Typeof *a, const Exp_Typeof *src) {
- a->exp = cpy_exp(p, src->exp);
-}
-
-ANN static Exp cpy_exp(MemPool p, const Exp src) {
- Exp a = mp_calloc(p, Exp);
- if(src->next)
- a->next = cpy_exp(p, src->next);
- switch(src->exp_type) {
- case ae_exp_post: // !! naming
- cpy_exp_postfix(p, &a->d.exp_post, &src->d.exp_post);
- break;
- case ae_exp_primary:
- cpy_exp_primary(p, &a->d.exp_primary, &src->d.exp_primary);
- break;
- case ae_exp_decl:
- cpy_exp_decl(p, &a->d.exp_decl, &src->d.exp_decl);
- break;
- case ae_exp_unary:
- cpy_exp_unary(p, &a->d.exp_unary, &src->d.exp_unary);
- break;
- case ae_exp_binary:
- cpy_exp_binary(p, &a->d.exp_binary, &src->d.exp_binary);
- break;
- case ae_exp_cast:
- cpy_exp_cast(p, &a->d.exp_cast, &src->d.exp_cast);
- break;
- case ae_exp_call:
- cpy_exp_call(p, &a->d.exp_call, &src->d.exp_call);
- break;
- case ae_exp_if:
- cpy_exp_if(p, &a->d.exp_if, &src->d.exp_if);
- break;
- case ae_exp_dot:
- cpy_exp_dot(p, &a->d.exp_dot, &src->d.exp_dot);
- break;
- case ae_exp_array:
- cpy_exp_array(p, &a->d.exp_array, &src->d.exp_array);
- break;
- case ae_exp_lambda:
- cpy_exp_lambda(p, &a->d.exp_lambda, &src->d.exp_lambda);
- break;
- case ae_exp_typeof:
- cpy_exp_typeof(p, &a->d.exp_typeof, &src->d.exp_typeof);
- break;
- }
- a->exp_type = src->exp_type;
- a->meta = src->meta;// maybe meta shoyuld be set as in constructors
- a->pos = loc_cpy(p, src->pos);
- return a;
-}
-
-ANN /*static */Decl_List cpy_decl_list(MemPool p, const Decl_List src) {
- Decl_List a = mp_calloc(p, Decl_List);
- a->self = cpy_exp(p, src->self);
- if(src->next)
- a->next = cpy_decl_list(p, src->next);
- return a;
-}
-
-ANN static void cpy_stmt_exp(MemPool p, const Stmt_Exp a, const Stmt_Exp src) {
- if(src->val)
- a->val = cpy_exp(p, src->val);
-}
-
-ANN static void cpy_stmt_flow(MemPool p, Stmt_Flow a,const Stmt_Flow src) {
- if(src->cond)
- a->cond = cpy_exp(p, src->cond);
- if(src->body)
- a->body = cpy_stmt(p, src->body);
- a->is_do = src->is_do;
-}
-
-ANN static void cpy_stmt_code(MemPool p, Stmt_Code a, const Stmt_Code src) {
- if(src->stmt_list)
- a->stmt_list = cpy_stmt_list(p, src->stmt_list);
-}
-
-ANN static void cpy_stmt_for(MemPool p, Stmt_For a, const Stmt_For src) {
- if(src->c1)
- a->c1 = cpy_stmt(p, src->c1);
- if(src->c2)
- a->c2 = cpy_stmt(p, src->c2);
- if(src->c3)
- a->c3 = cpy_exp(p, src->c3);
- if(src->body)
- a->body = cpy_stmt(p, src->body);
-}
-
-ANN static void cpy_stmt_auto(MemPool p, Stmt_Auto a, const Stmt_Auto src) {
- if(src->sym)
- a->sym = src->sym;
- if(src->exp)
- a->exp = cpy_exp(p, src->exp);
- if(src->body)
- a->body = cpy_stmt(p, src->body);
- a->is_ptr = src->is_ptr;
-}
-
-ANN static void cpy_stmt_loop(MemPool p, Stmt_Loop a, const Stmt_Loop src) {
- if(src->cond)
- a->cond = cpy_exp(p, src->cond);
- if(src->body)
- a->body = cpy_stmt(p, src->body);
-}
-
-ANN static void cpy_stmt_if(MemPool p, Stmt_If a, const Stmt_If src) {
- if(src->cond)
- a->cond = cpy_exp(p, src->cond);
- if(src->if_body)
- a->if_body = cpy_stmt(p, src->if_body);
- if(src->else_body)
- a->else_body = cpy_stmt(p, src->else_body);
-}
-
-ANN static void cpy_stmt_jump(MemPool p NUSED, const Stmt_Jump a,const Stmt_Jump src) {
- a->name = src->name;
- a->is_label = src->is_label;
-}
-
-ANN static Stmt cpy_stmt_case(MemPool p, const Stmt_Match src) {
- Stmt a = mp_calloc(p, Stmt);
- a->d.stmt_match.cond = cpy_exp(p, src->cond);
- a->d.stmt_match.list = cpy_stmt_list(p, src->list);
- if(src->when)
- a->d.stmt_match.when = cpy_exp(p, src->when);
- return a;
-}
-
-ANN static Stmt_List cpy_stmt_cases(MemPool p, const Stmt_List src) {
- Stmt_List a = mp_calloc(p, Stmt_List);
- if(src->next)
- a->next = cpy_stmt_cases(p, src->next);
- a->stmt = cpy_stmt_case(p, &src->stmt->d.stmt_match);
- return a;
-}
-
-ANN static void cpy_stmt_match(MemPool p, Stmt_Match a, const Stmt_Match src) {
- a->cond = cpy_exp(p, src->cond);
- a->list = cpy_stmt_cases(p, src->list);
- if(src->where)
- a->where = cpy_stmt(p, src->where);
-}
-
-ANN static Enum_Def cpy_enum_def(MemPool p, const Enum_Def src) {
- Enum_Def a = mp_calloc(p, Enum_Def);
- a->list = cpy_id_list(p, src->list);
- a->xid = src->xid;
- a->pos = loc_cpy(p, src->pos);
- a->flag = src->flag;
- vector_init(&a->values);
- return a;
-}
-
-ANN Func_Base* cpy_func_base(MemPool p, const Func_Base* src) {
- Func_Base *a = mp_calloc(p, Func_Base);
- if(src->td)
- a->td = cpy_type_decl(p, src->td); // 1
- if(src->xid)
- a->xid = src->xid; // 1
- if(src->args)
- a->args = cpy_arg_list(p, src->args); // 1
- if(src->tmpl)
- a->tmpl = cpy_tmpl(p, src->tmpl); // 1
- return a;
-}
-
-ANN static Fptr_Def cpy_fptr_def(MemPool p, const Fptr_Def src) {
- Fptr_Def a = mp_calloc(p, Fptr_Def);
- a->base = cpy_func_base(p, src->base);
- return a;
-}
-
-ANN static void cpy_type_def2(MemPool p, Type_Def a, const Type_Def src) {
- if(src->ext)
- a->ext = cpy_type_decl(p, src->ext);
- a->xid = src->xid;
- if(src->tmpl)
- a->tmpl = cpy_tmpl(p, src->tmpl);
-}
-
-ANN static Type_Def cpy_type_def(MemPool p, const Type_Def src) {
- Type_Def a = mp_calloc(p, Type_Def);
- cpy_type_def2(p, a, src);
- return a;
-}
-
-ANN static Union_Def cpy_union_def(MemPool p, const Union_Def src) {
- Union_Def a = mp_calloc(p, Union_Def);
- a->l = cpy_decl_list(p, src->l); // 1
- if(src->xid)
- a->xid = src->xid; // 1
- if(src->type_xid)
- a->type_xid = src->type_xid; // 1
- if(src->tmpl)
- a->tmpl = cpy_tmpl(p, src->tmpl); // 1
- a->pos = loc_cpy(p, src->pos);
- a->flag = src->flag; // 1
- return a;
-}
-
-ANN static Stmt cpy_stmt(MemPool p, const Stmt src) {
- Stmt a = mp_calloc(p, Stmt);
- switch(src->stmt_type) {
- case ae_stmt_exp:
- case ae_stmt_return:
- cpy_stmt_exp(p, &a->d.stmt_exp, &src->d.stmt_exp);
- break;
- case ae_stmt_code:
- cpy_stmt_code(p, &a->d.stmt_code, &src->d.stmt_code);
- break;
- case ae_stmt_while:
- case ae_stmt_until:
- cpy_stmt_flow(p, &a->d.stmt_flow, &src->d.stmt_flow);
- break;
- case ae_stmt_loop:
- cpy_stmt_loop(p, &a->d.stmt_loop, &src->d.stmt_loop);
- break;
- case ae_stmt_for:
- cpy_stmt_for(p, &a->d.stmt_for, &src->d.stmt_for);
- break;
- case ae_stmt_auto:
- cpy_stmt_auto(p, &a->d.stmt_auto, &src->d.stmt_auto);
- break;
- case ae_stmt_if:
- cpy_stmt_if(p, &a->d.stmt_if, &src->d.stmt_if);
- break;
- case ae_stmt_jump:
- cpy_stmt_jump(p, &a->d.stmt_jump, &src->d.stmt_jump);
- break;
- case ae_stmt_match:
- cpy_stmt_match(p, &a->d.stmt_match, &src->d.stmt_match);
- break;
- case ae_stmt_break:
- case ae_stmt_continue:
- break;
- }
- a->stmt_type = src->stmt_type;
- a->pos = loc_cpy(p, src->pos);
- return a;
-}
-
-ANN Func_Def cpy_func_def(MemPool p, const Func_Def src) {
- Func_Def a = mp_calloc(p, Func_Def);
- a->base = cpy_func_base(p, src->base);
- if(!GET_FLAG(src, builtin)) {
- if(src->d.code)
- a->d.code = cpy_stmt(p, src->d.code);
- } else
- a->d.dl_func_ptr = src->d.dl_func_ptr;
- a->pos = loc_cpy(p, src->pos);
- a->flag = src->flag;
- return a;
-}
-
-ANN static Stmt_List cpy_stmt_list(MemPool p, const Stmt_List src) {
- Stmt_List a = mp_calloc(p, Stmt_List);
- if(src->next)
- a->next = cpy_stmt_list(p, src->next);
- a->stmt = cpy_stmt(p, src->stmt);
- return a;
-}
-
-ANN static Section* cpy_section(MemPool p, const Section *src) {
- Section* a = mp_calloc(p, Section);
- switch(src->section_type) {
- case ae_section_stmt:
- a->d.stmt_list = cpy_stmt_list(p, src->d.stmt_list);
- break;
- case ae_section_class:
- a->d.class_def = cpy_class_def(p, src->d.class_def);
- break;
- case ae_section_func:
- a->d.func_def = cpy_func_def(p, src->d.func_def);
- break;
- case ae_section_enum:
- a->d.enum_def = cpy_enum_def(p, src->d.enum_def);
- break;
- case ae_section_union:
- a->d.union_def = cpy_union_def(p, src->d.union_def);
- break;
- case ae_section_fptr:
- a->d.fptr_def = cpy_fptr_def(p, src->d.fptr_def);
- break;
- case ae_section_type:
- a->d.type_def = cpy_type_def(p, src->d.type_def);
- break;
- }
- a->section_type = src->section_type;
- return a;
-}
-
-ANN static Class_Body cpy_class_body(MemPool p, const Class_Body src) {
- Class_Body a = mp_calloc(p, Class_Body);
- a->section = cpy_section(p, src->section);
- if(src->next)
- a->next = cpy_class_body(p, src->next);
- return a;
-}
-
-ANN Class_Def cpy_class_def(MemPool p, const Class_Def src) {
- Class_Def a = mp_calloc(p, Class_Def);
- cpy_type_def2(p, &a->base, &src->base);
- if(src->body) {
- if(!GET_FLAG(src, union))
- a->body = cpy_class_body(p, src->body);
- else
- a->list = cpy_decl_list(p, src->list);
- }
- a->flag = src->flag;
- a->pos = loc_cpy(p, src->pos);
- return a;
-}
-/*
-ANN static Ast cpy_ast(MemPool p, const Ast src) {
- Ast a = mp_calloc(p, Ast);
- a->section = cpy_section(p, src->section);
- if(src->next)
- a->next = cpy_ast(p, src->next);
- return a;
-}
-*/
#include "template.h"
#include "parser.h"
#include "parse.h"
-#include "cpy_ast.h"
#include "object.h"
#include "instr.h"
#include "operator.h"
ANN static Value mk_class(const Env env, const Type base) {
const Symbol sym = insert_symbol(base->name);
const Type t = type_copy(env->gwion->mp, env->gwion->type[et_class]);
-t->e->ctx = env->context;
+//t->e->ctx = env->context;
+t->e->ctx = base->e->ctx;
const Value v = new_value(env->gwion->mp, t, s_name(sym));
t->e->d.base_type = base;
// set from
#include "vm.h"
#include "parse.h"
#include "gwion.h"
-#include "cpy_ast.h"
#include "tuple.h"
struct tmpl_info {
MFUN(test_mfun){}
GWION_IMPORT(array_test) {
- Type t_invalid_var_name;
- GWI_OB((t_invalid_var_name = gwi_mk_type(gwi, "invalid_var_name", SZ_INT, "Object")))
- GWI_BB(gwi_class_ini(gwi, t_invalid_var_name, NULL, NULL))
+ GWI_OB(gwi_class_ini(gwi, "ArrayTest", NULL))
GWI_BB(gwi_item_ini(gwi, "int[]", "int_array"))
GWI_BB(gwi_item_end(gwi, 0, NULL)) // import array var
- GWI_BB(gwi_func_ini(gwi, "float[][]", "f", test_mfun))
- GWI_BB(gwi_func_end(gwi, 0))
- GWI_BB(gwi_func_ini(gwi, "float[][]", "g", test_mfun))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_ini(gwi, "float[][]", "f"))
+ GWI_BB(gwi_func_end(gwi, test_mfun, ae_flag_none))
+ GWI_BB(gwi_func_ini(gwi, "float[][]", "g"))
+ GWI_BB(gwi_func_end(gwi, test_mfun, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
return GW_OK;
}
+++ /dev/null
-#include "gwion_util.h"
-#include "gwion_ast.h"
-#include "oo.h"
-#include "vm.h"
-#include "env.h"
-#include "type.h"
-#include "object.h"
-#include "instr.h"
-#include "gwion.h"
-#include "value.h"
-#include "operator.h"
-#include "import.h"
-#include "gwi.h"
-
-MFUN(test_mfun){}
-GWION_IMPORT(begin_class) {
- Type t_invalid_var_name;
- GWI_OB((t_invalid_var_name = gwi_mk_type(gwi, "invalid_var_name", SZ_INT, "Object")))
- GWI_BB(gwi_class_ini(gwi, t_invalid_var_name, NULL, NULL))
- GWI_BB(gwi_class_ini(gwi, t_invalid_var_name, NULL, NULL))
- return GW_OK;
-}
GWI_BB(gwi_fptr_ini(gwi, "Vec4", "PtrType"))
GWI_OB(gwi_fptr_end(gwi, 0))
- const Type t_callback = gwi_mk_type(gwi, "Callback", SZ_INT, "Object");
- GWI_BB(gwi_class_ini(gwi, t_callback, NULL, NULL))
- GWI_BB(gwi_func_ini(gwi, "int", "callback", cb_func))
+ GWI_OB(gwi_class_ini(gwi, "Callback", NULL))
+ GWI_BB(gwi_func_ini(gwi, "int", "callback"))
GWI_BB(gwi_func_arg(gwi, "PtrType", "func"))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
+ GWI_BB(gwi_func_end(gwi, cb_func, ae_flag_static))
GWI_BB(gwi_class_end(gwi))
return GW_OK;
}
}
GWION_IMPORT(class_template) {
- Type t_class_template;
- const m_str list[2] = { "A", "B" };
- gwi_tmpl_ini(gwi, 2, list);
- GWI_OB((t_class_template = gwi_mk_type(gwi, "ClassTemplate", SZ_INT, "Object")))
- GWI_BB(gwi_class_ini(gwi, t_class_template, class_template_ctor, NULL))
- gwi_tmpl_end(gwi);
+ GWI_OB(gwi_class_ini(gwi, "ClassTemplate<~A,B~>", NULL))
+ gwi_class_xtor(gwi, class_template_ctor, NULL);
GWI_BB(gwi_item_ini(gwi, "A[]", "key"))
GWI_BB((o_map_key = gwi_item_end(gwi, ae_flag_member | ae_flag_template, NULL)))
GWI_BB(gwi_item_ini(gwi, "B[]", "value"))
GWI_BB((o_map_value = gwi_item_end(gwi, ae_flag_member, NULL)))
- GWI_BB(gwi_func_ini(gwi, "int", "<~C,D~>test", (f_xfun)1))
- GWI_BB(gwi_func_end(gwi, ae_flag_none))
+ GWI_BB(gwi_func_ini(gwi, "int", "<~C,D~>test"))
+ GWI_BB(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
GWI_BB(gwi_item_ini(gwi, "ClassTemplate<~Ptr<~int~>,int[]~>", "testObject"))
#include "gwi.h"
GWION_IMPORT(class_template_fail) {
- Type t_fail;
- const m_str list[2] = { "A", "B" };
- gwi_tmpl_ini(gwi, 2, list);
- GWI_OB((t_fail = gwi_mk_type(gwi, "ClassTemplate", SZ_INT, "Object")))
- GWI_BB(gwi_class_ini(gwi, t_fail, NULL, NULL))
- gwi_tmpl_end(gwi);
- gwi_tmpl_ini(gwi, 2, list);
- GWI_BB(gwi_func_ini(gwi, "int", "test", (f_xfun)1))
- GWI_BB(gwi_func_end(gwi, ae_flag_none))
- gwi_tmpl_end(gwi);
+ GWI_OB(gwi_class_ini(gwi, "ClassTemplate<~A,B~>", NULL))
+ GWI_BB(gwi_func_ini(gwi, "int", "test"))
+ GWI_BB(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
return GW_OK;
}
static m_int o_map_value;
#define MAP_KEY(a) *((M_Object*)(a->data + o_map_key))
#define MAP_VAL(a) *((M_Object*)(a->data + o_map_value))
-static CTOR(class_template_ctor) {
- /*char* name = strdup(o->type_ref->name);*/
- /*char* tmp = strsep(&name, "@");*/
- /*char* name1 = strsep(&name, "@");*/
-/*Type t1 = nspc_lookup_type1(o->type_ref->info->parent, insert_symbol(name1));*/
- /*Type t2 = nspc_lookup_type0(shred->vm->emit->env->curr, insert_symbol(name));*/
-/*free(tmp);*/
-/**(M_Object*)(o->data) = new_array(t1->size, 0, t1->array_depth);*/
- /**(M_Object*)(o->data + SZ_INT) = new_array(t2->size, 0, t2->array_depth);*/
-}
GWION_IMPORT(class_template) {
- Type t_class_template;
- const m_str list[2] = { "A", "B" };
- gwi_tmpl_ini(gwi, 2, list);
- GWI_OB((t_class_template = gwi_mk_type(gwi, "ClassTemplate", SZ_INT, "Object")))
- GWI_BB(gwi_class_ini(gwi, t_class_template, class_template_ctor, NULL))
- gwi_tmpl_end(gwi);
+ GWI_OB(gwi_class_ini(gwi, "ClassTemplate<~A,B~>", NULL))
GWI_BB(gwi_item_ini(gwi, "A[]", "key"))
GWI_BB((o_map_key = gwi_item_end(gwi, ae_flag_member | ae_flag_template, NULL)))
GWI_BB(gwi_item_ini(gwi, "B[]", "value"))
GWI_BB((o_map_value = gwi_item_end(gwi, ae_flag_member, NULL)))
- GWI_BB(gwi_func_ini(gwi, "int", "<~C,D'~>test", (f_xfun)1))
- GWI_BB(gwi_func_end(gwi, ae_flag_none))
+ GWI_BB(gwi_func_ini(gwi, "int", "<~C,D'~>test"))
+ GWI_BB(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
GWI_BB(gwi_item_ini(gwi, "ClassTemplate<~Ptr<~int~>,int[]~>", "testObject"))
SFUN(coverage_vec4) { m_vec4 v = {0,0,0,0}; *(m_vec4*)RETURN = v; }
GWION_IMPORT(coverage) {
- Type t_coverage;
- GWI_OB((t_coverage = gwi_mk_type(gwi, "Coverage", SZ_INT, "Object")))
- GWI_BB(gwi_class_ini(gwi, t_coverage, NULL, NULL))
- GWI_BB(gwi_func_ini(gwi, "int", "i", coverage_int))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
- GWI_BB(gwi_func_ini(gwi, "float", "f", coverage_float))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
- GWI_BB(gwi_func_ini(gwi, "complex", "c", coverage_complex))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
- GWI_BB(gwi_func_ini(gwi, "Vec3", "v", coverage_vec3))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
- GWI_BB(gwi_func_ini(gwi, "Vec4", "w", coverage_vec4))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
+ GWI_OB(gwi_class_ini(gwi, "Coverage", NULL))
+ GWI_BB(gwi_func_ini(gwi, "int", "i"))
+ GWI_BB(gwi_func_end(gwi, coverage_int, ae_flag_static))
+ GWI_BB(gwi_func_ini(gwi, "float", "f"))
+ GWI_BB(gwi_func_end(gwi, coverage_float, ae_flag_static))
+ GWI_BB(gwi_func_ini(gwi, "complex", "c"))
+ GWI_BB(gwi_func_end(gwi, coverage_complex, ae_flag_static))
+ GWI_BB(gwi_func_ini(gwi, "Vec3", "v"))
+ GWI_BB(gwi_func_end(gwi, coverage_vec3, ae_flag_static))
+ GWI_BB(gwi_func_ini(gwi, "Vec4", "w"))
+ GWI_BB(gwi_func_end(gwi, coverage_vec4, ae_flag_static))
ALLOC_PTR(gwi->gwion->mp, i, m_uint, 5);
GWI_BB(gwi_item_ini(gwi,"int", "s_i"))
GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM9", 9))
GWI_OB(gwi_enum_end(gwi))
- Type t_enum;
- GWI_OB((t_enum = gwi_mk_type(gwi, "Enum", 0, NULL)))
- GWI_BB(gwi_class_ini(gwi, t_enum, NULL, NULL))
+ GWI_OB(gwi_class_ini(gwi, "Enum", NULL))
GWI_BB(gwi_enum_ini(gwi, 0))
GWI_BB(gwi_enum_add(gwi, "ENUM0", 0))
GWI_BB(gwi_enum_add(gwi, "ENUM1", 1))
#include "gwi.h"
GWION_IMPORT(extend_array_test) {
- Type t_array_ext;
- GWI_OB((t_array_ext = gwi_mk_type(gwi, "ArrayExt", SZ_INT, NULL)))
- GWI_BB(gwi_class_ini(gwi, t_array_ext, NULL, NULL))
- Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "float"), GWI_LOC));
- Exp e = new_exp_prim_int(gwi->gwion->st->p, 1, GWI_LOC);
- Array_Sub array = new_array_sub(gwi->gwion->st->p, e);
- td->array = array;
- GWI_BB(gwi_class_ext(gwi, td))
+ GWI_OB(gwi_class_ini(gwi, "ArrayExt", "float[1]"))
GWI_BB(gwi_class_end(gwi))
return GW_OK;
}
+++ /dev/null
-#include "gwion_util.h"
-#include "gwion_ast.h"
-#include "oo.h"
-#include "vm.h"
-#include "env.h"
-#include "type.h"
-#include "instr.h"
-#include "object.h"
-#include "instr.h"
-#include "vm.h"
-#include "gwion.h"
-#include "value.h"
-#include "operator.h"
-#include "import.h"
-#include "gwi.h"
-
-static CTOR(ev_ctor) { printf(" %p this to test ctor\n", (void*)o); }
-
-GWION_IMPORT(extend_event_test) {
- Type t_ev ;
- GWI_OB((t_ev = gwi_mk_type(gwi, "Ev", SZ_INT , NULL)))
- GWI_BB(gwi_class_ini(gwi, t_ev, ev_ctor, NULL))
- Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Event"), GWI_LOC));
- GWI_BB(gwi_class_ext(gwi, td))
- GWI_BB(gwi_class_end(gwi))
- return GW_OK;
-}
+++ /dev/null
-Ev ev;
-<<< ev >>>;
+++ /dev/null
-#include "gwion_util.h"
-#include "gwion_ast.h"
-#include "oo.h"
-#include "vm.h"
-#include "env.h"
-#include "type.h"
-#include "instr.h"
-#include "object.h"
-#include "instr.h"
-#include "vm.h"
-#include "gwion.h"
-#include "value.h"
-#include "operator.h"
-#include "import.h"
-#include "gwi.h"
-
-GWION_IMPORT(extend_event_test) {
- Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Event"), GWI_LOC));
- return gwi_class_ext(gwi, td);
-}
+++ /dev/null
-#include "gwion_util.h"
-#include "gwion_ast.h"
-#include "oo.h"
-#include "vm.h"
-#include "env.h"
-#include "type.h"
-#include "instr.h"
-#include "object.h"
-#include "instr.h"
-#include "vm.h"
-#include "gwion.h"
-#include "value.h"
-#include "operator.h"
-#include "import.h"
-#include "gwi.h"
-
-static CTOR(ev_ctor) { printf(" %p this to test ctor\n", (void*)o); }
-
-GWION_IMPORT(extend_event_test) {
- Type t_ev ;
- GWI_OB((t_ev = gwi_mk_type(gwi, "Ev", SZ_INT , NULL)))
- GWI_BB(gwi_class_ini(gwi, t_ev, ev_ctor, NULL))
- Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Event"), GWI_LOC));
- td->array = new_array_sub(gwi->gwion->mp, NULL);
- GWI_BB(gwi_class_ext(gwi, td))
- GWI_BB(gwi_class_end(gwi))
- return GW_OK;
-}
+++ /dev/null
-#include "gwion_util.h"
-#include "gwion_ast.h"
-#include "oo.h"
-#include "vm.h"
-#include "env.h"
-#include "type.h"
-#include "instr.h"
-#include "object.h"
-#include "instr.h"
-#include "vm.h"
-#include "gwion.h"
-#include "value.h"
-#include "operator.h"
-#include "import.h"
-#include "gwi.h"
-
-static CTOR(ev_ctor) { printf(" %p this to test ctor\n", (void*)o); }
-
-GWION_IMPORT(extend_event_test) {
- Type t_ev ;
- GWI_OB((t_ev = gwi_mk_type(gwi, "Ev", SZ_INT , NULL)))
- GWI_BB(gwi_class_ini(gwi, t_ev, ev_ctor, NULL))
- Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Event"), GWI_LOC));
- GWI_BB(gwi_class_ext(gwi, td))
- GWI_BB(gwi_class_ext(gwi, td))
- GWI_BB(gwi_class_end(gwi))
- return GW_OK;
-}
+++ /dev/null
-#include "gwion_util.h"
-#include "gwion_ast.h"
-#include "oo.h"
-#include "vm.h"
-#include "env.h"
-#include "type.h"
-#include "instr.h"
-#include "object.h"
-#include "instr.h"
-#include "vm.h"
-#include "gwion.h"
-#include "value.h"
-#include "operator.h"
-#include "import.h"
-#include "gwi.h"
-
-GWION_IMPORT(extend_pair_test) {
- m_str types[] = { "A", "B" };
- Type t_pair_ext ;
- GWI_OB((t_pair_ext = gwi_mk_type(gwi, "PairExt", SZ_INT , NULL)))
- GWI_BB(gwi_tmpl_ini(gwi, 2, types))
- GWI_BB(gwi_class_ini(gwi, t_pair_ext, NULL, NULL))
- GWI_BB(gwi_tmpl_end(gwi))
- Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Pair"), GWI_LOC));
- Type_Decl* td0 = new_type_decl(gwi->gwion->st->p ,new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "A"), GWI_LOC));
- Type_Decl* td1 = new_type_decl(gwi->gwion->st->p ,new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "B"), GWI_LOC));
- Type_List tl1 = new_type_list(gwi->gwion->st->p, td1, NULL);
- Type_List tl0 = new_type_list(gwi->gwion->st->p,td0, tl1);
- td->types = tl0;
- GWI_BB(gwi_class_ext(gwi, td))
- GWI_BB(gwi_class_end(gwi))
- return GW_OK;
-}
+++ /dev/null
-<~int, int~>PairExt p;
-<<< p >>>;
-<<< p.key >>>;
-<<< p.val >>>;
#include "gwi.h"
GWION_IMPORT(fail_on_next_arg) {
- GWI_BB(gwi_func_ini(gwi, "void", "test", (f_xfun)1))
+ GWI_BB(gwi_func_ini(gwi, "void", "test"))
GWI_BB(gwi_func_arg(gwi, "int", "i"))
GWI_BB(gwi_func_arg(gwi, "int", "j"))
- return gwi_func_end(gwi, ae_flag_none);
+ return gwi_func_end(gwi, (f_xfun)1, ae_flag_none);
}
#include "gwi.h"
GWION_IMPORT(fail_on_next_arg) {
- GWI_BB(gwi_func_ini(gwi, "void", "test", (f_xfun)1))
+ GWI_BB(gwi_func_ini(gwi, "void", "test"))
GWI_BB(gwi_func_arg(gwi, "int", "i"))
GWI_BB(gwi_func_arg(gwi, "i;t", "j"))
GWI_BB(gwi_func_arg(gwi, "int", "j[]"))
- return gwi_func_end(gwi, ae_flag_none);
+ return gwi_func_end(gwi, (f_xfun)1, ae_flag_none);
}
static MFUN(test_func) { puts("test"); }
GWION_IMPORT(typedef_test) {
- Type t_func_typedef;
- GWI_OB((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT , NULL)))
GWI_BB(gwi_fptr_ini(gwi, "void", "PtrType"))
GWI_OB(gwi_fptr_end(gwi, 0))
-
- GWI_BB(gwi_class_ini(gwi, t_func_typedef, NULL, NULL))
+
+ GWI_OB(gwi_class_ini(gwi, "FuncTypedef", NULL))
GWI_BB(gwi_fptr_ini(gwi, "void", "PtrType"))
GWI_OB(gwi_fptr_end(gwi, ae_flag_static))
- GWI_BB(gwi_func_ini(gwi, "void", "test_func", test_func))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
+ GWI_BB(gwi_func_ini(gwi, "void", "test_func"))
+ GWI_BB(gwi_func_end(gwi, test_func, ae_flag_static))
GWI_BB(gwi_item_ini(gwi, "PtrType", "ptr"))
GWI_BB(gwi_item_end(gwi, ae_flag_static, NULL))
GWI_BB(gwi_class_end(gwi))
#include "instr.h"
GWION_IMPORT(too_many_args) {
- GWI_BB(gwi_func_ini(gwi, "int", "test", (f_xfun)1))
+ GWI_BB(gwi_func_ini(gwi, "int", "test"))
GWI_BB(gwi_func_arg(gwi, "int", "i[][]"))
GWI_BB(gwi_func_arg(gwi, "Int", "i"))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
return GW_OK;
}
#include "instr.h"
GWION_IMPORT(too_many_args) {
- GWI_BB(gwi_func_ini(gwi, "int[]", "test", (f_xfun)1))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_ini(gwi, "int[]", "test"))
+ GWI_BB(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
return GW_OK;
}
}
GWION_IMPORT(func_tmpl) {
- GWI_BB(gwi_func_ini(gwi, "int[]", "<~A~>test", func_tmpl_xfun))
+ GWI_BB(gwi_func_ini(gwi, "int[]", "<~A~>test"))
GWI_BB(gwi_func_arg(gwi, "A", "i"))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, func_tmpl_xfun, ae_flag_none))
return GW_OK;
}
}
GWION_IMPORT(func_tmpl) {
- GWI_BB(gwi_func_ini(gwi, "voit", "<~A~>test", func_tmpl_xfun))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_ini(gwi, "voit", "<~A~>test"))
+ GWI_BB(gwi_func_end(gwi, func_tmpl_xfun, ae_flag_none))
return GW_OK;
}
#include "instr.h"
GWION_IMPORT(too_many_args) {
- GWI_BB(gwi_func_ini(gwi, "int", "test", (f_xfun)1))
+ GWI_BB(gwi_func_ini(gwi, "int", "test"))
GWI_BB(gwi_func_arg(gwi, "int", "i"))
GWI_BB(gwi_func_arg(gwi, "int", "j"))
GWI_BB(gwi_func_arg(gwi, "int", "k"))
GWI_BB(gwi_func_arg(gwi, "int", "x"))
GWI_BB(gwi_func_arg(gwi, "int", "y"))
GWI_BB(gwi_func_arg(gwi, "int", "z"))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, (f_xfun)1, ae_flag_none))
return GW_OK;
}
}
GWION_IMPORT(global_func_test) {
- GWI_BB(gwi_func_ini(gwi, "int", "test", coverage_int))
+ GWI_BB(gwi_func_ini(gwi, "int", "test"))
GWI_BB(gwi_func_arg(gwi, "int", "i"))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, coverage_int, ae_flag_none))
return GW_OK;
}
static MFUN(test_mfun){}
GWION_IMPORT(invalid_arg_test) {
- Type t_invalid_var_type ;
- GWI_OB((t_invalid_var_type = gwi_mk_type(gwi, "invalid_var_type",
- SZ_INT , NULL)))
- GWI_BB(gwi_class_ini(gwi, t_invalid_var_type, NULL, NULL))
- GWI_BB(gwi_func_ini(gwi, "int[]", "func", test_mfun))
+ GWI_OB(gwi_class_ini(gwi, "InvalidArg", NULL))
+ GWI_BB(gwi_func_ini(gwi, "int[]", "func"))
GWI_BB(gwi_func_arg(gwi, ".int", "i"))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
-
+ GWI_BB(gwi_func_end(gwi, test_mfun, ae_flag_static))
GWI_BB(gwi_class_end(gwi))
return GW_OK;
}
#include "import.h"
static MFUN(test_mfun){}
-GWION_IMPORT(inalid_array_test) {
- Type t_invalid_var_type;
- GWI_OB((t_invalid_var_type = gwi_mk_type(gwi, "invalid_var_type",
- SZ_INT , NULL)))
- GWI_BB(gwi_class_ini(gwi, t_invalid_var_type, NULL, NULL))
- GWI_BB(gwi_func_ini(gwi, "int[]", "func", test_mfun))
+GWION_IMPORT(invalid_array_test) {
+ GWI_OB(gwi_class_ini(gwi, "InvalidArray", NULL))
+ GWI_BB(gwi_func_ini(gwi, "int[]", "func"))
GWI_BB(gwi_func_arg(gwi, "int[][]", "i"))
GWI_BB(gwi_func_arg(gwi, "int", "j[]"))
GWI_BB(gwi_func_arg(gwi, "int[]", "k[]"))
GWI_BB(gwi_func_arg(gwi, "int", "l"))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
+ GWI_BB(gwi_func_end(gwi, test_mfun, ae_flag_static))
- GWI_BB(gwi_func_ini(gwi, "int[]", "func", test_mfun))
+ GWI_BB(gwi_func_ini(gwi, "int[]", "func"))
GWI_BB(gwi_func_arg(gwi, "int", "j[][]"))
GWI_BB(gwi_func_arg(gwi, "int[]", "+k[][][]"))
GWI_BB(gwi_func_arg(gwi, "int", "l"))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
+ GWI_BB(gwi_func_end(gwi, test_mfun, ae_flag_static))
- GWI_BB(gwi_func_ini(gwi, "int[]", "func", test_mfun))
+ GWI_BB(gwi_func_ini(gwi, "int[]", "func"))
GWI_BB(gwi_func_arg(gwi, "+int", "j[][]"))
GWI_BB(gwi_func_arg(gwi, "int[]", "+k[][][]"))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
+ GWI_BB(gwi_func_end(gwi, test_mfun, ae_flag_static))
GWI_BB(gwi_class_end(gwi))
return GW_OK;
static MFUN(test_mfun){}
GWION_IMPORT(invalid_func_test) {
- Type t_invalid_var_type ;
- GWI_OB((t_invalid_var_type = gwi_mk_type(gwi, "invalid_var_type",
- SZ_INT , NULL)))
- GWI_BB(gwi_class_ini(gwi, t_invalid_var_type, NULL, NULL))
- GWI_BB(gwi_func_ini(gwi, ".int", "i", test_mfun))
- GWI_BB(gwi_func_end(gwi, ae_flag_static))
+ GWI_OB(gwi_class_ini(gwi, "t_invalid_var_type", NULL))
+ GWI_BB(gwi_func_ini(gwi, ".int", "i"))
+ GWI_BB(gwi_func_end(gwi, test_mfun, ae_flag_static))
GWI_BB(gwi_class_end(gwi))
return GW_OK;
#include "import.h"
GWION_IMPORT(invalid_type1_test) {
- Type t_invalid_var_type;
- GWI_OB((t_invalid_var_type = gwi_mk_type(gwi, "invalid_var_type",
- SZ_INT , NULL)))
- GWI_BB(gwi_class_ini(gwi, t_invalid_var_type, NULL, NULL))
+ GWI_OB(gwi_class_ini(gwi, "invalid_var_type", NULL))
GWI_BB(gwi_item_ini(gwi,"i|nt", "test"))
GWI_BB(gwi_item_end(gwi, 0, NULL))
GWI_BB(gwi_class_end(gwi))
#include "import.h"
GWION_IMPORT(invalid_type2_test) {
- Type t_invalid_var_type ;
- GWI_OB((t_invalid_var_type = gwi_mk_type(gwi, "invalid_var_type",
- SZ_INT , NULL)))
- GWI_BB(gwi_class_ini(gwi, t_invalid_var_type, NULL, NULL))
+ GWI_OB(gwi_class_ini(gwi, "invalid_var_type", NULL))
GWI_BB(gwi_item_ini(gwi,".int", "test"))
GWI_BB(gwi_item_end(gwi, 0, NULL))
GWI_BB(gwi_class_end(gwi))
#include "import.h"
GWION_IMPORT(invalid_type3_test) {
- Type t_invalid_var_type ;
- GWI_OB((t_invalid_var_type = gwi_mk_type(gwi, ".invalid_var_type",
- SZ_INT , NULL)))
- GWI_BB(gwi_class_ini(gwi, t_invalid_var_type, NULL, NULL))
+ GWI_OB(gwi_class_ini(gwi, "InvalidVarType", NULL))
GWI_BB(gwi_item_ini(gwi,".int", "test"))
GWI_BB(gwi_item_end(gwi, 0, NULL))
GWI_BB(gwi_class_end(gwi))
#include "gwi.h"
GWION_IMPORT(str2decl) {
- const Type t_t0 = gwi_mk_type(gwi, "Test", SZ_INT, "Object");
- GWI_BB(gwi_class_ini(gwi, t_t0, NULL, NULL))
- const Type t_t2 = gwi_mk_type(gwi, "Child", SZ_INT, "Object");
- GWI_BB(gwi_class_ini(gwi, t_t2, NULL, NULL))
+ GWI_OB(gwi_class_ini(gwi, "Test", NULL))
+ GWI_OB(gwi_class_ini(gwi, "Child", NULL))
GWI_BB(gwi_class_end(gwi))
GWI_BB(gwi_class_end(gwi))
- const Type t_t1 = gwi_mk_type(gwi, "Test2", SZ_INT, "Test.Child");
- GWI_BB(gwi_class_ini(gwi, t_t1, NULL, NULL))
+ GWI_OB(gwi_class_ini(gwi, "Test2", "Test.Child"))
return gwi_class_end(gwi);
}
static MFUN(template_arg_fun) {}
GWION_IMPORT(template_arg_test) {
- Type t_template_arg;
- GWI_OB((t_template_arg = gwi_mk_type(gwi, "TemplateArg", SZ_INT , NULL)))
- GWI_BB(gwi_class_ini(gwi, t_template_arg, NULL, NULL))
- GWI_BB(gwi_func_ini(gwi, "int", "set", template_arg_fun))
+ GWI_OB(gwi_class_ini(gwi, "TemplateArg", NULL))
+ GWI_BB(gwi_func_ini(gwi, "int", "set"))
GWI_BB(gwi_func_arg(gwi, "Pair<Ptr<int>,float>","test"))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, template_arg_fun, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
return GW_OK;
}
GWION_IMPORT(trig) {
- const Type t_trig = gwi_mk_type(gwi, "Trig", SZ_INT, "UGen");
- GWI_BB(gwi_class_ini(gwi, t_trig, trig_ctor, NULL))
+ GWI_OB(gwi_class_ini(gwi, "Trig", "UGen"))
+ gwi_class_xtor(gwi, trig_ctor, NULL);
gwi_class_end(gwi);
- const Type t_trig2 = gwi_mk_type(gwi, "Trig2", SZ_INT, "UGen");
- GWI_BB(gwi_class_ini(gwi, t_trig2, trig2_ctor, NULL))
+ GWI_OB(gwi_class_ini(gwi, "Trig2", "UGen"))
+ gwi_class_xtor(gwi, trig2_ctor, NULL);
return gwi_class_end(gwi);
}
#include "import.h"
GWION_IMPORT(union_member) {
- const Type t_unionmember = gwi_mk_type(gwi, "UnionMember", SZ_INT, "Object");
- GWI_BB(gwi_class_ini(gwi, t_unionmember, NULL, NULL))
+ GWI_OB(gwi_class_ini(gwi, "UnionMember", NULL))
GWI_BB(gwi_union_ini(gwi, "U", NULL))
GWI_BB(gwi_union_add(gwi,"float", "f"))
GWI_BB(gwi_union_add(gwi,"int[]", "i"))
}
GWION_IMPORT(variadic test) {
- const Type t_variadic = gwi_mk_type(gwi, "Variadic", SZ_INT, "Object");
- GWI_BB(gwi_class_ini(gwi, t_variadic, NULL, NULL))
- GWI_BB(gwi_func_ini(gwi, "void", "member", m_variadic))
+ GWI_OB(gwi_class_ini(gwi, "Variadic", NULL))
+ GWI_BB(gwi_func_ini(gwi, "void", "member"))
GWI_BB(gwi_func_arg(gwi, "string", "format"))
- GWI_BB(gwi_func_end(gwi, ae_flag_variadic))
- GWI_BB(gwi_func_ini(gwi, "void", "test", m_test))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, m_variadic, ae_flag_variadic))
+ GWI_BB(gwi_func_ini(gwi, "void", "test"))
+ GWI_BB(gwi_func_end(gwi, m_test, ae_flag_none))
GWI_BB(gwi_class_end(gwi))
return GW_OK;
}
}
GWION_IMPORT(gwion_remove_test) {
- GWI_BB(gwi_func_ini(gwi, "int", "test", coverage_int))
+ GWI_BB(gwi_func_ini(gwi, "int", "test"))
GWI_BB(gwi_func_arg(gwi, "int", "i"))
- GWI_BB(gwi_func_end(gwi, 0))
+ GWI_BB(gwi_func_end(gwi, coverage_int, ae_flag_none))
return GW_OK;
}
#!/bin/bash
-# [test] #66
+# [test] #60
n=0
[ "$1" ] && n="$1"