From: fennecdjay Date: Tue, 9 Jul 2019 17:01:45 +0000 (+0200) Subject: :art: More fixes and tests X-Git-Tag: nightly~2348^2~15 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=6b5edd67af9eac6749e66ce4bfc7b9223040d69a;p=gwion.git :art: More fixes and tests --- diff --git a/src/arg.gcda b/src/arg.gcda index 3dcc1be1..bf449aee 100644 Binary files a/src/arg.gcda and b/src/arg.gcda differ diff --git a/src/arg.gcno b/src/arg.gcno index 4b9a987e..38f07084 100644 Binary files a/src/arg.gcno and b/src/arg.gcno differ diff --git a/src/compile.gcda b/src/compile.gcda index d7311546..6b4cdd62 100644 Binary files a/src/compile.gcda and b/src/compile.gcda differ diff --git a/src/compile.gcno b/src/compile.gcno index 411f8355..d69f6e16 100644 Binary files a/src/compile.gcno and b/src/compile.gcno differ diff --git a/src/gwion.gcda b/src/gwion.gcda index d0363d62..1a44e2f8 100644 Binary files a/src/gwion.gcda and b/src/gwion.gcda differ diff --git a/src/gwion.gcno b/src/gwion.gcno index 6c8e11e1..db0a66d4 100644 Binary files a/src/gwion.gcno and b/src/gwion.gcno differ diff --git a/src/gwiondata.gcda b/src/gwiondata.gcda index 8a977517..74199b69 100644 Binary files a/src/gwiondata.gcda and b/src/gwiondata.gcda differ diff --git a/src/gwiondata.gcno b/src/gwiondata.gcno index 5f90c6e3..83192df2 100644 Binary files a/src/gwiondata.gcno and b/src/gwiondata.gcno differ diff --git a/src/lib/func.c b/src/lib/func.c index 4d8cc62b..657d336d 100644 --- a/src/lib/func.c +++ b/src/lib/func.c @@ -67,20 +67,20 @@ struct FptrInfo { ANN static m_bool fptr_tmpl_push(const Env env, struct FptrInfo *info) { if(!info->rhs->def->base->tmpl) return GW_OK; -// some kind of template_match ? ID_List t0 = info->lhs->def->base->tmpl->list, t1 = info->rhs->def->base->tmpl->list; -nspc_push_type(env->gwion->mp, env->curr); + nspc_push_type(env->gwion->mp, env->curr); while(t0) { -// CHECK_OB(t1) -nspc_add_type(env->curr, t0->xid, t_undefined);// -nspc_add_type(env->curr, t1->xid, t_undefined);// + if(!t1) { + nspc_pop_type(env->gwion->mp, env->curr); + return GW_ERROR; + } + nspc_add_type(env->curr, t0->xid, t_undefined); + nspc_add_type(env->curr, t1->xid, t_undefined); t0 = t0->next; t1 = t1->next; } -// CHECK_BB(template_push_types(env, info->lhs->def->base->tmpl)) -// return template_push_types(env, info->rhs->def->base->tmpl); -return GW_OK;// + return GW_OK; } @@ -146,10 +146,8 @@ ANN static Type fptr_type(const Env env, struct FptrInfo *info) { if(fptr_rettype(env, info) > 0 && fptr_arity(info) && fptr_args(env, base) > 0) type = info->lhs->value_ref->type; - if(info->rhs->def->base->tmpl) { -// nspc_pop_type(env->gwion->mp, env->curr); + if(info->rhs->def->base->tmpl) nspc_pop_type(env->gwion->mp, env->curr); - } } } return type; diff --git a/src/main.gcda b/src/main.gcda index 1bd518d8..5fce5e27 100644 Binary files a/src/main.gcda and b/src/main.gcda differ diff --git a/src/main.gcno b/src/main.gcno index 6293d574..d737dff5 100644 Binary files a/src/main.gcno and b/src/main.gcno differ diff --git a/src/parse/check.c b/src/parse/check.c index a3e565eb..f20143ab 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -367,9 +367,7 @@ ANN2(1,2) static Func find_func_match_actual(const Env env, Func func, const Exp CHECK_OO(func->next); return find_func_match_actual(env, func->next, args, implicit, specific); } - if(e1->type == t_undefined || -(GET_FLAG(func, template) && isa(actual_type(func->value_ref->type), t_fptr) > 0) -) { + if(e1->type == t_undefined || (GET_FLAG(func, template) && is_fptr(func->value_ref->type))) { if(func->value_ref->owner_class) CHECK_BO(template_push_types(env, func->value_ref->owner_class->e->def->base.tmpl)) e1->type = known_type(env, e1->td); @@ -381,7 +379,6 @@ ANN2(1,2) static Func find_func_match_actual(const Env env, Func func, const Exp e = e->next; e1 = e1->next; } -printf("end %p %p\n", e1, func); if(!e1) return func; } while((func = func->next)); @@ -469,11 +466,10 @@ ANN static Func _find_template_match(const Env env, const Value v, const Exp_Cal m_func = find_func_match(env, fbase->func, exp->args); nspc_pop_type(env->gwion->mp, env->curr); if(!value && m_func) { -printf("m_func %p\n", m_func); -if(!m_func->def->base->ret_type) -CHECK_BO(traverse_func_def(env, m_func->def)) + if(!m_func->def->base->ret_type) + CHECK_BO(traverse_func_def(env, m_func->def)) map_set(&v->owner->info->type->map, (vtype)sym, (vtype)actual_type(m_func->value_ref->type)); -} + } } free_stmt(env->gwion->mp, stmt); } @@ -587,15 +583,11 @@ ANN static Type check_exp_call_template(const Env env, const Exp_Call *exp) { const Exp call = exp->func; const Exp args = exp->args; m_uint args_number = 0; -puts("here =="); DECL_OO(const Value, value, = nspc_lookup_value1(call->type->e->owner, insert_symbol(call->type->name))) -puts("after here =="); const m_uint type_number = get_type_number(value->d.func_ref->def->base->tmpl->list); -printf("%s func\n", __func__) ; Type_List tl[type_number]; ID_List list = value->d.func_ref->def->base->tmpl->list; while(list) { -printf("%s func\n", __func__) ; Arg_List arg = value->d.func_ref->def->base->args; Exp template_arg = args; while(arg && template_arg) { @@ -620,7 +612,7 @@ printf("%s func\n", __func__) ; DECL_OO(const Func,func, = get_template_func(env, exp, value)) if(!func->def->base->ret_type) // template fptr CHECK_BO(traverse_func_def(env, func->def)) - return func->def->base->ret_type; + return func->def->base->ret_type; } ANN static m_bool check_exp_call1_check(const Env env, const Exp exp) { @@ -715,11 +707,7 @@ ANN static Type check_exp_call(const Env env, Exp_Call* exp) { CHECK_OO((exp->m_func = ret)) return ret->def->base->ret_type; } - - const Type t = check_exp_call1(env, exp); -printf("here exp_call %p\n", t); -return t; -// return check_exp_call1(env, exp); + return check_exp_call1(env, exp); } ANN static Type check_exp_unary(const Env env, const Exp_Unary* unary) { diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 2856ea9e..ded15f44 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -245,8 +245,8 @@ ANN static m_bool scan1_args(const Env env, Arg_List list) { ANN m_bool scan1_stmt_fptr(const Env env, const Stmt_Fptr stmt) { if(!stmt->type) CHECK_BB(scan0_stmt_fptr(env, stmt)) - if(stmt->base->tmpl)// - return GW_OK;// + if(stmt->base->tmpl) + return GW_OK; CHECK_OB((stmt->base->ret_type = known_type(env, stmt->base->td))) return stmt->base->args ? scan1_args(env, stmt->base->args) : GW_OK; } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 2d0af075..5b5fa989 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -93,8 +93,7 @@ ANN m_bool scan2_stmt_fptr(const Env env, const Stmt_Fptr ptr) { ptr->type->e->d.func = ptr->base->func; def->base->tmpl = ptr->base->tmpl; SET_FLAG(ptr->value, func | ae_flag_checked); -if(!ptr->base->tmpl)// - if(ptr->base->args) + if(!ptr->base->tmpl && ptr->base->args) CHECK_BB(scan2_args(env, def)) if(env->class_def) { if(GET_FLAG(ptr->base->td, global)) { diff --git a/src/plug.gcda b/src/plug.gcda index aa78ce69..8b664567 100644 Binary files a/src/plug.gcda and b/src/plug.gcda differ diff --git a/src/plug.gcno b/src/plug.gcno index de8f8a67..dc419866 100644 Binary files a/src/plug.gcno and b/src/plug.gcno differ diff --git a/src/soundinfo.gcda b/src/soundinfo.gcda index 66d3f7d2..ade055bc 100644 Binary files a/src/soundinfo.gcda and b/src/soundinfo.gcda differ diff --git a/src/soundinfo.gcno b/src/soundinfo.gcno index 6c38817e..56f21448 100644 Binary files a/src/soundinfo.gcno and b/src/soundinfo.gcno differ diff --git a/tests/import/driver.so b/tests/import/driver.so deleted file mode 100755 index f286bf3b..00000000 Binary files a/tests/import/driver.so and /dev/null differ diff --git a/tests/import/test.log b/tests/import/test.log index b584940e..8557b3a4 100644 --- a/tests/import/test.log +++ b/tests/import/test.log @@ -11398,3 +11398,45 @@ global_func.gw ==22565== Memcheck, a memory error detector ==4349== ==4349== For counts of detected and suppressed errors, rerun with: -v ==4349== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) +/dev/null ==13821== Memcheck, a memory error detector +==13821== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. +==13821== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info +==13821== Command: ./../../gwion -p. -d dummy /dev/null +==13821== Parent PID: 13795 +==13821== +==13821== +==13821== HEAP SUMMARY: +==13821== in use at exit: 928 bytes in 10 blocks +==13821== total heap usage: 974 allocs, 964 frees, 7,596,796 bytes allocated +==13821== +==13821== LEAK SUMMARY: +==13821== definitely lost: 928 bytes in 10 blocks +==13821== indirectly lost: 0 bytes in 0 blocks +==13821== possibly lost: 0 bytes in 0 blocks +==13821== still reachable: 0 bytes in 0 blocks +==13821== suppressed: 0 bytes in 0 blocks +==13821== Rerun with --leak-check=full to see details of leaked memory +==13821== +==13821== For counts of detected and suppressed errors, rerun with: -v +==13821== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) +/dev/null ==14729== Memcheck, a memory error detector +==14729== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. +==14729== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info +==14729== Command: ./../../gwion -p. -d dummy /dev/null +==14729== Parent PID: 13795 +==14729== +==14729== +==14729== HEAP SUMMARY: +==14729== in use at exit: 576 bytes in 9 blocks +==14729== total heap usage: 956 allocs, 947 frees, 7,590,612 bytes allocated +==14729== +==14729== LEAK SUMMARY: +==14729== definitely lost: 576 bytes in 9 blocks +==14729== indirectly lost: 0 bytes in 0 blocks +==14729== possibly lost: 0 bytes in 0 blocks +==14729== still reachable: 0 bytes in 0 blocks +==14729== suppressed: 0 bytes in 0 blocks +==14729== Rerun with --leak-check=full to see details of leaked memory +==14729== +==14729== For counts of detected and suppressed errors, rerun with: -v +==14729== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) diff --git a/tests/tree/array_cast.gw b/tests/tree/array_cast.gw new file mode 100644 index 00000000..1b7c437c --- /dev/null +++ b/tests/tree/array_cast.gw @@ -0,0 +1,2 @@ +typedef int[2] _int; +new _int $ _int; diff --git a/tests/tree/did_you_mean_type.gw b/tests/tree/did_you_mean_type.gw new file mode 100644 index 00000000..73b04597 --- /dev/null +++ b/tests/tree/did_you_mean_type.gw @@ -0,0 +1,4 @@ +class C { + <<>>; + int a; +} diff --git a/tests/tree/push_func.gw b/tests/tree/push_func.gw new file mode 100644 index 00000000..2f7957f6 --- /dev/null +++ b/tests/tree/push_func.gw @@ -0,0 +1 @@ +me.exit; diff --git a/tests/tree/reddit.gw b/tests/tree/reddit.gw new file mode 100644 index 00000000..9b4fd259 --- /dev/null +++ b/tests/tree/reddit.gw @@ -0,0 +1,8 @@ + +#! basic math printed out (note the space after '<<<' and before '>>>' +<<< 1 + 2 >>>; + +#! define and operator +operator $@+-*%~<>^&!= void (int i, int j) { <<< i, " ", j >>>; } + +1 $@+-*%~<>^&!= 2; diff --git a/tests/tree/template_fptr.gw b/tests/tree/template_fptr.gw new file mode 100644 index 00000000..3a130d9f --- /dev/null +++ b/tests/tree/template_fptr.gw @@ -0,0 +1,11 @@ +typedef int ptr_t<~A~>(A); +ptr_t ptr; +<<>>; + +fun int test<~A~>(A a) { <<< a >>>; } +test @=> ptr; +<<< ptr >>>; +#!3; +#!3 => test; +ptr<~int~>(2); +ptr<~float~>(2.3);