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

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

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

revision 3582 by schoenebeck, Fri Aug 30 12:23:40 2019 UTC revision 3744 by schoenebeck, Sat Feb 15 11:50:02 2020 UTC
# Line 13  Line 13 
13  #include "../common/global_private.h"  #include "../common/global_private.h"
14  #include "../common/RTMath.h"  #include "../common/RTMath.h"
15  #include <assert.h>  #include <assert.h>
16    #include "CoreVMFunctions.h" // for VMIntResult, VMRealResult
17    
18  namespace LinuxSampler {  namespace LinuxSampler {
19            
20  bool isNoOperation(StatementRef statement) {  bool isNoOperation(StatementRef statement) {
21      return statement->statementType() == STMT_NOOP;      return statement->statementType() == STMT_NOOP;
22  }  }
23    
24    String acceptedArgTypesStr(VMFunction* fn, vmint iArg) {
25        static const ExprType_t allTypes[] = {
26            INT_EXPR,
27            INT_ARR_EXPR,
28            REAL_EXPR,
29            REAL_ARR_EXPR,
30            STRING_EXPR,
31            STRING_ARR_EXPR,
32        };
33        const size_t nTypes = sizeof(allTypes) / sizeof(ExprType_t);
34    
35        std::vector<ExprType_t> supportedTypes;
36        for (int iType = 0; iType < nTypes; ++iType) {
37            const ExprType_t& type = allTypes[iType];
38            if (fn->acceptsArgType(iArg, type))
39                supportedTypes.push_back(type);
40        }
41        assert(!supportedTypes.empty());
42    
43        if (supportedTypes.size() == 1) {
44            return typeStr(*supportedTypes.begin());
45        } else {
46            String s = "either ";
47            for (size_t i = 0; i < supportedTypes.size(); ++i) {
48                const ExprType_t& type = supportedTypes[i];
49                if (i == 0) {
50                    s += typeStr(type);
51                } else if (i == supportedTypes.size() - 1) {
52                    s += " or " + typeStr(type);
53                } else {
54                    s += ", " + typeStr(type);
55                }
56            }
57            return s;
58        }
59    }
60            
61  Node::Node() {  Node::Node() {
62  }  }
# Line 85  static String _unitFactorToShortStr(vmfl Line 123  static String _unitFactorToShortStr(vmfl
123      }      }
124  }  }
125    
126  static String _unitToStr(Unit* unit) {  static String _unitToStr(VMUnit* unit) {
127      const StdUnit_t type = unit->unitType();      const StdUnit_t type = unit->unitType();
128      String sType;      String sType;
129      switch (type) {      switch (type) {
# Line 151  vmint IntLiteral::evalInt() { Line 189  vmint IntLiteral::evalInt() {
189    
190  void IntLiteral::dump(int level) {  void IntLiteral::dump(int level) {
191      printIndents(level);      printIndents(level);
192      printf("IntLiteral %lld\n", value);      printf("IntLiteral %" PRId64 "\n", (int64_t)value);
193  }  }
194    
195  RealLiteral::RealLiteral(const RealLitDef& def) :  RealLiteral::RealLiteral(const RealLitDef& def) :
# Line 575  VMFnResult* FunctionCall::execVMFn() { Line 613  VMFnResult* FunctionCall::execVMFn() {
613      if (!fn) return NULL;      if (!fn) return NULL;
614      // assuming here that all argument checks (amount and types) have been made      // assuming here that all argument checks (amount and types) have been made
615      // at parse time, to avoid time intensive checks on each function call      // at parse time, to avoid time intensive checks on each function call
616      return fn->exec(dynamic_cast<VMFnArgs*>(&*args));      VMFnResult* res = fn->exec(dynamic_cast<VMFnArgs*>(&*args));
617        if (!res) return res;
618    
619        VMExpr* expr = res->resultValue();
620        if (!expr) return res;
621    
622        // For performance reasons we always only let 'FunctionCall' assign the unit
623        // type to the function's result expression, never by the function
624        // implementation itself, nor by other classes, because a FunctionCall
625        // object solely knows the unit type in O(1).
626        ExprType_t type = expr->exprType();
627        if (type == INT_EXPR) {
628            VMIntResult* intRes = dynamic_cast<VMIntResult*>(res);
629            intRes->unitBaseType = unitType();
630        } else if (type == REAL_EXPR) {
631            VMRealResult* realRes = dynamic_cast<VMRealResult*>(res);
632            realRes->unitBaseType = unitType();
633        }
634    
635        return res;
636  }  }
637    
638  StmtFlags_t FunctionCall::exec() {  StmtFlags_t FunctionCall::exec() {
# Line 602  vmfloat FunctionCall::evalReal() { Line 659  vmfloat FunctionCall::evalReal() {
659  }  }
660    
661  VMIntArrayExpr* FunctionCall::asIntArray() const {  VMIntArrayExpr* FunctionCall::asIntArray() const {
662        //FIXME: asIntArray() not intended for evaluation semantics (for both
663        // performance reasons with arrays, but also to prevent undesired value
664        // mutation by implied (hidden) evaluation, as actually done here. We must
665        // force function evaluation here though, because we need it for function
666        // calls to be evaluated at all. This issue should be addressed cleanly by
667        // adjusting the API appropriately.
668        FunctionCall* rwSelf = const_cast<FunctionCall*>(this);
669        rwSelf->result = rwSelf->execVMFn();
670    
671      if (!result) return 0;      if (!result) return 0;
672      VMIntArrayExpr* intArrExpr = dynamic_cast<VMIntArrayExpr*>(result->resultValue());      VMIntArrayExpr* intArrExpr = dynamic_cast<VMIntArrayExpr*>(result->resultValue());
673      return intArrExpr;      return intArrExpr;
674  }  }
675    
676  VMRealArrayExpr* FunctionCall::asRealArray() const {  VMRealArrayExpr* FunctionCall::asRealArray() const {
677        //FIXME: asRealArray() not intended for evaluation semantics (for both
678        // performance reasons with arrays, but also to prevent undesired value
679        // mutation by implied (hidden) evaluation, as actually done here. We must
680        // force function evaluation here though, because we need it for function
681        // calls to be evaluated at all. This issue should be addressed cleanly by
682        // adjusting the API appropriately.
683        FunctionCall* rwSelf = const_cast<FunctionCall*>(this);
684        rwSelf->result = rwSelf->execVMFn();
685    
686      if (!result) return 0;      if (!result) return 0;
687      VMRealArrayExpr* realArrExpr = dynamic_cast<VMRealArrayExpr*>(result->resultValue());      VMRealArrayExpr* realArrExpr = dynamic_cast<VMRealArrayExpr*>(result->resultValue());
688      return realArrExpr;      return realArrExpr;
# Line 630  String FunctionCall::evalCastToStr() { Line 705  String FunctionCall::evalCastToStr() {
705          return strExpr ? strExpr->evalStr() : "";          return strExpr ? strExpr->evalStr() : "";
706      } else if (resultType == REAL_EXPR) {      } else if (resultType == REAL_EXPR) {
707          VMRealExpr* realExpr = dynamic_cast<VMRealExpr*>(result->resultValue());          VMRealExpr* realExpr = dynamic_cast<VMRealExpr*>(result->resultValue());
708          return realExpr ? ToString(realExpr->evalReal()) : "";          return realExpr ? ToString(realExpr->evalReal()) + _unitToStr(realExpr) : "";
709      } else {      } else {
710          VMIntExpr* intExpr = dynamic_cast<VMIntExpr*>(result->resultValue());          VMIntExpr* intExpr = dynamic_cast<VMIntExpr*>(result->resultValue());
711          return intExpr ? ToString(intExpr->evalInt()) : "";          return intExpr ? ToString(intExpr->evalInt()) + _unitToStr(intExpr) : "";
712      }      }
713  }  }
714    
# Line 668  IntVariable::IntVariable(const VariableD Line 743  IntVariable::IntVariable(const VariableD
743          .ctx = decl.ctx,          .ctx = decl.ctx,
744          .isPolyphonic = decl.isPolyphonic,          .isPolyphonic = decl.isPolyphonic,
745          .isConst = decl.isConst,          .isConst = decl.isConst,
         .isFinal = decl.isFinal,  
