示例#1
0
文件: boxes.cpp 项目: Ace17/faust
Tree buildBoxAppl(Tree fun, Tree revarglist)
{
  if(isNil(revarglist))
    exit(1); // a revoir !!!!!!

  return boxAppl(fun, revarglist);
}
示例#2
0
文件: boxes.cpp 项目: EBone/Faust
Tree buildBoxAppl 	(Tree fun, Tree revarglist)
{
	if (isNil (revarglist)) {
        // a revoir !!!!!!
        throw faustexception("ERROR : buildBoxAppl called with null revarglist\n");
    }
	return  boxAppl(fun, revarglist);
}
示例#3
0
文件: boxes.cpp 项目: EBone/Faust
Tree buildBoxAppl 	(Tree fun, Tree revarglist)
{
	if (isNil(revarglist)) {
		return fun;
	} else {
		return  boxAppl(buildBoxAppl(fun, tl(revarglist)), hd(revarglist));
	}
}
示例#4
0
文件: boxes.cpp 项目: Ace17/faust
/**
 * Prepare a "pattern" by replacing variables x by special
 * pattern variables ?x.
 *
 * P[x]     -> ?x
 * P[x(e)]  -> x(P[e])
 * P[e(f)]  -> P[e](P[f])
 * P[e:f]   -> P[e]:P[f]
 * etc.
 */
static Tree preparePattern(Tree box)
{
// cerr << "preparePattern(" << boxpp(box) << ")" << endl;

  int id;
  double r;
  prim0 p0;
  prim1 p1;
  prim2 p2;
  prim3 p3;
  prim4 p4;
  prim5 p5;

  Tree t1, t2, t3, ff, label, cur, min, max, step, type, name, file, arg,
       body, fun, args, ldef, slot,
       ident, rules;

  xtended* xt = (xtended*)getUserData(box);

  // primitive elements
  if(xt)
    return box;
  else if(isBoxIdent(box))
    return boxPatternVar(box);
  else if(isBoxAppl(box, fun, args))
  {
    if(isBoxIdent(fun))
      return boxAppl(fun, lmap(preparePattern, args));
    else
      return boxAppl(preparePattern(fun), lmap(preparePattern, args));
  }
  else if(isBoxAbstr(box, arg, body))
    return box;
  else if(isBoxInt(box))
    return box;
  else if(isBoxReal(box, &r))
    return box;
  else if(isBoxWaveform(box))
    return box;
  else if(isBoxCut(box))
    return box;
  else if(isBoxWire(box))
    return box;
  else if(isBoxPrim0(box, &p0))
    return box;
  else if(isBoxPrim1(box, &p1))
    return box;
  else if(isBoxPrim2(box, &p2))
    return box;
  else if(isBoxPrim3(box, &p3))
    return box;
  else if(isBoxPrim4(box, &p4))
    return box;
  else if(isBoxPrim5(box, &p5))
    return box;

  else if(isBoxWithLocalDef(box, body, ldef))
    return boxWithLocalDef(preparePattern(body), ldef);

  // foreign elements
  else if(isBoxFFun(box, ff))
    return box;
  else if(isBoxFConst(box, type, name, file))
    return box;
  else if(isBoxFVar(box, type, name, file))
    return box;

  // block diagram binary operator
  else if(isBoxSeq(box, t1, t2))
    return boxSeq(preparePattern(t1), preparePattern(t2));
  else if(isBoxSplit(box, t1, t2))
    return boxSplit(preparePattern(t1), preparePattern(t2));
  else if(isBoxMerge(box, t1, t2))
    return boxMerge(preparePattern(t1), preparePattern(t2));
  else if(isBoxPar(box, t1, t2))
    return boxPar(preparePattern(t1), preparePattern(t2));
  else if(isBoxRec(box, t1, t2))
    return boxRec(preparePattern(t1), preparePattern(t2));

  // iterative block diagram construction
  else if(isBoxIPar(box, t1, t2, t3))
    return boxIPar(t1, t2, preparePattern(t3));
  else if(isBoxISeq(box, t1, t2, t3))
    return boxISeq(t1, t2, preparePattern(t3));
  else if(isBoxISum(box, t1, t2, t3))
    return boxISum(t1, t2, preparePattern(t3));
  else if(isBoxIProd(box, t1, t2, t3))
    return boxIProd(t1, t2, preparePattern(t3));

  // static information
  else if(isBoxInputs(box, t1))
    return boxInputs(preparePattern(t1));
  else if(isBoxOutputs(box, t1))
    return boxOutputs(preparePattern(t1));

  // user interface
  else if(isBoxButton(box, label))
    return box;
  else if(isBoxCheckbox(box, label))
    return box;

  else if(isBoxVSlider(box, label, cur, min, max, step))
    return box;
  else if(isBoxHSlider(box, label, cur, min, max, step))
    return box;

  else if(isBoxVGroup(box, label, t1))
    return boxVGroup(label, preparePattern(t1));
  else if(isBoxHGroup(box, label, t1))
    return boxHGroup(label, preparePattern(t1));
  else if(isBoxTGroup(box, label, t1))
    return boxTGroup(label, preparePattern(t1));

  else if(isBoxHBargraph(box, label, min, max))
    return box;
  else if(isBoxVBargraph(box, label, min, max))
    return box;
  else if(isBoxNumEntry(box, label, cur, min, max, step))
    return box;

  else if(isNil(box))
    return box;
  else if(isList(box))
    return lmap(preparePattern, box);
  else if(isBoxEnvironment(box))
    return box;
  /* not expected
     else if (isClosure(box, abstr, genv, vis, lenv)) {
      fout << "closure[" << boxpp(abstr)
          << ", genv = " << envpp(genv)
          << ", lenv = " << envpp(lenv)
          << "]";
     }
   */
  else if(isBoxComponent(box, label))
    return box;
  else if(isBoxAccess(box, t1, t2))
    return box;

  /* not expected
     else if (isImportFile(box, label)) {
      fout << "import("
          << tree2str(label) << ')';
     }
   */

  else if(isBoxSlot(box, &id))
    return box;
  else if(isBoxSymbolic(box, slot, body))
    return box;

  // Pattern Matching Extensions
  else if(isBoxCase(box, rules))
    return box;
  else if(isBoxPatternVar(box, ident))
    return box;

  // None of the previous tests succeded, then it is not a valid box
  else
  {
    cerr << "Error in preparePattern() : " << *box << " is not a valid box" << endl;
    exit(1);
  }

  return box;
}