I published the version with the 'any' patch. Thanks! Le ven. 26 août 2022 à 18:05, Yann Orlarey <orla...@grame.fr> a écrit :
> Hi Oleg, > > Sounds relevant to me indeed. I am testing the patch... > > Thanks ! > > Yann > > Le ven. 26 août 2022 à 13:36, Oleg Nesterov <o...@redhat.com> a écrit : > >> Stephane, Yann, >> >> Can I suggest this patch for inclusion? >> >> With this patch you can declare ffargtype() as "any", which means it >> can accept "int" or "float" without type conversion. This can be used >> when ffunction() is actually a macro or even a compiler builtin. >> >> For example, >> >> sizeof = ffunction(int sizeof(any), "",""); >> >> process = +(1)~_ <: _,!=(0), /(2) : par(i,3, sizeof); >> >> compiled with -double outputs >> >> 4 1 8 >> >> Oleg. >> --- >> >> diff --git a/compiler/parser/faustlexer.l b/compiler/parser/faustlexer.l >> index 38b43c4df..923179765 100644 >> --- a/compiler/parser/faustlexer.l >> +++ b/compiler/parser/faustlexer.l >> @@ -142,6 +142,7 @@ TMACRO \\{ID}(\[(\ *({ID}|{NUMBER}),?\ *)\])?(\{(\ >> *({ID}|{NUMBER}),?\ *)*\})* >> >> "int" return INTCAST; >> "float" return FLOATCAST; >> +"any" return NOTYPECAST; >> >> "rdtable" return RDTBL; >> "rwtable" return RWTBL; >> diff --git a/compiler/parser/faustparser.y b/compiler/parser/faustparser.y >> index f64258b4c..31063dae8 100644 >> --- a/compiler/parser/faustparser.y >> +++ b/compiler/parser/faustparser.y >> @@ -131,6 +131,7 @@ inline Tree unquote(char* str) >> >> %token INTCAST >> %token FLOATCAST >> +%token NOTYPECAST >> %token FFUNCTION >> %token FCONSTANT >> %token FVARIABLE >> @@ -297,6 +298,7 @@ inline Tree unquote(char* str) >> %type <exp> fstring >> %type <exp> type >> %type <exp> typelist >> +%type <exp> argtype >> %type <exp> fun >> >> %type <exp> fpar >> @@ -728,8 +730,8 @@ signature : type fun LPAR typelist RPAR >> { $$ = cons($1, cons(cons >> fun : IDENT >> { $$ = tree(yytext); } >> ; >> >> -typelist : type >> { $$ = cons($1,gGlobal->nil); } >> - | typelist PAR type >> { $$ = cons($3,$1); } >> +typelist : argtype >> { $$ = cons($1,gGlobal->nil); } >> + | typelist PAR argtype { >> $$ = cons($3,$1); } >> ; >> >> rulelist : rule >> { $$ = cons($1,gGlobal->nil); } >> @@ -744,4 +746,9 @@ type : INTCAST >> { $$ = tree(0); } >> | FLOATCAST >> { $$ = tree(1); } >> ; >> >> +argtype : INTCAST { $$ = >> tree(0); } >> + | FLOATCAST >> { $$ = tree(1); } >> + | NOTYPECAST >> { $$ = tree(2); } >> + ; >> + >> %% >> diff --git a/compiler/signals/sigtype.hh b/compiler/signals/sigtype.hh >> index 6cb1fb397..43e9ba66a 100644 >> --- a/compiler/signals/sigtype.hh >> +++ b/compiler/signals/sigtype.hh >> @@ -48,7 +48,7 @@ >> //-------------------------------------------------- >> // simple types quality >> >> -enum { kInt = 0, kReal = 1 }; ///< nature : integer or floating point >> values >> +enum { kInt = 0, kReal = 1, kAny = 2 }; ///< nature : integer or >> floating point values >> enum { >> kNum = 0, >> kBool = 1 >> diff --git a/compiler/transform/sigPromotion.cpp >> b/compiler/transform/sigPromotion.cpp >> index fc4fa927d..1f1265db2 100644 >> --- a/compiler/transform/sigPromotion.cpp >> +++ b/compiler/transform/sigPromotion.cpp >> @@ -66,7 +66,8 @@ void SignalTreeChecker::visit(Tree sig) >> } else if (isSigFFun(sig, ff, args)) { >> int len = ffarity(ff) - 1; >> for (int i = 0; i < ffarity(ff); i++) { >> - if (getCertifiedSigType(nth(args, i))->nature() != >> ffargtype(ff, len - i)) { >> + int type = ffargtype(ff, len - i); >> + if (getCertifiedSigType(nth(args, i))->nature() != type && >> type != kAny) { >> cerr << "ERROR : isSigFFun of args with incoherent types >> : " << *sig << endl; >> faustassert(false); >> } >> @@ -319,6 +320,8 @@ Tree SignalPromotion::cast(int t, Tree sig) >> return sigFloatCast(sig); >> } else if (t == kInt) { >> return sigIntCast(sig); >> + } else if (t == kAny) { >> + return sig; >> } else { >> faustassert(false); >> return nullptr; >> >>
_______________________________________________ Faudiostream-devel mailing list Faudiostream-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-devel