746          .elements = decl.elements,          .elements = decl.elements,
747          .memPos = (          .memPos = (
748              (!decl.ctx) ? 0 :              (!decl.ctx) ? 0 :
# Line 682  IntVariable::IntVariable(const VariableD Line 756  IntVariable::IntVariable(const VariableD
756                      postfixInc(decl.ctx->polyphonicUnitFactorCount, decl.elements) :                      postfixInc(decl.ctx->polyphonicUnitFactorCount, decl.elements) :
757                      postfixInc(decl.ctx->globalUnitFactorCount, decl.elements)                      postfixInc(decl.ctx->globalUnitFactorCount, decl.elements)
758          ),          ),
759          .unitType = decl.unitType          .unitType = decl.unitType,
760            .isFinal = decl.isFinal,
761      }),      }),
762      Unit(decl.unitType)      Unit(decl.unitType)
763  {  {
# Line 724  RealVariable::RealVariable(const Variabl Line 799  RealVariable::RealVariable(const Variabl
799          .ctx = decl.ctx,          .ctx = decl.ctx,
800          .isPolyphonic = decl.isPolyphonic,          .isPolyphonic = decl.isPolyphonic,
801          .isConst = decl.isConst,          .isConst = decl.isConst,
         .isFinal = decl.isFinal,  
802          .elements = decl.elements,          .elements = decl.elements,
803          .memPos = (          .memPos = (
804              (!decl.ctx) ? 0 :              (!decl.ctx) ? 0 :
# Line 738  RealVariable::RealVariable(const Variabl Line 812  RealVariable::RealVariable(const Variabl
812                      postfixInc(decl.ctx->polyphonicUnitFactorCount, decl.elements) :                      postfixInc(decl.ctx->polyphonicUnitFactorCount, decl.elements) :
813                      postfixInc(decl.ctx->globalUnitFactorCount, decl.elements)                      postfixInc(decl.ctx->globalUnitFactorCount, decl.elements)
814          ),          ),
815          .unitType = decl.unitType          .unitType = decl.unitType,
816            .isFinal = decl.isFinal,
817      }),      }),
818      Unit(decl.unitType)      Unit(decl.unitType)
819  {  {
# Line 780  ConstIntVariable::ConstIntVariable(const Line 855  ConstIntVariable::ConstIntVariable(const
855          .ctx = def.ctx,          .ctx = def.ctx,
856          .isPolyphonic = false,          .isPolyphonic = false,
857          .isConst = true,          .isConst = true,
         .isFinal = def.isFinal,  
858          .elements = 1,          .elements = 1,
859          .memPos = def.memPos,          .memPos = def.memPos,
860          .unitFactorMemPos = def.unitFactorMemPos,          .unitFactorMemPos = def.unitFactorMemPos,
861          .unitType = def.unitType          .unitType = def.unitType,
862            .isFinal = def.isFinal,
863      }),      }),
864      Unit(def.unitType),      Unit(def.unitType),
865      value(def.value), unitPrefixFactor(def.unitFactor)      value(def.value), unitPrefixFactor(def.unitFactor)
# Line 808  vmint ConstIntVariable::evalInt() { Line 883  vmint ConstIntVariable::evalInt() {
883    
884  void ConstIntVariable::dump(int level) {  void ConstIntVariable::dump(int level) {
885      printIndents(level);      printIndents(level);
886      printf("ConstIntVariable val=%lld\n", value);      printf("ConstIntVariable val=%" PRId64 "\n", (int64_t)value);
887  }  }
888    
889  ConstRealVariable::ConstRealVariable(const RealVarDef& def) :  ConstRealVariable::ConstRealVariable(const RealVarDef& def) :
# Line 816  ConstRealVariable::ConstRealVariable(con Line 891  ConstRealVariable::ConstRealVariable(con
891          .ctx = def.ctx,          .ctx = def.ctx,
892          .isPolyphonic = false,          .isPolyphonic = false,
893          .isConst = true,          .isConst = true,
         .isFinal = def.isFinal,  
