MCPcopy Create free account
hub / github.com/BuildCraft/BuildCraft / castTo

Method castTo

common/buildcraft/lib/expression/api/Arguments.java:37–58  ·  view source on GitHub ↗
(ArgumentCounts counts)

Source from the content-addressed store, hash-verified

35 }
36
37 public Arguments castTo(ArgumentCounts counts) throws InvalidExpressionException {
38 li = di = bi = si = 0;
39 Arguments to = counts.createArgs();
40 for (int i = 0; i < counts.order.size(); i++) {
41 ArgType oldType = this.counts.order.get(i);
42 ArgType newType = counts.order.get(i);
43 IExpressionNode node;
44 if (oldType == ArgType.LONG) node = longs[li++];
45 else if (oldType == ArgType.DOUBLE) node = doubles[di++];
46 else if (oldType == ArgType.BOOL) node = bools[bi++];
47 else/* if (old == ArgType.STRING) */ node = strings[si++];
48 if (newType == ArgType.STRING) {
49 node = NodeCasting.castToString(node);
50 } else if (newType == ArgType.DOUBLE) {
51 node = NodeCasting.castToDouble(node);
52 } else if (newType != oldType) {
53 throw new InvalidExpressionException("Cannot cast from " + oldType + " to " + newType);
54 }
55 to.appendNode(node);
56 }
57 return to;
58 }
59
60 @Override
61 public String toString() {

Callers 1

pushFunctionNodeMethod · 0.95

Calls 6

castToStringMethod · 0.95
castToDoubleMethod · 0.95
appendNodeMethod · 0.95
createArgsMethod · 0.80
getMethod · 0.65
sizeMethod · 0.45

Tested by

no test coverage detected