On 04/29, Oleg Nesterov wrote:
>
> Why the environment? Because this way it is very easy to add more
> primitives using a single keyword

For example. I noticed two undocumented primitives, lowest() and highest(),
both consume a keyword.

Both look useful to me, but they do not work. This trivial program

        process = +(100) : lowest;

crashes the faust compiler (I didn't try to investigate).

While the trivial change below (on top of this patch) seems to work:

        process = +(100) <: meta.lo, meta.hi;

compiles to

        output0[i0] = FAUSTFLOAT(99.0f);
        output1[i0] = FAUSTFLOAT(101.0f);

Oleg.
---
 compiler/extended/metaprim.hh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/compiler/extended/metaprim.hh b/compiler/extended/metaprim.hh
index 20cc5982e..255fd3f0c 100644
--- a/compiler/extended/metaprim.hh
+++ b/compiler/extended/metaprim.hh
@@ -47,6 +47,11 @@ class MetaPrim : public xtended {
                case 1:
                        ret = getSigOrder(sig);
                        break;
+               case 2: case 3: {
+                       typeAnnotation(sig, false);
+                       interval i = getCertifiedSigType(sig)->getInterval();
+                       return tree(fOp == 2 ? i.lo() : i.hi());
+               }
                default:
                        faustassert(false);
                }
@@ -89,6 +94,8 @@ static Tree mkMetaEnv()
 
        defs = add_meta_def(defs, 0, "serial");
        defs = add_meta_def(defs, 1, "order");
+       defs = add_meta_def(defs, 2, "lo");
+       defs = add_meta_def(defs, 3, "hi");
 
        return boxWithLocalDef(boxEnvironment(), defs);
 }
-- 
2.39.2




_______________________________________________
Faudiostream-devel mailing list
Faudiostream-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-devel

Reply via email to