894          .elements = 1,          .elements = 1,
895          .memPos = def.memPos,          .memPos = def.memPos,
896          .unitFactorMemPos = def.unitFactorMemPos,          .unitFactorMemPos = def.unitFactorMemPos,
897          .unitType = def.unitType          .unitType = def.unitType,
898            .isFinal = def.isFinal,
899      }),      }),
900      Unit(def.unitType),      Unit(def.unitType),
901      value(def.value), unitPrefixFactor(def.unitFactor)      value(def.value), unitPrefixFactor(def.unitFactor)
# Line 845  BuiltInIntVariable::BuiltInIntVariable(c Line 920  BuiltInIntVariable::BuiltInIntVariable(c
920          .ctx = NULL,          .ctx = NULL,
921          .isPolyphonic = false,          .isPolyphonic = false,
922          .isConst = false, // may or may not be modifyable though!          .isConst = false, // may or may not be modifyable though!
         .isFinal = false,  
923          .elements = 0,          .elements = 0,
924          .memPos = 0,          .memPos = 0,
925          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
926          .unitType = VM_NO_UNIT          .unitType = VM_NO_UNIT,
927            .isFinal = false,
928      }),      }),
929      Unit(VM_NO_UNIT),      Unit(VM_NO_UNIT),
930      name(name), ptr(ptr)      name(name), ptr(ptr)
# Line 876  PolyphonicIntVariable::PolyphonicIntVari Line 951  PolyphonicIntVariable::PolyphonicIntVari
951          .ctx = decl.ctx,          .ctx = decl.ctx,
952          .isPolyphonic = true,          .isPolyphonic = true,
953          .isConst = decl.isConst,          .isConst = decl.isConst,
         .isFinal = decl.isFinal,  
