- Expanded BuildCraft support to 1.7.2 and 1.6.4

- Fixed string + formatted string not being added properly
This commit is contained in:
Stan Hebben committed 2014-10-08 20:45:09 +02:00
1 parent a8aae17d8a
commit f5e467e9a4
20 files changed
+1930 -15

No files matched your search

@@ -107,7 +107,7 @@ public class TypeExpansion {
switch (operatorAnnotation.value()) {
case NEG:
case NOT:
if (method.getParameterTypes().length != 0) {
if (method.getParameterTypes().length != 1) {
// TODO: error
} else {
unaryOperators.add(new ZenNativeOperator(
@@ -128,8 +128,12 @@ public class TypeExpansion {
case RANGE:
case CONTAINS:
case COMPARE:
if (method.getParameterTypes().length != 1) {
// TODO: error
if (method.getParameterTypes().length != 2) {
throw new RuntimeException(
"Binary operator expansion needs a static method with 2 arguments - "
+ cls.getName()
+ "."
+ method.getName());
} else {
binaryOperators.add(new ZenNativeOperator(
operatorAnnotation.value(),
@@ -137,7 +141,7 @@ public class TypeExpansion {
}
break;
case INDEXSET:
if (method.getParameterTypes().length != 2) {
if (method.getParameterTypes().length != 3) {
// TODO: error
} else {
trinaryOperators.add(new ZenNativeOperator(
@@ -207,10 +207,20 @@ public class ZenTypeString extends ZenType {
((ExpressionStringConcat) left).add(right.cast(position, environment, this));
return left;
} else {
List<Expression> values = new ArrayList<Expression>();
values.add(left);
values.add(right.cast(position, environment, this));
return new ExpressionStringConcat(position, values);
if (right.getType().canCastImplicit(STRING, environment)) {
List<Expression> values = new ArrayList<Expression>();
values.add(left);
values.add(right.cast(position, environment, this));
return new ExpressionStringConcat(position, values);
} else {
Expression expanded = this.binaryExpansion(position, environment, left, right, operator);
if (expanded == null) {
environment.error(position, "cannot add " + right.getType().getName() + " to a string");
return new ExpressionInvalid(position, this);
} else {
return expanded;
}
}
}
} else if (operator == OperatorType.INDEXGET) {
return new ExpressionStringIndex(position, left, right.cast(position, environment, INT));