/[svn]/linuxsampler/trunk/src/scriptvm/tree.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/tree.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3576 by schoenebeck, Wed Aug 28 12:56:38 2019 UTC revision 3581 by schoenebeck, Fri Aug 30 11:40:25 2019 UTC
# Line 59  public: Line 59  public:
59  typedef Ref<Expression,Node> ExpressionRef;  typedef Ref<Expression,Node> ExpressionRef;
60    
61  class Unit : virtual public VMUnit, virtual public Node {  class Unit : virtual public VMUnit, virtual public Node {
     ArrayList<MetricPrefix_t> prefix;  
62      StdUnit_t unit;      StdUnit_t unit;
63  public:  public:
64      Unit() : unit(VM_NO_UNIT) {}      Unit(StdUnit_t type) : unit(type) {}
     MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE;  
65      StdUnit_t unitType() const OVERRIDE { return unit; }      StdUnit_t unitType() const OVERRIDE { return unit; }
66      void setUnit(const std::vector<MetricPrefix_t>& prefix, StdUnit_t type);      static vmint convIntToUnitFactor(vmint iValue, VMUnit* srcUnit, VMUnit* dstUnit);
67      void setUnit(const MetricPrefix_t* prefixes, StdUnit_t type);      static vmint convIntToUnitFactor(vmint iValue, vmfloat srcFactor, vmfloat dstFactor);
68      void copyUnitFrom(const Ref<Unit,Node>& src);      static vmfloat convRealToUnitFactor(vmfloat fValue, VMUnit* srcUnit, VMUnit* dstUnit);
69        static vmfloat convRealToUnitFactor(vmfloat fValue, vmfloat srcFactor, vmfloat dstFactor);
70  };  };
71  typedef Ref<Unit,Node> UnitRef;  typedef Ref<Unit,Node> UnitRef;
72    
# Line 79  typedef Ref<ScalarNumberExpr,Node> Scala Line 78  typedef Ref<ScalarNumberExpr,Node> Scala
78  class IntExpr : virtual public ScalarNumberExpr, virtual public VMIntExpr {  class IntExpr : virtual public ScalarNumberExpr, virtual public VMIntExpr {
79  public:  public:
80      ExprType_t exprType() const OVERRIDE { return INT_EXPR; }      ExprType_t exprType() const OVERRIDE { return INT_EXPR; }
81        vmint evalIntToUnitFactor(vmfloat unitFactor);
82      String evalCastToStr() OVERRIDE;      String evalCastToStr() OVERRIDE;
83  };  };
84  typedef Ref<IntExpr,Node> IntExprRef;  typedef Ref<IntExpr,Node> IntExprRef;
# Line 86  typedef Ref<IntExpr,Node> IntExprRef; Line 86  typedef Ref<IntExpr,Node> IntExprRef;
86  class RealExpr : virtual public ScalarNumberExpr, virtual public VMRealExpr  {  class RealExpr : virtual public ScalarNumberExpr, virtual public VMRealExpr  {
87  public:  public:
88      ExprType_t exprType() const OVERRIDE { return REAL_EXPR; }      ExprType_t exprType() const OVERRIDE { return REAL_EXPR; }
89        vmfloat evalRealToUnitFactor(vmfloat unitFactor);
90      String evalCastToStr() OVERRIDE;      String evalCastToStr() OVERRIDE;
91  };  };
92  typedef Ref<RealExpr,Node> RealExprRef;  typedef Ref<RealExpr,Node> RealExprRef;
# Line 116  public: Line 117  public:
117  };  };
118  typedef Ref<StringExpr,Node> StringExprRef;  typedef Ref<StringExpr,Node> StringExprRef;
119    
120    struct IntLitDef {
121        vmint value; //NOTE: sequence matters! Since this is usually initialized with VMIntExpr::evalInt() it should be before member unitFactor, since the latter is usually initialized with VMIntExpr::unitFactor() which does not evaluate the expression.
122        vmfloat unitFactor = VM_NO_FACTOR;
123        StdUnit_t unitType = VM_NO_UNIT;
124        bool isFinal;
125    };
126    
127  class IntLiteral FINAL : public IntExpr {  class IntLiteral FINAL : public IntExpr {
128      bool finalVal;      bool finalVal;
129  public:      vmfloat unitPrefixFactor;
130      vmint value;      vmint value;
131      IntLiteral(vmint value) : IntExpr(),  public:
132          value(value), finalVal(false) { }      IntLiteral(const IntLitDef& def);
133      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
134        vmfloat unitFactor() const OVERRIDE { return unitPrefixFactor; }
135      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
136      bool isConstExpr() const OVERRIDE { return true; }      bool isConstExpr() const OVERRIDE { return true; }
137      bool isPolyphonic() const OVERRIDE { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
138      bool isFinal() const OVERRIDE { return finalVal; }      bool isFinal() const OVERRIDE { return finalVal; }
     void setFinal(bool b = true) { finalVal = b; }  
139  };  };
140  typedef Ref<IntLiteral,Node> IntLiteralRef;  typedef Ref<IntLiteral,Node> IntLiteralRef;
141    
142    struct RealLitDef {
143        vmfloat value; //NOTE: sequence matters! Since this is usually initialized with VMRealExpr::evalReal() it should be before member unitFactor, since the latter is usually initialized with VMRealExpr::unitFactor() which does not evaluate the expression.
144        vmfloat unitFactor = VM_NO_FACTOR;
145        StdUnit_t unitType = VM_NO_UNIT;
146        bool isFinal;
147    };
148    
149  class RealLiteral FINAL : public RealExpr {  class RealLiteral FINAL : public RealExpr {
150      bool finalVal;      bool finalVal;
151  public:      vmfloat unitPrefixFactor;
152      vmfloat value;      vmfloat value;
153      RealLiteral(vmfloat value) : RealExpr(),  public:
154          value(value), finalVal(false) { }      RealLiteral(const RealLitDef& def);
155      vmfloat evalReal() OVERRIDE;      vmfloat evalReal() OVERRIDE;
156        vmfloat unitFactor() const OVERRIDE { return unitPrefixFactor; }
157      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
158      bool isConstExpr() const OVERRIDE { return true; }      bool isConstExpr() const OVERRIDE { return true; }
159      bool isPolyphonic() const OVERRIDE { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
160      bool isFinal() const OVERRIDE { return finalVal; }      bool isFinal() const OVERRIDE { return finalVal; }
     void setFinal(bool b = true) { finalVal = b; }  
161  };  };
162  typedef Ref<RealLiteral,Node> RealLiteralRef;  typedef Ref<RealLiteral,Node> RealLiteralRef;
163    
164  class StringLiteral FINAL : public StringExpr {  class StringLiteral FINAL : public StringExpr {
 public:  
165      String value;      String value;
166    public:
167      StringLiteral(const String& value) : value(value) { }      StringLiteral(const String& value) : value(value) { }
168      bool isConstExpr() const OVERRIDE { return true; }      bool isConstExpr() const OVERRIDE { return true; }
169      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
# Line 168  public: Line 183  public:
183  };  };
184  typedef Ref<Args,Node> ArgsRef;  typedef Ref<Args,Node> ArgsRef;
185    
186    struct VariableDecl {
187        ParserContext* ctx;
188        bool isPolyphonic;
189        bool isConst;
190        bool isFinal;
191        vmint elements = 1;
192        vmint memPos;
193        vmint unitFactorMemPos;
194        StdUnit_t unitType = VM_NO_UNIT;
195    };
196    
197  class Variable : virtual public VMVariable, virtual public Expression {  class Variable : virtual public VMVariable, virtual public Expression {
198  public:  public:
199      bool isConstExpr() const OVERRIDE { return bConst; }      bool isConstExpr() const OVERRIDE { return bConst; }
# Line 175  public: Line 201  public:
201      virtual void assign(Expression* expr) = 0;      virtual void assign(Expression* expr) = 0;
202      void assignExpr(VMExpr* expr) OVERRIDE { Expression* e = dynamic_cast<Expression*>(expr); if (e) assign(e); }      void assignExpr(VMExpr* expr) OVERRIDE { Expression* e = dynamic_cast<Expression*>(expr); if (e) assign(e); }
203  protected:  protected:
204      Variable(ParserContext* ctx, vmint _memPos, bool _bConst)      Variable(const VariableDecl& decl);
         : context(ctx), memPos(_memPos), bConst(_bConst) {}  
205    
206      ParserContext* context;      ParserContext* context;
207      vmint memPos;      vmint memPos;
# Line 187  typedef Ref<Variable,Node> VariableRef; Line 212  typedef Ref<Variable,Node> VariableRef;
212  class ScalarNumberVariable : public Variable, virtual public ScalarNumberExpr {  class ScalarNumberVariable : public Variable, virtual public ScalarNumberExpr {
213      bool polyphonic;      bool polyphonic;
214      bool finalVal;      bool finalVal;
215    protected:
216        vmint unitFactorMemPos;
217  public:  public:
218      bool isPolyphonic() const OVERRIDE { return polyphonic; }      bool isPolyphonic() const OVERRIDE { return polyphonic; }
219      bool isFinal() const OVERRIDE { return finalVal; }      bool isFinal() const OVERRIDE { return finalVal; }
220      void setFinal(bool b = true) { finalVal = b; }      vmfloat unitFactor() const OVERRIDE;
221  protected:  protected:
222      ScalarNumberVariable(ParserContext* ctx, vmint _memPos,      ScalarNumberVariable(const VariableDecl& decl);
                          bool _bConst = false, bool _bPolyphonic = false,  
                          bool _bFinal = false);  
223  };  };
224  typedef Ref<ScalarNumberVariable,Node> ScalarNumberVariableRef;  typedef Ref<ScalarNumberVariable,Node> ScalarNumberVariableRef;
225    
226  class IntVariable : public ScalarNumberVariable, virtual public IntExpr {  class IntVariable : public ScalarNumberVariable, virtual public IntExpr {
227  public:  public:
228      IntVariable(ParserContext* ctx);      IntVariable(const VariableDecl& decl);
229      void assign(Expression* expr) OVERRIDE;      void assign(Expression* expr) OVERRIDE;
230      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
231      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
 protected:  
     IntVariable(ParserContext* ctx, bool polyphonic, bool bConst, vmint size = 1);  
232  };  };
233  typedef Ref<IntVariable,Node> IntVariableRef;  typedef Ref<IntVariable,Node> IntVariableRef;
234    
235  class RealVariable : public ScalarNumberVariable, virtual public RealExpr {  class RealVariable : public ScalarNumberVariable, virtual public RealExpr {
236  public:  public:
237      RealVariable(ParserContext* ctx);      RealVariable(const VariableDecl& decl);
238      void assign(Expression* expr) OVERRIDE;      void assign(Expression* expr) OVERRIDE;
239      vmfloat evalReal() OVERRIDE;      vmfloat evalReal() OVERRIDE;
240      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
 protected:  
     RealVariable(ParserContext* ctx, bool polyphonic, bool bConst, vmint size = 1);  
241  };  };
242  typedef Ref<RealVariable,Node> RealVariableRef;  typedef Ref<RealVariable,Node> RealVariableRef;
243    
244    struct IntVarDef /* : VariableDecl*/ { //NOTE: derived, aggregate initializer-lists requires C++17
245        // copied from VariableDecl
246        ParserContext* ctx;
247        bool isPolyphonic;
248        bool isConst;
249        bool isFinal;
250        vmint elements = 1;
251        vmint memPos;
252        vmint unitFactorMemPos;
253        StdUnit_t unitType = VM_NO_UNIT;
254        // additions for RealVarDef
255        vmint value = 0; //NOTE: sequence matters! Since this is usually initialized with VMIntExpr::evalInt() it should be before member unitFactor, since the latter is usually initialized with VMIntExpr::unitFactor() which does not evaluate the expression.
256        vmfloat unitFactor = VM_NO_FACTOR;
257    };
258    
259  class ConstIntVariable FINAL : public IntVariable {  class ConstIntVariable FINAL : public IntVariable {
260  public:      vmfloat unitPrefixFactor;
261      vmint value;      vmint value;
262    public:
263      ConstIntVariable(vmint value);      ConstIntVariable(const IntVarDef& def);
264      void assign(Expression* expr) OVERRIDE;      void assign(Expression* expr) OVERRIDE;
265      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
266        vmfloat unitFactor() const OVERRIDE { return unitPrefixFactor; }
267      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
268  };  };
269  typedef Ref<ConstIntVariable,Node> ConstIntVariableRef;  typedef Ref<ConstIntVariable,Node> ConstIntVariableRef;
270    
271    struct RealVarDef /* : VariableDecl*/ { //NOTE: derived, aggregate initializer-lists requires C++17
272        // copied from VariableDecl
273        ParserContext* ctx;
274        bool isPolyphonic;
275        bool isConst;
276        bool isFinal;
277        vmint elements = 1;
278        vmint memPos;
279        vmint unitFactorMemPos;
280        StdUnit_t unitType = VM_NO_UNIT;
281        // additions for RealVarDef
282        vmfloat value = vmfloat(0); //NOTE: sequence matters! Since this is usually initialized with VMRealExpr::evalReal() it should be before member unitFactor, since the latter is usually initialized with VMRealExpr::unitFactor() which does not evaluate the expression.
283        vmfloat unitFactor = VM_NO_FACTOR;
284    };
285    
286  class ConstRealVariable FINAL : public RealVariable {  class ConstRealVariable FINAL : public RealVariable {
287  public:      vmfloat unitPrefixFactor;
288      vmfloat value;      vmfloat value;
289    public:
290      ConstRealVariable(vmfloat value);      ConstRealVariable(const RealVarDef& def);
291      void assign(Expression* expr) OVERRIDE;      void assign(Expression* expr) OVERRIDE;
292      vmfloat evalReal() OVERRIDE;      vmfloat evalReal() OVERRIDE;
293        vmfloat unitFactor() const OVERRIDE { return unitPrefixFactor; }
294      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
295  };  };
296  typedef Ref<ConstRealVariable,Node> ConstRealVariableRef;  typedef Ref<ConstRealVariable,Node> ConstRealVariableRef;
# Line 250  public: Line 303  public:
303      bool isAssignable() const OVERRIDE { return ptr->isAssignable(); }      bool isAssignable() const OVERRIDE { return ptr->isAssignable(); }
304      void assign(Expression* expr) OVERRIDE;      void assign(Expression* expr) OVERRIDE;
305      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
306        vmfloat unitFactor() const OVERRIDE { return VM_NO_UNIT; }
307      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
308  };  };
309  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;
310    
311  class PolyphonicIntVariable FINAL : public IntVariable {  class PolyphonicIntVariable FINAL : public IntVariable {
312  public:  public:
313      PolyphonicIntVariable(ParserContext* ctx);      PolyphonicIntVariable(const VariableDecl& decl);
314      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
315  };  };
316  typedef Ref<PolyphonicIntVariable,Node> PolyphonicIntVariableRef;  typedef Ref<PolyphonicIntVariable,Node> PolyphonicIntVariableRef;
317    
318  class PolyphonicRealVariable FINAL : public RealVariable {  class PolyphonicRealVariable FINAL : public RealVariable {
319  public:  public:
320      PolyphonicRealVariable(ParserContext* ctx);      PolyphonicRealVariable(const VariableDecl& decl);
321      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
322  };  };
323  typedef Ref<PolyphonicRealVariable,Node> PolyphonicRealVariableRef;  typedef Ref<PolyphonicRealVariable,Node> PolyphonicRealVariableRef;
324    
325  class IntArrayVariable : public Variable, virtual public IntArrayExpr {  class IntArrayVariable : public Variable, virtual public IntArrayExpr {
326      ArrayList<vmint> values;      ArrayList<vmint> values;
327        ArrayList<vmfloat> unitFactors;
328  public:  public:
329      IntArrayVariable(ParserContext* ctx, vmint size);      IntArrayVariable(ParserContext* ctx, vmint size);
330      IntArrayVariable(ParserContext* ctx, vmint size, ArgsRef values, bool _bConst = false);      IntArrayVariable(ParserContext* ctx, vmint size, ArgsRef values, bool _bConst = false);
331      void assign(Expression* expr) OVERRIDE {} // ignore scalar assignment      void assign(Expression* expr) OVERRIDE {} // ignore scalar assignment
     String evalCastToStr() OVERRIDE { return ""; } // ignore scalar cast to string  
332      ExprType_t exprType() const OVERRIDE { return INT_ARR_EXPR; }      ExprType_t exprType() const OVERRIDE { return INT_ARR_EXPR; }
333      virtual vmint arraySize() const OVERRIDE { return values.size(); }      virtual vmint arraySize() const OVERRIDE { return values.size(); }
334      virtual vmint evalIntElement(vmuint i) OVERRIDE;      virtual vmint evalIntElement(vmuint i) OVERRIDE;
335      virtual void assignIntElement(vmuint i, vmint value) OVERRIDE;      virtual void assignIntElement(vmuint i, vmint value) OVERRIDE;
336        vmfloat unitFactorOfElement(vmuint i) const OVERRIDE;
337        void assignElementUnitFactor(vmuint i, vmfloat factor) OVERRIDE;
338      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
339      bool isPolyphonic() const OVERRIDE { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
340  protected:  protected:
# Line 288  typedef Ref<IntArrayVariable,Node> IntAr Line 344  typedef Ref<IntArrayVariable,Node> IntAr
344    
345  class RealArrayVariable FINAL : public Variable, virtual public RealArrayExpr {  class RealArrayVariable FINAL : public Variable, virtual public RealArrayExpr {
346      ArrayList<vmfloat> values;      ArrayList<vmfloat> values;
347        ArrayList<vmfloat> unitFactors;
348  public:  public:
349      RealArrayVariable(ParserContext* ctx, vmint size);      RealArrayVariable(ParserContext* ctx, vmint size);
350      RealArrayVariable(ParserContext* ctx, vmint size, ArgsRef values, bool _bConst = false);      RealArrayVariable(ParserContext* ctx, vmint size, ArgsRef values, bool _bConst = false);
351      void assign(Expression* expr) OVERRIDE {} // ignore scalar assignment      void assign(Expression* expr) OVERRIDE {} // ignore scalar assignment
     String evalCastToStr() OVERRIDE { return ""; } // ignore scalar cast to string  
352      ExprType_t exprType() const OVERRIDE { return REAL_ARR_EXPR; }      ExprType_t exprType() const OVERRIDE { return REAL_ARR_EXPR; }
353      virtual vmint arraySize() const OVERRIDE { return values.size(); }      virtual vmint arraySize() const OVERRIDE { return values.size(); }
354      virtual vmfloat evalRealElement(vmuint i) OVERRIDE;      virtual vmfloat evalRealElement(vmuint i) OVERRIDE;
355      virtual void assignRealElement(vmuint i, vmfloat value) OVERRIDE;      virtual void assignRealElement(vmuint i, vmfloat value) OVERRIDE;
356        vmfloat unitFactorOfElement(vmuint i) const OVERRIDE;
357        void assignElementUnitFactor(vmuint i, vmfloat factor) OVERRIDE;
358      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
359      bool isPolyphonic() const OVERRIDE { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
360  protected:  protected:
# Line 311  public: Line 369  public:
369      BuiltInIntArrayVariable(const String& name, VMInt8Array* array);      BuiltInIntArrayVariable(const String& name, VMInt8Array* array);
370      vmint arraySize() const OVERRIDE { return array->size; }      vmint arraySize() const OVERRIDE { return array->size; }
371      vmint evalIntElement(vmuint i) OVERRIDE;      vmint evalIntElement(vmuint i) OVERRIDE;
     bool isAssignable() const OVERRIDE { return !array->readonly; }  
372      void assignIntElement(vmuint i, vmint value) OVERRIDE;      void assignIntElement(vmuint i, vmint value) OVERRIDE;
373        vmfloat unitFactorOfElement(vmuint i) const OVERRIDE { return VM_NO_FACTOR; }
374        void assignElementUnitFactor(vmuint i, vmfloat factor) OVERRIDE {}
375        bool isAssignable() const OVERRIDE { return !array->readonly; }
376      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
377  };  };
378  typedef Ref<BuiltInIntArrayVariable,Node> BuiltInIntArrayVariableRef;  typedef Ref<BuiltInIntArrayVariable,Node> BuiltInIntArrayVariableRef;
# Line 320  typedef Ref<BuiltInIntArrayVariable,Node Line 380  typedef Ref<BuiltInIntArrayVariable,Node
380  class IntArrayElement FINAL : public IntVariable {  class IntArrayElement FINAL : public IntVariable {
381      IntArrayExprRef array;      IntArrayExprRef array;
382      IntExprRef index;      IntExprRef index;
383        vmint currentIndex;
384  public:  public:
385      IntArrayElement(IntArrayExprRef array, IntExprRef arrayIndex);      IntArrayElement(IntArrayExprRef array, IntExprRef arrayIndex);
386      void assign(Expression* expr) OVERRIDE;      void assign(Expression* expr) OVERRIDE;
387      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
388        vmfloat unitFactor() const OVERRIDE;
389      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
390  };  };
391  typedef Ref<IntArrayElement,Node> IntArrayElementRef;  typedef Ref<IntArrayElement,Node> IntArrayElementRef;
# Line 331  typedef Ref<IntArrayElement,Node> IntArr Line 393  typedef Ref<IntArrayElement,Node> IntArr
393  class RealArrayElement FINAL : public RealVariable {  class RealArrayElement FINAL : public RealVariable {
394      RealArrayExprRef array;      RealArrayExprRef array;
395      IntExprRef index;      IntExprRef index;
396        vmint currentIndex;
397  public:  public:
398      RealArrayElement(RealArrayExprRef array, IntExprRef arrayIndex);      RealArrayElement(RealArrayExprRef array, IntExprRef arrayIndex);
399      void assign(Expression* expr) OVERRIDE;      void assign(Expression* expr) OVERRIDE;
400      vmfloat evalReal() OVERRIDE;      vmfloat evalReal() OVERRIDE;
401        vmfloat unitFactor() const OVERRIDE;
402      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
403  };  };
404  typedef Ref<RealArrayElement,Node> RealArrayElementRef;  typedef Ref<RealArrayElement,Node> RealArrayElementRef;
# Line 352  protected: Line 416  protected:
416  typedef Ref<StringVariable,Node> StringVariableRef;  typedef Ref<StringVariable,Node> StringVariableRef;
417    
418  class ConstStringVariable FINAL : public StringVariable {  class ConstStringVariable FINAL : public StringVariable {
 public:  
419      String value;      String value;
420    public:
421      ConstStringVariable(ParserContext* ctx, String value = "");      ConstStringVariable(ParserContext* ctx, String value = "");
422      void assign(Expression* expr) OVERRIDE;      void assign(Expression* expr) OVERRIDE;
423      String evalStr() OVERRIDE;      String evalStr() OVERRIDE;
# Line 376  typedef Ref<BinaryOp,Node> BinaryOpRef; Line 439  typedef Ref<BinaryOp,Node> BinaryOpRef;
439  class ScalarNumberBinaryOp : public BinaryOp, virtual public ScalarNumberExpr {  class ScalarNumberBinaryOp : public BinaryOp, virtual public ScalarNumberExpr {
440  public:  public:
441      ScalarNumberBinaryOp(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs) : BinaryOp(lhs, rhs) { }      ScalarNumberBinaryOp(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs) : BinaryOp(lhs, rhs) { }
     MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE;  
     StdUnit_t unitType() const OVERRIDE;  
442      bool isFinal() const OVERRIDE;      bool isFinal() const OVERRIDE;
443  };  };
444  typedef Ref<ScalarNumberBinaryOp,Node> ScalarNumberBinaryOpRef;  typedef Ref<ScalarNumberBinaryOp,Node> ScalarNumberBinaryOpRef;
# Line 398  typedef Ref<VaritypeScalarBinaryOp,Node> Line 459  typedef Ref<VaritypeScalarBinaryOp,Node>
459    
460  class Add FINAL : public VaritypeScalarBinaryOp {  class Add FINAL : public VaritypeScalarBinaryOp {
461  public:  public:
462      Add(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs) : VaritypeScalarBinaryOp(lhs, rhs) { }      Add(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs);
463      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
464      vmfloat evalReal() OVERRIDE;      vmfloat evalReal() OVERRIDE;
465        vmfloat unitFactor() const OVERRIDE;
466      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
467  };  };
468  typedef Ref<Add,Node> AddRef;  typedef Ref<Add,Node> AddRef;
469    
470  class Sub FINAL : public VaritypeScalarBinaryOp {  class Sub FINAL : public VaritypeScalarBinaryOp {
471  public:  public:
472      Sub(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs) : VaritypeScalarBinaryOp(lhs, rhs) { }      Sub(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs);
473      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
474      vmfloat evalReal() OVERRIDE;      vmfloat evalReal() OVERRIDE;
475        vmfloat unitFactor() const OVERRIDE;
476      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
477  };  };
478  typedef Ref<Sub,Node> SubRef;  typedef Ref<Sub,Node> SubRef;
479    
480  class Mul FINAL : public VaritypeScalarBinaryOp {  class Mul FINAL : public VaritypeScalarBinaryOp {
481  public:  public:
482      Mul(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs) : VaritypeScalarBinaryOp(lhs, rhs) { }      Mul(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs);
483      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
484      vmfloat evalReal() OVERRIDE;      vmfloat evalReal() OVERRIDE;
485        vmfloat unitFactor() const OVERRIDE;
486      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
     MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE;  
     StdUnit_t unitType() const OVERRIDE;  
487  };  };
488  typedef Ref<Mul,Node> MulRef;  typedef Ref<Mul,Node> MulRef;
489    
490  class Div FINAL : public VaritypeScalarBinaryOp {  class Div FINAL : public VaritypeScalarBinaryOp {
491  public:  public:
492      Div(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs) : VaritypeScalarBinaryOp(lhs, rhs) { }      Div(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs);
493      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
494      vmfloat evalReal() OVERRIDE;      vmfloat evalReal() OVERRIDE;
495      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
496      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE;      vmfloat unitFactor() const OVERRIDE;
     StdUnit_t unitType() const OVERRIDE;  
497  };  };
498  typedef Ref<Div,Node> DivRef;  typedef Ref<Div,Node> DivRef;
499    
500  class Mod FINAL : public IntBinaryOp {  class Mod FINAL : public IntBinaryOp {
501  public:  public:
502      Mod(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs, rhs) { }      Mod(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs, rhs), Unit(VM_NO_UNIT) { }
503      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
504        vmfloat unitFactor() const OVERRIDE { return VM_NO_FACTOR; }
505      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
506  };  };
507  typedef Ref<Mod,Node> ModRef;  typedef Ref<Mod,Node> ModRef;
# Line 505  public: Line 567  public:
567      vmint arraySize() const OVERRIDE { return dynVar->asIntArray()->arraySize(); }      vmint arraySize() const OVERRIDE { return dynVar->asIntArray()->arraySize(); }
568      vmint evalIntElement(vmuint i) OVERRIDE { return dynVar->asIntArray()->evalIntElement(i); }      vmint evalIntElement(vmuint i) OVERRIDE { return dynVar->asIntArray()->evalIntElement(i); }
569      void assignIntElement(vmuint i, vmint value) OVERRIDE { return dynVar->asIntArray()->assignIntElement(i, value); }      void assignIntElement(vmuint i, vmint value) OVERRIDE { return dynVar->asIntArray()->assignIntElement(i, value); }
570        vmfloat unitFactorOfElement(vmuint i) const OVERRIDE { return VM_NO_FACTOR; }
571        void assignElementUnitFactor(vmuint i, vmfloat factor) OVERRIDE {}
572      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
573      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }      vmfloat unitFactor() const OVERRIDE { return VM_NO_FACTOR; }
     StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }  
574      bool isFinal() const OVERRIDE { return false; }      bool isFinal() const OVERRIDE { return false; }
575  };  };
576  typedef Ref<DynamicVariableCall,Node> DynamicVariableCallRef;  typedef Ref<DynamicVariableCall,Node> DynamicVariableCallRef;
# Line 516  class FunctionCall : virtual public Leaf Line 579  class FunctionCall : virtual public Leaf
579      String functionName;      String functionName;
580      ArgsRef args;      ArgsRef args;
581      VMFunction* fn;      VMFunction* fn;
582        VMFnResult* result;
583  public:  public:
584      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :      FunctionCall(const char* function, ArgsRef args, VMFunction* fn);
         functionName(function), args(args), fn(fn) { }  
585      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
586      StmtFlags_t exec() OVERRIDE;      StmtFlags_t exec() OVERRIDE;
587      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
# Line 530  public: Line 593  public:
593      ExprType_t exprType() const OVERRIDE;      ExprType_t exprType() const OVERRIDE;
594      String evalCastToStr() OVERRIDE;      String evalCastToStr() OVERRIDE;
595      bool isPolyphonic() const OVERRIDE { return args->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return args->isPolyphonic(); }
596      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }      vmfloat unitFactor() const OVERRIDE;
597      StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }      bool isFinal() const OVERRIDE;
     bool isFinal() const OVERRIDE { return false; }  
598  protected:  protected:
599      VMFnResult* execVMFn();      VMFnResult* execVMFn();
600  };  };
# Line 540  typedef Ref<FunctionCall,Node> FunctionC Line 602  typedef Ref<FunctionCall,Node> FunctionC
602    
603  class NoFunctionCall FINAL : public FunctionCall {  class NoFunctionCall FINAL : public FunctionCall {
604  public:  public:
605      NoFunctionCall() : FunctionCall("nothing", new Args, NULL) {}      NoFunctionCall() : FunctionCall("nothing", new Args, NULL), Unit(VM_NO_UNIT) {}
606      StmtType_t statementType() const OVERRIDE { return STMT_NOOP; }      StmtType_t statementType() const OVERRIDE { return STMT_NOOP; }
607  };  };
608  typedef Ref<NoFunctionCall,Node> NoFunctionCallRef;  typedef Ref<NoFunctionCall,Node> NoFunctionCallRef;
# Line 646  public: Line 708  public:
708      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
709      vmint evalBranch() OVERRIDE;      vmint evalBranch() OVERRIDE;
710      Statements* branch(vmuint i) const OVERRIDE;      Statements* branch(vmuint i) const OVERRIDE;
     //void addBranch(IntExprRef condition, StatementsRef statements);  
     //void addBranch(IntExprRef from, IntExprRef to, StatementsRef statements);  
     //void addBranch(CaseBranchRef branch);  
     //void addBranches(CaseBranchesRef branches);  
