while ((td = td->next) && type && type->nspc) {
const Nspc nspc = type->nspc;
if(!(type = find_in_parent(type, td->tag.sym)))
+ ERR_O(td->tag.loc, _("...(cannot find class '%s' in nspc '%s')"),
+s_name(td->tag.sym), nspc->name);
+
+/*
+ if(!type)
ERR_O(td->tag.loc, _("...(cannot find class '%s' in nspc '%s')"),
s_name(td->tag.sym), nspc->name);
+ Type_Decl *next = td->next;
+ td->next = NULL;
+env_push_type(env, type);
+ type = known_type(env, td);
+env_pop(env, 0); // respect scope depth // use env scope
+ td->next = next;
+*/
}
return type;
}
m_str str;
const loc_t loc;
};
+ANN static void eat_space(struct td_checker *tdc) {
+ while(isspace(*tdc->str)) {
+ tdc->str++;
+ }
+}
struct AC {
m_str str;
vd->value = NULL;
return true;
}
-
+ANN static Type_Decl *_str2td(const Gwion, struct td_checker *tdc);
#define ARG_ERROR (Arg_List) -1
#define SPEC_ERROR (Specialized_List) -1
#define TMPLARG_ERROR (TmplArg_List) -1
ANN static bool _tmpl_list(const Gwion gwion,
struct td_checker *tdc, Specialized_List *sl) {
+ eat_space(tdc);
if(unlikely(!strncmp(tdc->str, "...", 3))) {
tdc->str += 3;
Specialized spec = { .tag = MK_TAG(insert_symbol(gwion->st, "..."), tdc->loc) };
mp_vector_add(gwion->mp, sl, Specialized, spec);
return true;
}
- DECL_O(const Symbol, sym, = __str2sym(gwion, tdc));
- // TODO: handle traits?
- Specialized spec = { .tag = MK_TAG(sym, tdc->loc) };
- mp_vector_add(gwion->mp, sl, Specialized, spec);
+ if(unlikely(!strncmp(tdc->str, "const ", 6))) {
+ tdc->str += 6;
+ // eat space?
+ eat_space(tdc);
+ Type_Decl *td = _str2td(gwion, tdc);
+ eat_space(tdc);
+ DECL_O(const Symbol, sym, = __str2sym(gwion, tdc));
+ Specialized spec = { .td = td, .tag = MK_TAG(sym, tdc->loc) };
+ mp_vector_add(gwion->mp, sl, Specialized, spec);
+ } else {
+ DECL_O(const Symbol, sym, = __str2sym(gwion, tdc));
+ // TODO: handle traits?
+ Specialized spec = { .tag = MK_TAG(sym, tdc->loc) };
+ mp_vector_add(gwion->mp, sl, Specialized, spec);
+ }
if (*tdc->str == ',') {
++tdc->str;
if (!_tmpl_list(gwion, tdc, sl))
if (!str2tl(gwion, tdc, tl))
return false;
}
- } else GWION_ERR_B(tdc->loc, "invalid character in template list");
+ } else GWION_ERR_B(tdc->loc, "invalid character %c in template list", *tdc->str);
return true;
}
return td;
}
+#include "gwion_parse.h"
ANN Type_Decl *str2td(const Gwion gwion, const m_str str, const loc_t loc) {
+ return gwion_parse_type_decl(gwion, str, loc);
+
+
struct td_checker tdc = {.str = str, .loc = loc};
DECL_O(Type_Decl *, td, = _str2td(gwion, &tdc));
if(*tdc.str) {
new_type_def(gwi->gwion->mp, td, gwi->ck->sym, gwi->loc);
if (gwi->ck->when) tdef->when = gwi->ck->when;
if (gwi->ck->tmpl) tdef->tmpl = gwi_tmpl(gwi);
+
+ if (safe_tflag(gwi->gwion->env->class_def, tflag_tmpl)) {
+ Section section = MK_SECTION(
+ type, type_def, tdef, gwi->loc
+ );
+ gwi_body(gwi, §ion);
+ ck_end(gwi);
+ return 1;
+ }
+
gwi->ck->td = NULL;
gwi->ck->tmpl = NULL;
const bool ret = traverse_type_def(gwi->gwion->env, tdef);
const Array_Sub array = (Array_Sub)data;
const Type t_int = env->gwion->type[et_int];
Exp* e = array->exp;
+ // FIX: we should only take up to *depth* expressions
do CHECK_ON(check_implicit(env, e, t_int));
while ((e = e->next));
const Type t = get_array_type(array->type);
GWION_IMPORT(func) {
gwidoc(gwi, "the base of all functions.");
- const Type t_function = gwi_mk_type(gwi, "function", SZ_INT, NULL);
+ const Type t_function = gwi_mk_type(gwi, "Function", SZ_INT, NULL);
GWI_B(gwi_gack(gwi, t_function, gack_function))
GWI_B(gwi_set_global_type(gwi, t_function, et_function))
gwidoc(gwi, "the base of decayed operators.");
- const Type t_op = gwi_mk_type(gwi, "operator", SZ_INT, "function");
+ const Type t_op = gwi_mk_type(gwi, "Operator", SZ_INT, "Function");
GWI_B(gwi_set_global_type(gwi, t_op, et_op))
gwidoc(gwi, "the base of function pointers.");
- const Type t_closure = gwi_class_ini(gwi, "funptr", "Object");
+ const Type t_closure = gwi_class_ini(gwi, "Funptr", "Object");
t_closure->nspc->offset = SZ_INT*3;
gwi_class_xtor(gwi, fptr_ctor, fptr_dtor);
GWI_B(gwi_set_global_type(gwi, t_closure, et_closure))
GWI_B(gwi_func_ini(gwi, "void", "default"));
GWI_B(gwi_func_end(gwi, fptr_default, ae_flag_none));
- gwi_class_end(gwi);
-
- GWI_B(gwi_oper_ini(gwi, "funptr", NULL, NULL))
+ gwi_class_end(gwi)
+;
+ GWI_B(gwi_oper_ini(gwi, "Funptr", NULL, NULL))
GWI_B(gwi_oper_add(gwi, opck_closure_scan))
GWI_B(gwi_oper_end(gwi, "class", NULL))
- GWI_B(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "function", NULL))
+ GWI_B(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "Function", NULL))
GWI_B(gwi_oper_add(gwi, opck_func_call))
GWI_B(gwi_oper_end(gwi, "=>", NULL))
- GWI_B(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "funptr", NULL))
+ GWI_B(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "Funptr", NULL))
GWI_B(gwi_oper_add(gwi, opck_fptr_call))
GWI_B(gwi_oper_end(gwi, "=>", NULL))
- GWI_B(gwi_oper_ini(gwi, "function", "funptr", NULL))
+ GWI_B(gwi_oper_ini(gwi, "Function", "Funptr", NULL))
GWI_B(gwi_oper_add(gwi, opck_fptr_assign))
GWI_B(gwi_oper_emi(gwi, opem_fptr_assign))
GWI_B(gwi_oper_end(gwi, ":=>", NULL))
GWI_B(gwi_oper_end(gwi, "@implicit", NULL))
GWI_B(gwi_oper_add(gwi, opck_fptr_cast))
GWI_B(gwi_oper_end(gwi, "$", NULL))
- GWI_B(gwi_oper_ini(gwi, "operator", "funptr", NULL))
+ GWI_B(gwi_oper_ini(gwi, "Operator", "Funptr", NULL))
GWI_B(gwi_oper_add(gwi, opck_op_impl))
GWI_B(gwi_oper_emi(gwi, opem_op_impl))
GWI_B(gwi_oper_end(gwi, "@implicit", NULL))
GWI_B(gwi_oper_add(gwi, opck_op_cast))
GWI_B(gwi_oper_end(gwi, "$", NULL))
- GWI_B(gwi_oper_ini(gwi, "function", "function", NULL))
+ GWI_B(gwi_oper_ini(gwi, "Function", "Function", NULL))
GWI_B(gwi_oper_add(gwi, opck_auto_fptr))
GWI_B(gwi_oper_end(gwi, ":=>", int_r_assign))
- GWI_B(gwi_oper_ini(gwi, "function", NULL, NULL))
+ GWI_B(gwi_oper_ini(gwi, "Function", NULL, NULL))
GWI_B(gwi_oper_add(gwi, opck_func_partial))
GWI_B(gwi_oper_end(gwi, "@partial", NULL))
GWI_B(gwi_oper_ini(gwi, "Class", NULL, NULL))
GWI_B(gwi_oper_emi(gwi, opem_deep_ne_any))
GWI_B(gwi_oper_end(gwi, "<>", NULL))
- GWI_B(gwi_oper_ini(gwi, "@Compound", "@Compound", "bool"))
+ //GWI_B(gwi_oper_ini(gwi, "@Compound", "@Compound", "bool"))
+ GWI_B(gwi_oper_ini(gwi, "Compound", "Compound", "bool"))
gwidoc(gwi, "Deep Equality");
GWI_B(gwi_oper_add(gwi, opck_deep_equal))
GWI_B(gwimport_enum(gwi));
- const Type t_compound = gwi_mk_type(gwi, "@Compound", SZ_INT, NULL);
+ //const Type t_compound = gwi_mk_type(gwi, "@Compound", SZ_INT, NULL);
+ const Type t_compound = gwi_mk_type(gwi, "Compound", SZ_INT, NULL);
GWI_B(gwi_gack(gwi, t_compound, gack_compound))
GWI_B(gwi_set_global_type(gwi, t_compound, et_compound))
GWI_B(gwimport_union(gwi))
GWI_B(gwimport_array(gwi))
+ GWI_B(gwimport_vector(gwi))
GWI_B(gwimport_event(gwi))
GWI_B(gwimport_ugen(gwi))
GWI_B(gwimport_xork(gwi))
GWI_B(gwimport_modules(gwi))
gwidoc(gwi, "allow member access.");
- GWI_B(gwi_oper_ini(gwi, "@Compound", (m_str)OP_ANY_TYPE, NULL))
+ //GWI_B(gwi_oper_ini(gwi, "@Compound", (m_str)OP_ANY_TYPE, NULL))
+ GWI_B(gwi_oper_ini(gwi, "Compound", (m_str)OP_ANY_TYPE, NULL))
GWI_B(gwi_oper_add(gwi, opck_object_dot))
GWI_B(gwi_oper_emi(gwi, opem_object_dot))
GWI_B(gwi_oper_end(gwi, ".", NULL))
// allow const generics in functions
- GWI_B(gwi_oper_ini(gwi, "function", (m_str)OP_ANY_TYPE, NULL))
+ GWI_B(gwi_oper_ini(gwi, "Function", (m_str)OP_ANY_TYPE, NULL))
GWI_B(gwi_oper_add(gwi, opck_object_dot))
GWI_B(gwi_oper_emi(gwi, opem_object_dot))
GWI_B(gwi_oper_end(gwi, ".", NULL))
GWION_IMPORT(gack) {
gwidoc(gwi, "a type for *pretty print*.");
- const Type t_gack = gwi_mk_type(gwi, "@Gack", SZ_INT, NULL);
+ const Type t_gack = gwi_mk_type(gwi, "Gack", SZ_INT, NULL);
GWI_B(gwi_gack(gwi, t_gack, gack_gack))
GWI_B(gwi_set_global_type(gwi, t_gack, et_gack));
gwidoc(gwi, "@Gack implicit cast");
- GWI_B(gwi_oper_ini(gwi, "@Gack", (m_str)OP_ANY_TYPE, NULL))
+ GWI_B(gwi_oper_ini(gwi, "Gack", (m_str)OP_ANY_TYPE, NULL))
GWI_B(gwi_oper_add(gwi, opck_gack_implicit))
GWI_B(gwi_oper_emi(gwi, opem_gack_implicit))
GWI_B(gwi_oper_end(gwi, "@implicit", NULL))
GWI_B(gwi_func_ini(gwi, "int", "default_tick"))
GWI_B(gwi_func_end(gwi, default_tick, 0))
GWI_B(gwi_class_end(gwi))
- GWI_B(gwi_oper_ini(gwi, "function", "UsrUGen", "UsrUGen"))
+ GWI_B(gwi_oper_ini(gwi, "Function", "UsrUGen", "UsrUGen"))
GWI_B(gwi_oper_add(gwi, opck_usrugen))
GWI_B(gwi_oper_emi(gwi, opem_usrugen))
GWI_B(gwi_oper_end(gwi, "~=>", NULL))
}
GWION_IMPORT(object) {
- const Type t_object = gwi_mk_type(gwi, "Object", SZ_INT, "@Compound");
+ //const Type t_object = gwi_mk_type(gwi, "Object", SZ_INT, "@Compound");
+ const Type t_object = gwi_mk_type(gwi, "Object", SZ_INT, "Compound");
gwi_set_global_type(gwi, t_object, et_object);
set_tflag(t_object, tflag_compound);
t_object->nspc = new_nspc(gwi->gwion->mp, "Object");
GWI_B(gwi_oper_add(gwi, opck_object_at))
GWI_B(gwi_oper_emi(gwi, opem_object_at))
GWI_B(gwi_oper_end(gwi, ":=>", NULL))
- GWI_B(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "@Compound", NULL))
+ //GWI_B(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "@Compound", NULL))
+ GWI_B(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "Compound", NULL))
GWI_B(gwi_oper_add(gwi, opck_object_instance))
GWI_B(gwi_oper_end(gwi, "=>", NULL))
GWI_B(gwi_oper_ini(gwi, "Object", "Object", "bool"))
GWI_B(gwi_oper_add(gwi, opck_unary_meta2))
GWI_B(gwi_oper_emi(gwi, opem_not_object))
GWI_B(gwi_oper_end(gwi, "!", NULL))
- GWI_B(gwi_oper_ini(gwi, "@Compound", NULL, NULL))
+ //GWI_B(gwi_oper_ini(gwi, "@Compound", NULL, NULL))
+ GWI_B(gwi_oper_ini(gwi, "Compound", NULL, NULL))
GWI_B(gwi_oper_add(gwi, opck_struct_scan))
GWI_B(gwi_oper_end(gwi, "class", NULL))
return true;
"#!- samp => now;\n"
"#!- }\n"
"#!- }");
- GWI_B(gwi_oper_ini(gwi, "UGen", "function", "Sift"));
+ GWI_B(gwi_oper_ini(gwi, "UGen", "Function", "Sift"));
GWI_B(gwi_oper_add(gwi, opck_ctrl));
GWI_B(gwi_oper_end(gwi, "|>", NULL));
- GWI_B(gwi_oper_ini(gwi, "Sift", "function", "Sift"));
+ GWI_B(gwi_oper_ini(gwi, "Sift", "Function", "Sift"));
GWI_B(gwi_oper_add(gwi, opck_sift));
GWI_B(gwi_oper_end(gwi, "|>", NULL));
- GWI_B(gwi_oper_ini(gwi, "UGen", "funptr", "Sift"));
+ GWI_B(gwi_oper_ini(gwi, "UGen", "Funptr", "Sift"));
GWI_B(gwi_oper_add(gwi, opck_ctrl));
GWI_B(gwi_oper_end(gwi, "|>", NULL));
- GWI_B(gwi_oper_ini(gwi, "Sift", "funptr", "Sift"));
+ GWI_B(gwi_oper_ini(gwi, "Sift", "Funptr", "Sift"));
GWI_B(gwi_oper_add(gwi, opck_sift));
GWI_B(gwi_oper_end(gwi, "|>", NULL));
return true;
GWI_B(gwi_oper_emi(gwi, opem_none))
GWI_B(gwi_oper_end(gwi, ":=>", NoOp))
- const Type t_union = gwi_struct_ini(gwi, "union");
+ const Type t_union = gwi_struct_ini(gwi, "Union");
//gwi_class_xtor(gwi, NULL, UnionDtor);
gwi->gwion->type[et_union] = t_union;
const struct Op_Func opfunc1 = {.ck = opck_union_new};
CHECK_B(add_op_func_check(gwi->gwion->env, t_union, &opfunc1, 1));
- GWI_B(gwi_oper_ini(gwi, "union", (m_str)OP_ANY_TYPE, NULL))
+ GWI_B(gwi_oper_ini(gwi, "Union", (m_str)OP_ANY_TYPE, NULL))
GWI_B(gwi_oper_emi(gwi, opem_union_dot))
GWI_B(gwi_oper_end(gwi, ".", NULL))