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 |
} |
} |
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 |
{ |
{ |
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) |
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 |
} |
} |
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 |
} |
} |
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 |
|
|