711      bool isPolyphonic() const OVERRIDE;      bool isPolyphonic() const OVERRIDE;
712  };  };
713  typedef Ref<SelectCase,Node> SelectCaseRef;  typedef Ref<SelectCase,Node> SelectCaseRef;
# Line 681  typedef Ref<SyncBlock,Node> SyncBlockRef Line 739  typedef Ref<SyncBlock,Node> SyncBlockRef
739  class Neg FINAL : virtual public IntExpr, virtual public RealExpr {  class Neg FINAL : virtual public IntExpr, virtual public RealExpr {
740      ScalarNumberExprRef expr;      ScalarNumberExprRef expr;
741  public:  public:
742      Neg(ScalarNumberExprRef expr) : expr(expr) { }      Neg(ScalarNumberExprRef expr) : Unit(expr->unitType()), expr(expr) { }
743      ExprType_t exprType() const OVERRIDE { return expr->exprType(); }      ExprType_t exprType() const OVERRIDE { return expr->exprType(); }
744      vmint evalInt() OVERRIDE { return (expr) ? -(expr->asInt()->evalInt()) : 0; }      vmint evalInt() OVERRIDE { return (expr) ? -(expr->asInt()->evalInt()) : 0; }
745      vmfloat evalReal() OVERRIDE { return (expr) ? -(expr->asReal()->evalReal()) : vmfloat(0); }      vmfloat evalReal() OVERRIDE { return (expr) ? -(expr->asReal()->evalReal()) : vmfloat(0); }
# Line 689  public: Line 747  public:
747      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
748      bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }      bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }
749      bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }
750      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return expr->unitPrefix(i); }      vmfloat unitFactor() const OVERRIDE { return expr->unitFactor(); }
     StdUnit_t unitType() const OVERRIDE { return expr->unitType(); }  