954          .elements = 1,          .elements = 1,
955          .memPos = 0,          .memPos = 0,
956          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
957          .unitType = decl.unitType          .unitType = decl.unitType,
958            .isFinal = decl.isFinal,
959      }),      }),
960      Unit(decl.unitType)      Unit(decl.unitType)
961  {  {
# Line 896  PolyphonicRealVariable::PolyphonicRealVa Line 971  PolyphonicRealVariable::PolyphonicRealVa
971          .ctx = decl.ctx,          .ctx = decl.ctx,
972          .isPolyphonic = true,          .isPolyphonic = true,
973          .isConst = decl.isConst,          .isConst = decl.isConst,
         .isFinal = decl.isFinal,  
974          .elements = 1,          .elements = 1,
975          .memPos = 0,          .memPos = 0,
976          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
977          .unitType = decl.unitType          .unitType = decl.unitType,
978            .isFinal = decl.isFinal,
979      }),      }),
980      Unit(decl.unitType)      Unit(decl.unitType)
981  {  {
# Line 916  IntArrayVariable::IntArrayVariable(Parse Line 991  IntArrayVariable::IntArrayVariable(Parse
991          .ctx = ctx,          .ctx = ctx,
992          .isPolyphonic = false,          .isPolyphonic = false,
993          .isConst = false,          .isConst = false,
         .isFinal = false,  
994          .elements = 0,          .elements = 0,
995          .memPos = 0,          .memPos = 0,
996          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
997          .unitType = VM_NO_UNIT          .unitType = VM_NO_UNIT,
998            .isFinal = false,
999      })      })
1000  {  {
1001      values.resize(size);      values.resize(size);
# Line 937  IntArrayVariable::IntArrayVariable(Parse Line 1012  IntArrayVariable::IntArrayVariable(Parse
1012          .ctx = ctx,          .ctx = ctx,
1013          .isPolyphonic = false,          .isPolyphonic = false,
1014          .isConst = _bConst,          .isConst = _bConst,
         .isFinal = false,  
1015          .elements = 0,          .elements = 0,
1016          .memPos = 0,          .memPos = 0,
1017          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
1018          .unitType = VM_NO_UNIT          .unitType = VM_NO_UNIT,
1019            .isFinal = false,
1020      })      })
1021  {  {
1022      this->values.resize(size);      this->values.resize(size);
# Line 960  IntArrayVariable::IntArrayVariable(Parse Line 1035  IntArrayVariable::IntArrayVariable(Parse
1035          .ctx = ctx,          .ctx = ctx,
1036          .isPolyphonic = false,          .isPolyphonic = false,
1037          .isConst = bConst,          .isConst = bConst,
         .isFinal = false,  
1038          .elements = 0,          .elements = 0,
1039          .memPos = 0,          .memPos = 0,
1040          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
1041          .unitType = VM_NO_UNIT          .unitType = VM_NO_UNIT,
1042            .isFinal = false,
1043      })      })
1044  {  {
1045  }  }
# Line 997  void IntArrayVariable::dump(int level) { Line 1072  void IntArrayVariable::dump(int level) {
1072              printf("\n");              printf("\n");
1073              printIndents(level+1);              printIndents(level+1);
1074          }          }
1075          printf("%lld, ", values[i]);          printf("%" PRId64 ", ", (int64_t)values[i]);
1076      }      }
1077      printIndents(level);      printIndents(level);
1078      printf(")\n");      printf(")\n");
# Line 1008  RealArrayVariable::RealArrayVariable(Par Line 1083  RealArrayVariable::RealArrayVariable(Par
1083          .ctx = ctx,          .ctx = ctx,
1084          .isPolyphonic = false,          .isPolyphonic = false,
1085          .isConst = false,          .isConst = false,
         .isFinal = false,  
