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 |
} |
} |
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) { |
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) : |
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() { |
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; |
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 |
|
|
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 : |
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 |
{ |
{ |
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 : |
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 |
{ |
{ |
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) |
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) : |
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) |
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) |
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 |
{ |
{ |
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 |
{ |
{ |
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); |
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); |
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 |
} |
} |
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"); |
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); |
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); |
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 |
} |
} |
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) { |
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) |
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 |
} |
} |
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) |
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 |
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 |
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 |
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; |
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; |
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 |
|
|
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 |
|
|