751      bool isFinal() const OVERRIDE { return expr->isFinal(); }      bool isFinal() const OVERRIDE { return expr->isFinal(); }
752  };  };
753  typedef Ref<Neg,Node> NegRef;  typedef Ref<Neg,Node> NegRef;
# Line 717  public: Line 774  public:
774          EQUAL,          EQUAL,
775          NOT_EQUAL          NOT_EQUAL
776      };      };
777      Relation(ExpressionRef lhs, Type type, ExpressionRef rhs) :      Relation(ExpressionRef lhs, Type type, ExpressionRef rhs);
         lhs(lhs), rhs(rhs), type(type) {}  
778      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
779      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
780      bool isConstExpr() const OVERRIDE;      bool isConstExpr() const OVERRIDE;
781      bool isPolyphonic() const OVERRIDE { return lhs->isPolyphonic() || rhs->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return lhs->isPolyphonic() || rhs->isPolyphonic(); }
782      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }      vmfloat unitFactor() const OVERRIDE { return VM_NO_FACTOR; }
     StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }  
783      bool isFinal() const OVERRIDE { return false; }      bool isFinal() const OVERRIDE { return false; }
784  private:  private:
785      ExpressionRef lhs;      ExpressionRef lhs;
# Line 735  typedef Ref<Relation,Node> RelationRef; Line 790  typedef Ref<Relation,Node> RelationRef;
790    
791  class Or FINAL : public IntBinaryOp {  class Or FINAL : public IntBinaryOp {
792  public:  public:
793      Or(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs) {}      Or(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs), Unit(VM_NO_UNIT) {}
794      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
795        vmfloat unitFactor() const OVERRIDE { return VM_NO_FACTOR; }
796      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
797  };  };
798  typedef Ref<Or,Node> OrRef;  typedef Ref<Or,Node> OrRef;
799    
800  class BitwiseOr FINAL : public IntBinaryOp {  class BitwiseOr FINAL : public IntBinaryOp {
801  public:  public:
802      BitwiseOr(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs) {}      BitwiseOr(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs), Unit(VM_NO_UNIT) {}
803      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
804      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
805      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }      vmfloat unitFactor() const OVERRIDE { return VM_NO_FACTOR; }
     StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }  
