From a00c43399e2c56384a872f94293429c9b2cee722 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 16 Sep 2020 16:53:17 +0200 Subject: [PATCH] :art: Remove useless arguments for fptr_def --- ast | 2 +- include/arg.h | 1 + src/arg.c | 3 +++ src/compile.c | 2 +- src/gwion.c | 2 ++ src/import/import_fdef.c | 2 +- src/lib/lib_func.c | 2 +- src/parse/check.c | 2 +- 8 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ast b/ast index 750eae81..6d0584e7 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 750eae810b8603f1229a93d6bbf856ce8f9f9bd7 +Subproject commit 6d0584e789c5dbee8f2fc9b8fa95781d271c738c diff --git a/include/arg.h b/include/arg.h index 7efc4f97..d092cc67 100644 --- a/include/arg.h +++ b/include/arg.h @@ -9,6 +9,7 @@ typedef struct Arg_ { struct Vector_ config; struct SoundInfo_ *si; m_bool loop; + m_bool stdin; } Arg; ANN void arg_release(Arg*); diff --git a/src/arg.c b/src/arg.c index 930c7341..46c0c1ff 100644 --- a/src/arg.c +++ b/src/arg.c @@ -117,6 +117,9 @@ ANN m_bool _arg_parse(const Gwion gwion, Arg* arg) { CHECK_OB((tmp = option_argument(ca))) arg_set_pass(gwion, tmp); break; + case '\0': + arg->stdin = 1; + break; default: gw_err(_("invalid arguments")); return GW_ERROR; diff --git a/src/compile.c b/src/compile.c index c1147955..9c1644a5 100644 --- a/src/compile.c +++ b/src/compile.c @@ -72,7 +72,7 @@ ANN static m_bool _compiler_open(struct Compiler* c) { ANN static int is_reg(const m_str path) { struct stat s; stat(path, &s); - return S_ISREG(s.st_mode); + return S_ISREG(s.st_mode) || !S_ISFIFO(s.st_mode); } #else ANN static m_bool is_reg(const m_str path) { diff --git a/src/gwion.c b/src/gwion.c index df4abb90..07b221e3 100644 --- a/src/gwion.c +++ b/src/gwion.c @@ -79,6 +79,8 @@ ANN static m_bool gwion_ok(const Gwion gwion, Arg* arg) { if(gwion_engine(gwion)) { gwion_cleaner(gwion); gwion_compile(gwion, &arg->add); + if(arg->stdin) + compile_file(gwion, "stdin", stdin); return GW_OK; } } diff --git a/src/import/import_fdef.c b/src/import/import_fdef.c index a73db3b6..d9ab14e1 100644 --- a/src/import/import_fdef.c +++ b/src/import/import_fdef.c @@ -108,7 +108,7 @@ ANN m_int gwi_fptr_ini(const Gwi gwi, const restrict m_str type, const restrict 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); + return new_fptr_def(gwi->gwion->mp, base); } ANN Type gwi_fptr_end(const Gwi gwi, const ae_flag flag) { diff --git a/src/lib/lib_func.c b/src/lib/lib_func.c index 40e24f1a..53410ab7 100644 --- a/src/lib/lib_func.c +++ b/src/lib/lib_func.c @@ -200,7 +200,7 @@ static OP_CHECK(opck_auto_fptr) { // create a matching signature // TODO: we could check first if there a matching existing one Func_Base *const fbase = cpy_func_base(env->gwion->mp, bin->lhs->info->type->e->d.func->def->base); - const Fptr_Def fptr_def = new_fptr_def(env->gwion->mp, fbase, bin->lhs->info->type->e->d.func->def->base->flag); + const Fptr_Def fptr_def = new_fptr_def(env->gwion->mp, fbase); char name[13 + strlen(env->curr->name) + num_digit(bin->rhs->pos->first.line) + num_digit(bin->rhs->pos->first.column)]; sprintf(name, "generated@%s@%u:%u", env->curr->name, bin->rhs->pos->first.line, bin->rhs->pos->first.column); diff --git a/src/parse/check.c b/src/parse/check.c index 8c1b5562..fbcb8bd1 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -565,7 +565,7 @@ ANN static Func _find_template_match(const Env env, const Value v, const Exp_Cal fbase->tmpl->base = 0; fbase->tmpl->call = cpy_type_list(env->gwion->mp, types); if(template_push_types(env, fbase->tmpl) > 0) { - const Fptr_Def fptr = new_fptr_def(env->gwion->mp, fbase, base->base->flag); + const Fptr_Def fptr = new_fptr_def(env->gwion->mp, fbase); if(traverse_fptr_def(env, fptr) > 0 && (base->base->ret_type = known_type(env, base->base->td)) && (!exp->args || !!check_exp(env, exp->args))) { -- 2.43.0