19 |
bool isNoOperation(StatementRef statement) { |
bool isNoOperation(StatementRef statement) { |
20 |
return statement->statementType() == STMT_NOOP; |
return statement->statementType() == STMT_NOOP; |
21 |
} |
} |
22 |
|
|
23 |
|
String acceptedArgTypesStr(VMFunction* fn, vmint iArg) { |
24 |
|
static const ExprType_t allTypes[] = { |
25 |
|
INT_EXPR, |
26 |
|
INT_ARR_EXPR, |
27 |
|
REAL_EXPR, |
28 |
|
REAL_ARR_EXPR, |
29 |
|
STRING_EXPR, |
30 |
|
STRING_ARR_EXPR, |
31 |
|
}; |
32 |
|
const size_t nTypes = sizeof(allTypes) / sizeof(ExprType_t); |
33 |
|
|
34 |
|
std::vector<ExprType_t> supportedTypes; |
35 |
|
for (int iType = 0; iType < nTypes; ++iType) { |
36 |
|
const ExprType_t& type = allTypes[iType]; |
37 |
|
if (fn->acceptsArgType(iArg, type)) |
38 |
|
supportedTypes.push_back(type); |
39 |
|
} |
40 |
|
assert(!supportedTypes.empty()); |
41 |
|
|
42 |
|
if (supportedTypes.size() == 1) { |
43 |
|
return typeStr(*supportedTypes.begin()); |
44 |
|
} else { |
45 |
|
String s = "either "; |
46 |
|
for (size_t i = 0; i < supportedTypes.size(); ++i) { |
47 |
|
const ExprType_t& type = supportedTypes[i]; |
48 |
|
if (i == 0) { |
49 |
|
s += typeStr(type); |
50 |
|
} else if (i == supportedTypes.size() - 1) { |
51 |
|
s += " or " + typeStr(type); |
52 |
|
} else { |
53 |
|
s += ", " + typeStr(type); |
54 |
|
} |
55 |
|
} |
56 |
|
return s; |
57 |
|
} |
58 |
|
} |
59 |
|
|
60 |
Node::Node() { |
Node::Node() { |
61 |
} |
} |
188 |
|
|
189 |
void IntLiteral::dump(int level) { |
void IntLiteral::dump(int level) { |
190 |
printIndents(level); |
printIndents(level); |
191 |
printf("IntLiteral %lld\n", value); |
printf("IntLiteral %" PRId64 "\n", (int64_t)value); |
192 |
} |
} |
193 |
|
|
194 |
RealLiteral::RealLiteral(const RealLitDef& def) : |
RealLiteral::RealLiteral(const RealLitDef& def) : |
212 |
printf("StringLiteral: '%s'\n", value.c_str()); |
printf("StringLiteral: '%s'\n", value.c_str()); |
213 |
} |
} |
214 |
|
|
215 |
Add::Add(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs) : |
Add::Add(NumberExprRef lhs, NumberExprRef rhs) : |
216 |
VaritypeScalarBinaryOp(lhs, rhs), |
VaritypeScalarBinaryOp(lhs, rhs), |
217 |
Unit( |
Unit( |
218 |
// lhs and rhs are forced to be same unit type at parse time, so either one is fine here |
// lhs and rhs are forced to be same unit type at parse time, so either one is fine here |
252 |
} |
} |
253 |
|
|
254 |
vmfloat Add::unitFactor() const { |
vmfloat Add::unitFactor() const { |
255 |
const ScalarNumberExpr* pLHS = dynamic_cast<const ScalarNumberExpr*>(&*lhs); |
const NumberExpr* pLHS = dynamic_cast<const NumberExpr*>(&*lhs); |
256 |
const ScalarNumberExpr* pRHS = dynamic_cast<const ScalarNumberExpr*>(&*rhs); |
const NumberExpr* pRHS = dynamic_cast<const NumberExpr*>(&*rhs); |
257 |
return (pLHS->unitFactor() < pRHS->unitFactor()) ? pLHS->unitFactor() : pRHS->unitFactor(); |
return (pLHS->unitFactor() < pRHS->unitFactor()) ? pLHS->unitFactor() : pRHS->unitFactor(); |
258 |
} |
} |
259 |
|
|
268 |
printf(")\n"); |
printf(")\n"); |
269 |
} |
} |
270 |
|
|
271 |
Sub::Sub(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs) : |
Sub::Sub(NumberExprRef lhs, NumberExprRef rhs) : |
272 |
VaritypeScalarBinaryOp(lhs, rhs), |
VaritypeScalarBinaryOp(lhs, rhs), |
273 |
Unit( |
Unit( |
274 |
// lhs and rhs are forced to be same unit type at parse time, so either one is fine here |
// lhs and rhs are forced to be same unit type at parse time, so either one is fine here |
308 |
} |
} |
309 |
|
|
310 |
vmfloat Sub::unitFactor() const { |
vmfloat Sub::unitFactor() const { |
311 |
const ScalarNumberExpr* pLHS = dynamic_cast<const ScalarNumberExpr*>(&*lhs); |
const NumberExpr* pLHS = dynamic_cast<const NumberExpr*>(&*lhs); |
312 |
const ScalarNumberExpr* pRHS = dynamic_cast<const ScalarNumberExpr*>(&*rhs); |
const NumberExpr* pRHS = dynamic_cast<const NumberExpr*>(&*rhs); |
313 |
return (pLHS->unitFactor() < pRHS->unitFactor()) ? pLHS->unitFactor() : pRHS->unitFactor(); |
return (pLHS->unitFactor() < pRHS->unitFactor()) ? pLHS->unitFactor() : pRHS->unitFactor(); |
314 |
} |
} |
315 |
|
|
324 |
printf(")\n"); |
printf(")\n"); |
325 |
} |
} |
326 |
|
|
327 |
Mul::Mul(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs) : |
Mul::Mul(NumberExprRef lhs, NumberExprRef rhs) : |
328 |
VaritypeScalarBinaryOp(lhs, rhs), |
VaritypeScalarBinaryOp(lhs, rhs), |
329 |
Unit( |
Unit( |
330 |
// currently the NKSP parser only allows a unit type on either side on multiplications |
// currently the NKSP parser only allows a unit type on either side on multiplications |
357 |
} |
} |
358 |
|
|
359 |
vmfloat Mul::unitFactor() const { |
vmfloat Mul::unitFactor() const { |
360 |
const ScalarNumberExpr* pLHS = dynamic_cast<const ScalarNumberExpr*>(&*lhs); |
const NumberExpr* pLHS = dynamic_cast<const NumberExpr*>(&*lhs); |
361 |
const ScalarNumberExpr* pRHS = dynamic_cast<const ScalarNumberExpr*>(&*rhs); |
const NumberExpr* pRHS = dynamic_cast<const NumberExpr*>(&*rhs); |
362 |
return pLHS->unitFactor() * pRHS->unitFactor(); |
return pLHS->unitFactor() * pRHS->unitFactor(); |
363 |
} |
} |
364 |
|
|
365 |
Div::Div(ScalarNumberExprRef lhs, ScalarNumberExprRef rhs) : |
Div::Div(NumberExprRef lhs, NumberExprRef rhs) : |
366 |
VaritypeScalarBinaryOp(lhs, rhs), |
VaritypeScalarBinaryOp(lhs, rhs), |
367 |
Unit( |
Unit( |
368 |
// the NKSP parser only allows either A) a unit type on left side and none |
// the NKSP parser only allows either A) a unit type on left side and none |
404 |
} |
} |
405 |
|
|
406 |
vmfloat Div::unitFactor() const { |
vmfloat Div::unitFactor() const { |
407 |
const ScalarNumberExpr* pLHS = dynamic_cast<const ScalarNumberExpr*>(&*lhs); |
const NumberExpr* pLHS = dynamic_cast<const NumberExpr*>(&*lhs); |
408 |
const ScalarNumberExpr* pRHS = dynamic_cast<const ScalarNumberExpr*>(&*rhs); |
const NumberExpr* pRHS = dynamic_cast<const NumberExpr*>(&*rhs); |
409 |
return pLHS->unitFactor() / pRHS->unitFactor(); |
return pLHS->unitFactor() / pRHS->unitFactor(); |
410 |
} |
} |
411 |
|
|
597 |
if (!fn || !result) return VM_NO_FACTOR; |
if (!fn || !result) return VM_NO_FACTOR; |
598 |
VMExpr* expr = result->resultValue(); |
VMExpr* expr = result->resultValue(); |
599 |
if (!expr) return VM_NO_FACTOR; |
if (!expr) return VM_NO_FACTOR; |
600 |
VMScalarNumberExpr* scalar = expr->asScalarNumberExpr(); |
VMNumberExpr* scalar = expr->asNumber(); |
601 |
if (!scalar) return VM_NO_FACTOR; |
if (!scalar) return VM_NO_FACTOR; |
602 |
return scalar->unitFactor(); |
return scalar->unitFactor(); |
603 |
} |
} |
679 |
{ |
{ |
680 |
} |
} |
681 |
|
|
682 |
ScalarNumberVariable::ScalarNumberVariable(const VariableDecl& decl) : |
NumberVariable::NumberVariable(const VariableDecl& decl) : |
683 |
Variable(decl), |
Variable(decl), |
684 |
Unit(decl.unitType), |
Unit(decl.unitType), |
685 |
unitFactorMemPos(decl.unitFactorMemPos), polyphonic(decl.isPolyphonic), |
unitFactorMemPos(decl.unitFactorMemPos), polyphonic(decl.isPolyphonic), |
687 |
{ |
{ |
688 |
} |
} |
689 |
|
|
690 |
vmfloat ScalarNumberVariable::unitFactor() const { |
vmfloat NumberVariable::unitFactor() const { |
691 |
if (isPolyphonic()) { |
if (isPolyphonic()) { |
692 |
return context->execContext->polyphonicUnitFactorMemory[unitFactorMemPos]; |
return context->execContext->polyphonicUnitFactorMemory[unitFactorMemPos]; |
693 |
} |
} |
701 |
} |
} |
702 |
|
|
703 |
IntVariable::IntVariable(const VariableDecl& decl) : |
IntVariable::IntVariable(const VariableDecl& decl) : |
704 |
ScalarNumberVariable({ |
NumberVariable({ |
705 |
.ctx = decl.ctx, |
.ctx = decl.ctx, |
706 |
.isPolyphonic = decl.isPolyphonic, |
.isPolyphonic = decl.isPolyphonic, |
707 |
.isConst = decl.isConst, |
.isConst = decl.isConst, |
|
.isFinal = decl.isFinal, |
|
708 |
.elements = decl.elements, |
.elements = decl.elements, |
709 |
.memPos = ( |
.memPos = ( |
710 |
(!decl.ctx) ? 0 : |
(!decl.ctx) ? 0 : |
718 |
postfixInc(decl.ctx->polyphonicUnitFactorCount, decl.elements) : |
postfixInc(decl.ctx->polyphonicUnitFactorCount, decl.elements) : |
719 |
postfixInc(decl.ctx->globalUnitFactorCount, decl.elements) |
postfixInc(decl.ctx->globalUnitFactorCount, decl.elements) |
720 |
), |
), |
721 |
.unitType = decl.unitType |
.unitType = decl.unitType, |
722 |
|
.isFinal = decl.isFinal, |
723 |
}), |
}), |
724 |
Unit(decl.unitType) |
Unit(decl.unitType) |
725 |
{ |
{ |
757 |
} |
} |
758 |
|
|
759 |
RealVariable::RealVariable(const VariableDecl& decl) : |
RealVariable::RealVariable(const VariableDecl& decl) : |
760 |
ScalarNumberVariable({ |
NumberVariable({ |
761 |
.ctx = decl.ctx, |
.ctx = decl.ctx, |
762 |
.isPolyphonic = decl.isPolyphonic, |
.isPolyphonic = decl.isPolyphonic, |
763 |
.isConst = decl.isConst, |
.isConst = decl.isConst, |
|
.isFinal = decl.isFinal, |
|
764 |
.elements = decl.elements, |
.elements = decl.elements, |
765 |
.memPos = ( |
.memPos = ( |
766 |
(!decl.ctx) ? 0 : |
(!decl.ctx) ? 0 : |
774 |
postfixInc(decl.ctx->polyphonicUnitFactorCount, decl.elements) : |
postfixInc(decl.ctx->polyphonicUnitFactorCount, decl.elements) : |
775 |
postfixInc(decl.ctx->globalUnitFactorCount, decl.elements) |
postfixInc(decl.ctx->globalUnitFactorCount, decl.elements) |
776 |
), |
), |
777 |
.unitType = decl.unitType |
.unitType = decl.unitType, |
778 |
|
.isFinal = decl.isFinal, |
779 |
}), |
}), |
780 |
Unit(decl.unitType) |
Unit(decl.unitType) |
781 |
{ |
{ |
817 |
.ctx = def.ctx, |
.ctx = def.ctx, |
818 |
.isPolyphonic = false, |
.isPolyphonic = false, |
819 |
.isConst = true, |
.isConst = true, |
|
.isFinal = def.isFinal, |
|
820 |
.elements = 1, |
.elements = 1, |
821 |
.memPos = def.memPos, |
.memPos = def.memPos, |
822 |
.unitFactorMemPos = def.unitFactorMemPos, |
.unitFactorMemPos = def.unitFactorMemPos, |
823 |
.unitType = def.unitType |
.unitType = def.unitType, |
824 |
|
.isFinal = def.isFinal, |
825 |
}), |
}), |
826 |
Unit(def.unitType), |
Unit(def.unitType), |
827 |
value(def.value), unitPrefixFactor(def.unitFactor) |
value(def.value), unitPrefixFactor(def.unitFactor) |
845 |
|
|
846 |
void ConstIntVariable::dump(int level) { |
void ConstIntVariable::dump(int level) { |
847 |
printIndents(level); |
printIndents(level); |
848 |
printf("ConstIntVariable val=%lld\n", value); |
printf("ConstIntVariable val=%" PRId64 "\n", (int64_t)value); |
849 |
} |
} |
850 |
|
|
851 |
ConstRealVariable::ConstRealVariable(const RealVarDef& def) : |
ConstRealVariable::ConstRealVariable(const RealVarDef& def) : |
853 |
.ctx = def.ctx, |
.ctx = def.ctx, |
854 |
.isPolyphonic = false, |
.isPolyphonic = false, |
855 |
.isConst = true, |
.isConst = true, |
|
.isFinal = def.isFinal, |
|
856 |
.elements = 1, |
.elements = 1, |
857 |
.memPos = def.memPos, |
.memPos = def.memPos, |
858 |
.unitFactorMemPos = def.unitFactorMemPos, |
.unitFactorMemPos = def.unitFactorMemPos, |
859 |
.unitType = def.unitType |
.unitType = def.unitType, |
860 |
|
.isFinal = def.isFinal, |
861 |
}), |
}), |
862 |
Unit(def.unitType), |
Unit(def.unitType), |
863 |
value(def.value), unitPrefixFactor(def.unitFactor) |
value(def.value), unitPrefixFactor(def.unitFactor) |
882 |
.ctx = NULL, |
.ctx = NULL, |
883 |
.isPolyphonic = false, |
.isPolyphonic = false, |
884 |
.isConst = false, // may or may not be modifyable though! |
.isConst = false, // may or may not be modifyable though! |
|
.isFinal = false, |
|
885 |
.elements = 0, |
.elements = 0, |
886 |
.memPos = 0, |
.memPos = 0, |
887 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
888 |
.unitType = VM_NO_UNIT |
.unitType = VM_NO_UNIT, |
889 |
|
.isFinal = false, |
890 |
}), |
}), |
891 |
Unit(VM_NO_UNIT), |
Unit(VM_NO_UNIT), |
892 |
name(name), ptr(ptr) |
name(name), ptr(ptr) |
913 |
.ctx = decl.ctx, |
.ctx = decl.ctx, |
914 |
.isPolyphonic = true, |
.isPolyphonic = true, |
915 |
.isConst = decl.isConst, |
.isConst = decl.isConst, |
|
.isFinal = decl.isFinal, |
|
916 |
.elements = 1, |
.elements = 1, |
917 |
.memPos = 0, |
.memPos = 0, |
918 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
919 |
.unitType = decl.unitType |
.unitType = decl.unitType, |
920 |
|
.isFinal = decl.isFinal, |
921 |
}), |
}), |
922 |
Unit(decl.unitType) |
Unit(decl.unitType) |
923 |
{ |
{ |
933 |
.ctx = decl.ctx, |
.ctx = decl.ctx, |
934 |
.isPolyphonic = true, |
.isPolyphonic = true, |
935 |
.isConst = decl.isConst, |
.isConst = decl.isConst, |
|
.isFinal = decl.isFinal, |
|
936 |
.elements = 1, |
.elements = 1, |
937 |
.memPos = 0, |
.memPos = 0, |
938 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
939 |
.unitType = decl.unitType |
.unitType = decl.unitType, |
940 |
|
.isFinal = decl.isFinal, |
941 |
}), |
}), |
942 |
Unit(decl.unitType) |
Unit(decl.unitType) |
943 |
{ |
{ |
953 |
.ctx = ctx, |
.ctx = ctx, |
954 |
.isPolyphonic = false, |
.isPolyphonic = false, |
955 |
.isConst = false, |
.isConst = false, |
|
.isFinal = false, |
|
956 |
.elements = 0, |
.elements = 0, |
957 |
.memPos = 0, |
.memPos = 0, |
958 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
959 |
.unitType = VM_NO_UNIT |
.unitType = VM_NO_UNIT, |
960 |
|
.isFinal = false, |
961 |
}) |
}) |
962 |
{ |
{ |
963 |
values.resize(size); |
values.resize(size); |
974 |
.ctx = ctx, |
.ctx = ctx, |
975 |
.isPolyphonic = false, |
.isPolyphonic = false, |
976 |
.isConst = _bConst, |
.isConst = _bConst, |
|
.isFinal = false, |
|
977 |
.elements = 0, |
.elements = 0, |
978 |
.memPos = 0, |
.memPos = 0, |
979 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
980 |
.unitType = VM_NO_UNIT |
.unitType = VM_NO_UNIT, |
981 |
|
.isFinal = false, |
982 |
}) |
}) |
983 |
{ |
{ |
984 |
this->values.resize(size); |
this->values.resize(size); |
997 |
.ctx = ctx, |
.ctx = ctx, |
998 |
.isPolyphonic = false, |
.isPolyphonic = false, |
999 |
.isConst = bConst, |
.isConst = bConst, |
|
.isFinal = false, |
|
1000 |
.elements = 0, |
.elements = 0, |
1001 |
.memPos = 0, |
.memPos = 0, |
1002 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
1003 |
.unitType = VM_NO_UNIT |
.unitType = VM_NO_UNIT, |
1004 |
|
.isFinal = false, |
1005 |
}) |
}) |
1006 |
{ |
{ |
1007 |
} |
} |
1034 |
printf("\n"); |
printf("\n"); |
1035 |
printIndents(level+1); |
printIndents(level+1); |
1036 |
} |
} |
1037 |
printf("%lld, ", values[i]); |
printf("%" PRId64 ", ", (int64_t)values[i]); |
1038 |
} |
} |
1039 |
printIndents(level); |
printIndents(level); |
1040 |
printf(")\n"); |
printf(")\n"); |
1045 |
.ctx = ctx, |
.ctx = ctx, |
1046 |
.isPolyphonic = false, |
.isPolyphonic = false, |
1047 |
.isConst = false, |
.isConst = false, |
|
.isFinal = false, |
|
1048 |
.elements = 0, |
.elements = 0, |
1049 |
.memPos = 0, |
.memPos = 0, |
1050 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
1051 |
.unitType = VM_NO_UNIT |
.unitType = VM_NO_UNIT, |
1052 |
|
.isFinal = false, |
1053 |
}) |
}) |
1054 |
{ |
{ |
1055 |
values.resize(size); |
values.resize(size); |
1066 |
.ctx = ctx, |
.ctx = ctx, |
1067 |
.isPolyphonic = false, |
.isPolyphonic = false, |
1068 |
.isConst = _bConst, |
.isConst = _bConst, |
|
.isFinal = false, |
|
1069 |
.elements = 0, |
.elements = 0, |
1070 |
.memPos = 0, |
.memPos = 0, |
1071 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
1072 |
.unitType = VM_NO_UNIT |
.unitType = VM_NO_UNIT, |
1073 |
|
.isFinal = false, |
1074 |
}) |
}) |
1075 |
{ |
{ |
1076 |
this->values.resize(size); |
this->values.resize(size); |
1089 |
.ctx = ctx, |
.ctx = ctx, |
1090 |
.isPolyphonic = false, |
.isPolyphonic = false, |
1091 |
.isConst = bConst, |
.isConst = bConst, |
|
.isFinal = false, |
|
1092 |
.elements = 0, |
.elements = 0, |
1093 |
.memPos = 0, |
.memPos = 0, |
1094 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
1095 |
.unitType = VM_NO_UNIT |
.unitType = VM_NO_UNIT, |
1096 |
|
.isFinal = false, |
1097 |
}) |
}) |
1098 |
{ |
{ |
1099 |
} |
} |
1158 |
.ctx = NULL, |
.ctx = NULL, |
1159 |
.isPolyphonic = (array) ? array->isPolyphonic() : false, |
.isPolyphonic = (array) ? array->isPolyphonic() : false, |
1160 |
.isConst = (array) ? array->isConstExpr() : false, |
.isConst = (array) ? array->isConstExpr() : false, |
|
.isFinal = false, |
|
1161 |
.elements = 0, |
.elements = 0, |
1162 |
.memPos = 0, |
.memPos = 0, |
1163 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
1164 |
.unitType = VM_NO_UNIT |
.unitType = VM_NO_UNIT, |
1165 |
|
.isFinal = false, |
1166 |
}), |
}), |
1167 |
Unit(VM_NO_UNIT), |
Unit(VM_NO_UNIT), |
1168 |
array(array), index(arrayIndex), currentIndex(-1) |
array(array), index(arrayIndex), currentIndex(-1) |
1169 |
{ |
{ |
1170 |
} |
} |
1171 |
|
|
1172 |
void IntArrayElement::assign(Expression* expr) { |
void IntArrayElement::assign(Expression* expr) { |
1209 |
.ctx = NULL, |
.ctx = NULL, |
1210 |
.isPolyphonic = (array) ? array->isPolyphonic() : false, |
.isPolyphonic = (array) ? array->isPolyphonic() : false, |
1211 |
.isConst = (array) ? array->isConstExpr() : false, |
.isConst = (array) ? array->isConstExpr() : false, |
|
.isFinal = false, |
|
1212 |
.elements = 0, |
.elements = 0, |
1213 |
.memPos = 0, |
.memPos = 0, |
1214 |
.unitFactorMemPos = 0, |
.unitFactorMemPos = 0, |
1215 |
.unitType = VM_NO_UNIT |
.unitType = VM_NO_UNIT, |
1216 |
|
.isFinal = false, |
1217 |
}), |
}), |
1218 |
Unit(VM_NO_UNIT), |
Unit(VM_NO_UNIT), |
1219 |
array(array), index(arrayIndex), currentIndex(-1) |
array(array), index(arrayIndex), currentIndex(-1) |
1267 |
StringVariable::StringVariable(ParserContext* ctx, bool bConst) : |
StringVariable::StringVariable(ParserContext* ctx, bool bConst) : |
1268 |
Variable({ |
Variable({ |
1269 |
.ctx = ctx, |
.ctx = ctx, |
1270 |
|
.isConst = bConst, |
1271 |
.memPos = 0, |
.memPos = 0, |
|
.isConst = bConst |
|
1272 |
}) |
}) |
1273 |
{ |
{ |
1274 |
} |
} |
1285 |
|
|
1286 |
void StringVariable::dump(int level) { |
void StringVariable::dump(int level) { |
1287 |
printIndents(level); |
printIndents(level); |
1288 |
printf("StringVariable memPos=%lld\n", memPos); |
printf("StringVariable memPos=%" PRId64 "\n", (int64_t)memPos); |
1289 |
} |
} |
1290 |
|
|
1291 |
ConstStringVariable::ConstStringVariable(ParserContext* ctx, String _value) |
ConstStringVariable::ConstStringVariable(ParserContext* ctx, String _value) |
1308 |
printf("ConstStringVariable val='%s'\n", value.c_str()); |
printf("ConstStringVariable val='%s'\n", value.c_str()); |
1309 |
} |
} |
1310 |
|
|
1311 |
bool ScalarNumberBinaryOp::isFinal() const { |
bool NumberBinaryOp::isFinal() const { |
1312 |
ScalarNumberExprRef l = (ScalarNumberExprRef) lhs; |
NumberExprRef l = (NumberExprRef) lhs; |
1313 |
ScalarNumberExprRef r = (ScalarNumberExprRef) rhs; |
NumberExprRef r = (NumberExprRef) rhs; |
1314 |
return l->isFinal() || r->isFinal(); |
return l->isFinal() || r->isFinal(); |
1315 |
} |
} |
1316 |
|
|
1355 |
printIndents(level); |
printIndents(level); |
1356 |
if (select) |
if (select) |
1357 |
if (select->isConstExpr()) |
if (select->isConstExpr()) |
1358 |
printf("Case select %lld\n", select->evalInt()); |
printf("Case select %" PRId64 "\n", (int64_t)select->evalInt()); |
1359 |
else |
else |
1360 |
printf("Case select [runtime expr]\n"); |
printf("Case select [runtime expr]\n"); |
1361 |
else |
else |
1365 |
CaseBranch& branch = branches[i]; |
CaseBranch& branch = branches[i]; |
1366 |
if (branch.from && branch.to) |
if (branch.from && branch.to) |
1367 |
if (branch.from->isConstExpr() && branch.to->isConstExpr()) |
if (branch.from->isConstExpr() && branch.to->isConstExpr()) |
1368 |
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()); |
1369 |
else if (branch.from->isConstExpr() && !branch.to->isConstExpr()) |
else if (branch.from->isConstExpr() && !branch.to->isConstExpr()) |
1370 |
printf("case %lld to [runtime expr]\n", branch.from->evalInt()); |
printf("case %" PRId64 " to [runtime expr]\n", (int64_t)branch.from->evalInt()); |
1371 |
else if (!branch.from->isConstExpr() && branch.to->isConstExpr()) |
else if (!branch.from->isConstExpr() && branch.to->isConstExpr()) |
1372 |
printf("case [runtime expr] to %lld\n", branch.to->evalInt()); |
printf("case [runtime expr] to %" PRId64 "\n", (int64_t)branch.to->evalInt()); |
1373 |
else |
else |
1374 |
printf("case [runtime expr] to [runtime expr]\n"); |
printf("case [runtime expr] to [runtime expr]\n"); |
1375 |
else if (branch.from) |
else if (branch.from) |
1376 |
if (branch.from->isConstExpr()) |
if (branch.from->isConstExpr()) |
1377 |
printf("case %lld\n", branch.from->evalInt()); |
printf("case %" PRId64 "\n", (int64_t)branch.from->evalInt()); |
1378 |
else |
else |
1379 |
printf("case [runtime expr]\n"); |
printf("case [runtime expr]\n"); |
1380 |
else |
else |
1413 |
printIndents(level); |
printIndents(level); |
1414 |
if (m_condition) |
if (m_condition) |
1415 |
if (m_condition->isConstExpr()) |
if (m_condition->isConstExpr()) |
1416 |
printf("while (%lld) {\n", m_condition->evalInt()); |
printf("while (%" PRId64 ") {\n", (int64_t)m_condition->evalInt()); |
1417 |
else |
else |
1418 |
printf("while ([runtime expr]) {\n"); |
printf("while ([runtime expr]) {\n"); |
1419 |
else |
else |
1880 |
.value = it->second |
.value = it->second |
1881 |
}); |
}); |
1882 |
vartable[it->first] = ref; |
vartable[it->first] = ref; |
1883 |
|
} |
1884 |
|
} |
1885 |
|
|
1886 |
|
void ParserContext::registerBuiltInConstRealVariables(const std::map<String,vmfloat>& vars) { |
1887 |
|
for (std::map<String,vmfloat>::const_iterator it = vars.begin(); |
1888 |
|
it != vars.end(); ++it) |
1889 |
|
{ |
1890 |
|
ConstRealVariableRef ref = new ConstRealVariable({ |
1891 |
|
.value = it->second |
1892 |
|
}); |
1893 |
|
vartable[it->first] = ref; |
1894 |
} |
} |
1895 |
} |
} |
1896 |
|
|