806  };  };
807  typedef Ref<BitwiseOr,Node> BitwiseOrRef;  typedef Ref<BitwiseOr,Node> BitwiseOrRef;
808    
809  class And FINAL : public IntBinaryOp {  class And FINAL : public IntBinaryOp {
810  public:  public:
811      And(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs) {}      And(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs), Unit(VM_NO_UNIT) {}
812      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
813        vmfloat unitFactor() const OVERRIDE { return VM_NO_FACTOR; }
814      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
815  };  };
816  typedef Ref<And,Node> AndRef;  typedef Ref<And,Node> AndRef;
817    
818  class BitwiseAnd FINAL : public IntBinaryOp {  class BitwiseAnd FINAL : public IntBinaryOp {
819  public:  public:
820      BitwiseAnd(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs) {}      BitwiseAnd(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs), Unit(VM_NO_UNIT) {}
821      vmint evalInt() OVERRIDE;      vmint evalInt() OVERRIDE;
822      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
823      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }      vmfloat unitFactor() const OVERRIDE { return VM_NO_FACTOR; }
     StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }  
824  };  };
825  typedef Ref<BitwiseAnd,Node> BitwiseAndRef;  typedef Ref<BitwiseAnd,Node> BitwiseAndRef;
826    
827  class Not FINAL : virtual public IntExpr {  class Not FINAL : virtual public IntExpr {
828      IntExprRef expr;      IntExprRef expr;
829  public:  public:
830      Not(IntExprRef expr) : expr(expr) {}      Not(IntExprRef expr) : Unit(VM_NO_UNIT), expr(expr) {}
831      vmint evalInt() OVERRIDE { return !expr->evalInt(); }      vmint evalInt() OVERRIDE { return !expr->evalInt(); }
832      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
833      bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }      bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }
834      bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }
835      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }      vmfloat unitFactor() const OVERRIDE { return VM_NO_FACTOR; }
     StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }  