1086          .elements = 0,          .elements = 0,
1087          .memPos = 0,          .memPos = 0,
1088          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
1089          .unitType = VM_NO_UNIT          .unitType = VM_NO_UNIT,
1090            .isFinal = false,
1091      })      })
1092  {  {
1093      values.resize(size);      values.resize(size);
# Line 1029  RealArrayVariable::RealArrayVariable(Par Line 1104  RealArrayVariable::RealArrayVariable(Par
1104          .ctx = ctx,          .ctx = ctx,
1105          .isPolyphonic = false,          .isPolyphonic = false,
1106          .isConst = _bConst,          .isConst = _bConst,
         .isFinal = false,  
1107          .elements = 0,          .elements = 0,
1108          .memPos = 0,          .memPos = 0,
1109          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
1110          .unitType = VM_NO_UNIT          .unitType = VM_NO_UNIT,
1111            .isFinal = false,
1112      })      })
1113  {  {
1114      this->values.resize(size);      this->values.resize(size);
# Line 1052  RealArrayVariable::RealArrayVariable(Par Line 1127  RealArrayVariable::RealArrayVariable(Par
1127          .ctx = ctx,          .ctx = ctx,
1128          .isPolyphonic = false,          .isPolyphonic = false,
1129          .isConst = bConst,          .isConst = bConst,
         .isFinal = false,  
1130          .elements = 0,          .elements = 0,
1131          .memPos = 0,          .memPos = 0,
1132          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
1133          .unitType = VM_NO_UNIT          .unitType = VM_NO_UNIT,
1134            .isFinal = false,
1135      })      })
1136  {  {
1137  }  }
# Line 1121  IntArrayElement::IntArrayElement(IntArra Line 1196  IntArrayElement::IntArrayElement(IntArra
1196          .ctx = NULL,          .ctx = NULL,
1197          .isPolyphonic = (array) ? array->isPolyphonic() : false,          .isPolyphonic = (array) ? array->isPolyphonic() : false,
1198          .isConst = (array) ? array->isConstExpr() : false,          .isConst = (array) ? array->isConstExpr() : false,
         .isFinal = false,  
