(ArgumentCounts counts)
| 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() { |
no test coverage detected