836      bool isFinal() const OVERRIDE { return expr->isFinal(); }      bool isFinal() const OVERRIDE { return expr->isFinal(); }
837  };  };
838  typedef Ref<Not,Node> NotRef;  typedef Ref<Not,Node> NotRef;
# Line 786  typedef Ref<Not,Node> NotRef; Line 840  typedef Ref<Not,Node> NotRef;
840  class BitwiseNot FINAL : virtual public IntExpr {  class BitwiseNot FINAL : virtual public IntExpr {
841      IntExprRef expr;      IntExprRef expr;
842  public:  public:
843      BitwiseNot(IntExprRef expr) : expr(expr) {}      BitwiseNot(IntExprRef expr) : Unit(VM_NO_UNIT), expr(expr) {}
844      vmint evalInt() OVERRIDE { return ~expr->evalInt(); }      vmint evalInt() OVERRIDE { return ~expr->evalInt(); }
845      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
846      bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }      bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }
847      bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }
848      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }      vmfloat unitFactor() const OVERRIDE { return VM_NO_FACTOR; }
     StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }  
849      bool isFinal() const OVERRIDE { return expr->isFinal(); }      bool isFinal() const OVERRIDE { return expr->isFinal(); }
850  };  };
851  typedef Ref<BitwiseNot,Node> BitwiseNotRef;  typedef Ref<BitwiseNot,Node> BitwiseNotRef;
# Line 800  typedef Ref<BitwiseNot,Node> BitwiseNotR Line 853  typedef Ref<BitwiseNot,Node> BitwiseNotR
853  class Final FINAL : virtual public IntExpr, virtual public RealExpr {  class Final FINAL : virtual public IntExpr, virtual public RealExpr {
854      ScalarNumberExprRef expr;      ScalarNumberExprRef expr;
855  public:  public:
856      Final(ScalarNumberExprRef expr) : expr(expr) {}      Final(ScalarNumberExprRef expr) : Unit(expr->unitType()), expr(expr) {}
857      ExprType_t exprType() const OVERRIDE { return expr->exprType(); }      ExprType_t exprType() const OVERRIDE { return expr->exprType(); }
858      vmint evalInt() OVERRIDE { return expr->asInt()->evalInt(); }      vmint evalInt() OVERRIDE { return expr->asInt()->evalInt(); }
859      vmfloat evalReal() OVERRIDE { return expr->asReal()->evalReal(); }      vmfloat evalReal() OVERRIDE { return expr->asReal()->evalReal(); }
# Line 808  public: Line 861  public:
861      void dump(int level = 0) OVERRIDE;      void dump(int level = 0) OVERRIDE;
862      bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }      bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }
863      bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }
864      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return expr->unitPrefix(i); }      vmfloat unitFactor() const OVERRIDE { return expr->unitFactor(); }
     StdUnit_t unitType() const OVERRIDE { return expr->unitType(); }  