1199          .elements = 0,          .elements = 0,
1200          .memPos = 0,          .memPos = 0,
1201          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
1202          .unitType = VM_NO_UNIT          .unitType = VM_NO_UNIT,
1203            .isFinal = false,
1204      }),      }),
1205      Unit(VM_NO_UNIT),      Unit(VM_NO_UNIT),
1206      array(array), index(arrayIndex), currentIndex(-1)      array(array), index(arrayIndex), currentIndex(-1)
1207  {      {
1208  }  }
1209    
1210  void IntArrayElement::assign(Expression* expr) {  void IntArrayElement::assign(Expression* expr) {
# Line 1172  RealArrayElement::RealArrayElement(RealA Line 1247  RealArrayElement::RealArrayElement(RealA
1247          .ctx = NULL,          .ctx = NULL,
1248          .isPolyphonic = (array) ? array->isPolyphonic() : false,          .isPolyphonic = (array) ? array->isPolyphonic() : false,
1249          .isConst = (array) ? array->isConstExpr() : false,          .isConst = (array) ? array->isConstExpr() : false,
         .isFinal = false,  
1250          .elements = 0,          .elements = 0,
1251          .memPos = 0,          .memPos = 0,
1252          .unitFactorMemPos = 0,          .unitFactorMemPos = 0,
1253          .unitType = VM_NO_UNIT          .unitType = VM_NO_UNIT,
1254            .isFinal = false,
1255      }),      }),
1256      Unit(VM_NO_UNIT),      Unit(VM_NO_UNIT),
1257      array(array), index(arrayIndex), currentIndex(-1)      array(array), index(arrayIndex), currentIndex(-1)
# Line 1230  StringVariable::StringVariable(ParserCon Line 1305  StringVariable::StringVariable(ParserCon
1305  StringVariable::StringVariable(ParserContext* ctx, bool bConst) :  StringVariable::StringVariable(ParserContext* ctx, bool bConst) :
1306      Variable({      Variable({
1307          .ctx = ctx,          .ctx = ctx,
1308            .isConst = bConst,
1309          .memPos = 0,          .memPos = 0,
         .isConst = bConst  
1310      })      })
1311  {  {
1312  }  }
# Line 1248  String StringVariable::evalStr() { Line 1323  String StringVariable::evalStr() {
1323    
1324  void StringVariable::dump(int level) {  void StringVariable::dump(int level) {
1325      printIndents(level);      printIndents(level);
1326      printf("StringVariable memPos=%lld\n", memPos);      printf("StringVariable memPos=%" PRId64 "\n", (int64_t)memPos);
1327  }  }
1328    
1329  ConstStringVariable::ConstStringVariable(ParserContext* ctx, String _value)  ConstStringVariable::ConstStringVariable(ParserContext* ctx, String _value)
# Line 1318  void SelectCase::dump(int level) { Line 1393  void SelectCase::dump(int level) {
1393      printIndents(level);      printIndents(level);
1394      if (select)      if (select)
1395          if (select->isConstExpr())          if (select->isConstExpr())
1396              printf("Case select %lld\n", select->evalInt());              printf("Case select %" PRId64 "\n", (int64_t)select->evalInt());
1397          else          else
1398              printf("Case select [runtime expr]\n");              printf("Case select [runtime expr]\n");
1399      else      else
# Line 1328  void SelectCase::dump(int level) { Line 1403  void SelectCase::dump(int level) {
1403          CaseBranch& branch = branches[i];          CaseBranch& branch = branches[i];
1404          if (branch.from && branch.to)          if (branch.from && branch.to)
1405              if (branch.from->isConstExpr() && branch.to->isConstExpr())              if (branch.from->isConstExpr() && branch.to->isConstExpr())
1406                  printf("case %lld to %lld\n", branch.from->evalInt(), branch.to->evalInt());                  printf("case %" PRId64 " to %" PRId64 "\n", (int64_t)branch.from->evalInt(), (int64_t)branch.to->evalInt());
1407              else if (branch.from->isConstExpr() && !branch.to->isConstExpr())              else if (branch.from->isConstExpr() && !branch.to->isConstExpr())
1408                  printf("case %lld to [runtime expr]\n", branch.from->evalInt());                  printf("case %" PRId64 " to [runtime expr]\n", (int64_t)branch.from->evalInt());
1409              else if (!branch.from->isConstExpr() && branch.to->isConstExpr())              else if (!branch.from->isConstExpr() && branch.to->isConstExpr())
1410                  printf("case [runtime expr] to %lld\n", branch.to->evalInt());                  printf("case [runtime expr] to %" PRId64 "\n", (int64_t)branch.to->evalInt());
1411              else              else
1412                  printf("case [runtime expr] to [runtime expr]\n");                  printf("case [runtime expr] to [runtime expr]\n");
1413          else if (branch.from)          else if (branch.from)
1414              if (branch.from->isConstExpr())              if (branch.from->isConstExpr())
1415                  printf("case %lld\n", branch.from->evalInt());                  printf("case %" PRId64 "\n", (int64_t)branch.from->evalInt());
1416              else              else
1417                  printf("case [runtime expr]\n");                  printf("case [runtime expr]\n");
1418          else          else
# Line 1376  void While::dump(int level) { Line 1451  void While::dump(int level) {
1451      printIndents(level);      printIndents(level);
1452      if (m_condition)      if (m_condition)
1453          if (m_condition->isConstExpr())          if (m_condition->isConstExpr())
1454              printf("while (%lld) {\n", m_condition->evalInt());              printf("while (%" PRId64 ") {\n", (int64_t)m_condition->evalInt());
1455          else          else
1456              printf("while ([runtime expr]) {\n");              printf("while ([runtime expr]) {\n");
1457      else      else
# Line 1757  ParserContext::~ParserContext() { Line 1832  ParserContext::~ParserContext() {
1832      }      }
1833  }  }
1834    
1835  void ParserContext::addErr(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt) {  void ParserContext::addErr(int firstLine, int lastLine, int firstColumn,
1836                               int lastColumn, int firstByte, int lengthBytes,
1837                               const char* txt)
1838    {
1839      ParserIssue e;      ParserIssue e;
1840      e.type = PARSER_ERROR;      e.type = PARSER_ERROR;
1841      e.txt = txt;      e.txt = txt;
# Line 1765  void ParserContext::addErr(int firstLine Line 1843  void ParserContext::addErr(int firstLine
1843      e.lastLine = lastLine;      e.lastLine = lastLine;
1844      e.firstColumn = firstColumn;      e.firstColumn = firstColumn;
1845      e.lastColumn = lastColumn;      e.lastColumn = lastColumn;
1846        e.firstByte = firstByte;
1847        e.lengthBytes = lengthBytes;
1848      vErrors.push_back(e);      vErrors.push_back(e);
1849      vIssues.push_back(e);      vIssues.push_back(e);
1850  }  }
1851    
1852  void ParserContext::addWrn(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt) {  void ParserContext::addWrn(int firstLine, int lastLine, int firstColumn,
1853                               int lastColumn, int firstByte, int lengthBytes,
1854                               const char* txt)
1855    {
1856      ParserIssue w;      ParserIssue w;
1857      w.type = PARSER_WARNING;      w.type = PARSER_WARNING;
1858      w.txt = txt;      w.txt = txt;
# Line 1777  void ParserContext::addWrn(int firstLine Line 1860  void ParserContext::addWrn(int firstLine
1860      w.lastLine = lastLine;      w.lastLine = lastLine;
1861      w.firstColumn = firstColumn;      w.firstColumn = firstColumn;
1862      w.lastColumn = lastColumn;      w.lastColumn = lastColumn;
1863        w.firstByte = firstByte;
1864        w.lengthBytes = lengthBytes;
1865      vWarnings.push_back(w);      vWarnings.push_back(w);
1866      vIssues.push_back(w);      vIssues.push_back(w);
1867  }  }
1868    
1869  void ParserContext::addPreprocessorComment(int firstLine, int lastLine, int firstColumn, int lastColumn) {  void ParserContext::addPreprocessorComment(int firstLine, int lastLine,
1870                                               int firstColumn, int lastColumn,
1871                                               int firstByte, int lengthBytes)
1872    {
1873      CodeBlock block;      CodeBlock block;
1874      block.firstLine = firstLine;      block.firstLine = firstLine;
1875      block.lastLine = lastLine;      block.lastLine = lastLine;
1876      block.firstColumn = firstColumn;      block.firstColumn = firstColumn;
1877      block.lastColumn = lastColumn;      block.lastColumn = lastColumn;
1878        block.firstByte = firstByte;
1879        block.lengthBytes = lengthBytes;
1880      vPreprocessorComments.push_back(block);      vPreprocessorComments.push_back(block);
1881  }  }
1882    
# Line 1843  void ParserContext::registerBuiltInConst Line 1933  void ParserContext::registerBuiltInConst
1933              .value = it->second              .value = it->second
1934          });          });
1935          vartable[it->first] = ref;          vartable[it->first] = ref;
1936        }
1937    }
1938    
1939    void ParserContext::registerBuiltInConstRealVariables(const std::map<String,vmfloat>& vars) {
1940        for (std::map<String,vmfloat>::const_iterator it = vars.begin();
1941             it != vars.end(); ++it)
1942        {
1943            ConstRealVariableRef ref = new ConstRealVariable({
1944                .value = it->second
1945            });
1946            vartable[it->first] = ref;
1947      }      }
1948  }  }
1949    

Legend:
Removed from v.3582  
changed lines
  Added in v.3744

  ViewVC Help
Powered by ViewVC