865      bool isFinal() const OVERRIDE { return true; }      bool isFinal() const OVERRIDE { return true; }
866  };  };
867  typedef Ref<Final,Node> FinalRef;  typedef Ref<Final,Node> FinalRef;
# Line 837  public: Line 889  public:
889      vmint globalIntVarCount;      vmint globalIntVarCount;
890      vmint globalRealVarCount;      vmint globalRealVarCount;
891      vmint globalStrVarCount;      vmint globalStrVarCount;
892        vmint globalUnitFactorCount;
893      vmint polyphonicIntVarCount;      vmint polyphonicIntVarCount;
894      vmint polyphonicRealVarCount;      vmint polyphonicRealVarCount;
895        vmint polyphonicUnitFactorCount;
896    
897      EventHandlersRef handlers;      EventHandlersRef handlers;
898    
# Line 850  public: Line 904  public:
904      ArrayList<vmint>* globalIntMemory;      ArrayList<vmint>* globalIntMemory;
905      ArrayList<vmfloat>* globalRealMemory;      ArrayList<vmfloat>* globalRealMemory;
906      ArrayList<String>* globalStrMemory;      ArrayList<String>* globalStrMemory;
907        ArrayList<vmfloat>* globalUnitFactorMemory;
908      vmint requiredMaxStackSize;      vmint requiredMaxStackSize;
909    
910      VMFunctionProvider* functionProvider;      VMFunctionProvider* functionProvider;
# Line 859  public: Line 914  public:
914      ParserContext(VMFunctionProvider* parent) :      ParserContext(VMFunctionProvider* parent) :
915          scanner(NULL), is(NULL),          scanner(NULL), is(NULL),
916          globalIntVarCount(0), globalRealVarCount(0), globalStrVarCount(0),          globalIntVarCount(0), globalRealVarCount(0), globalStrVarCount(0),
917            globalUnitFactorCount(0),
918          polyphonicIntVarCount(0), polyphonicRealVarCount(0),          polyphonicIntVarCount(0), polyphonicRealVarCount(0),
919            polyphonicUnitFactorCount(0),
920          globalIntMemory(NULL), globalRealMemory(NULL), globalStrMemory(NULL),          globalIntMemory(NULL), globalRealMemory(NULL), globalStrMemory(NULL),
921            globalUnitFactorMemory(NULL),
922          requiredMaxStackSize(-1),          requiredMaxStackSize(-1),
923          functionProvider(parent), execContext(NULL)          functionProvider(parent), execContext(NULL)
924      {      {
# Line 906  public: Line 964  public:
964    
965      ArrayList<vmint> polyphonicIntMemory;      ArrayList<vmint> polyphonicIntMemory;
966      ArrayList<vmfloat> polyphonicRealMemory;      ArrayList<vmfloat> polyphonicRealMemory;
967        ArrayList<vmfloat> polyphonicUnitFactorMemory;
968      VMExecStatus_t status;      VMExecStatus_t status;
969      StmtFlags_t flags;      StmtFlags_t flags;
970      ArrayList<StackFrame> stack;      ArrayList<StackFrame> stack;
# Line 918  public: Line 977  public:
977          RealLiteral realLiteral;          RealLiteral realLiteral;
978          StringLiteral stringLiteral;          StringLiteral stringLiteral;
979    
980          ExitRes() : intLiteral(0), realLiteral(0.0), stringLiteral("") { }          ExitRes() :
981                intLiteral({ .value = 0 }), realLiteral({ .value = 0.0 }),
982                stringLiteral("") { }
983      } exitRes;      } exitRes;
984    
985      ExecContext();      ExecContext();
# Line 959  public: Line 1020  public:
1020              memset(&polyphonicIntMemory[0], 0, polyphonicIntMemory.size() * sizeof(vmint));              memset(&polyphonicIntMemory[0], 0, polyphonicIntMemory.size() * sizeof(vmint));
1021          if (!polyphonicRealMemory.empty())          if (!polyphonicRealMemory.empty())
1022              memset(&polyphonicRealMemory[0], 0, polyphonicRealMemory.size() * sizeof(vmfloat));              memset(&polyphonicRealMemory[0], 0, polyphonicRealMemory.size() * sizeof(vmfloat));
1023            if (!polyphonicUnitFactorMemory.empty()) {
1024                const vmint sz = polyphonicUnitFactorMemory.size();
1025                for (vmint i = 0; i < sz; ++i)
1026                    polyphonicUnitFactorMemory[i] = VM_NO_FACTOR;
1027            }
1028      }      }
1029    
1030      size_t instructionsPerformed() const OVERRIDE {      size_t instructionsPerformed() const OVERRIDE {

Legend:
Removed from v.3576  
changed lines
  Added in v.3581

  ViewVC Help
Powered by ViewVC