comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ArithmeticNode.java @ 8254:ac2204c05a02

UseSpecializations is now turned off for the generic specialization in WriteLocalNode.
author Christian Humer <christian.humer@gmail.com>
date Wed, 13 Mar 2013 20:00:16 +0100
parents 5b08b0f4d338
children aa9ffb3a715e
comparison
equal deleted inserted replaced
8253:4c0d72c98797 8254:ac2204c05a02
64 64
65 @Specialization(guards = "isString") 65 @Specialization(guards = "isString")
66 String add(Object left, Object right) { 66 String add(Object left, Object right) {
67 return left.toString() + right.toString(); 67 return left.toString() + right.toString();
68 } 68 }
69
70 @Generic
71 public Object addGeneric(Object left, Object right) {
72 throw new RuntimeException("Arithmetic not defined for types " + left.getClass().getSimpleName() + ", " + right.getClass().getSimpleName());
73 }
74 } 69 }
75 70
76 public abstract static class SubNode extends ArithmeticNode { 71 public abstract static class SubNode extends ArithmeticNode {
77 72
78 public SubNode(TypedNode left, TypedNode right) { 73 public SubNode(TypedNode left, TypedNode right) {
91 @Specialization 86 @Specialization
92 BigInteger sub(BigInteger left, BigInteger right) { 87 BigInteger sub(BigInteger left, BigInteger right) {
93 return left.subtract(right); 88 return left.subtract(right);
94 } 89 }
95 90
96 @Generic
97 public Object sub(Object left, Object right) {
98 throw new RuntimeException("Arithmetic not defined for types " + left.getClass().getSimpleName() + ", " + right.getClass().getSimpleName());
99 }
100 } 91 }
101 92
102 public abstract static class DivNode extends ArithmeticNode { 93 public abstract static class DivNode extends ArithmeticNode {
103 94
104 public DivNode(TypedNode left, TypedNode right) { 95 public DivNode(TypedNode left, TypedNode right) {
115 } 106 }
116 107
117 @Specialization 108 @Specialization
118 BigInteger div(BigInteger left, BigInteger right) { 109 BigInteger div(BigInteger left, BigInteger right) {
119 return left.divide(right); 110 return left.divide(right);
120 }
121
122 @Generic
123 public Object div(Object left, Object right) {
124 throw new RuntimeException("Arithmetic not defined for types " + left.getClass().getSimpleName() + ", " + right.getClass().getSimpleName());
125 } 111 }
126 } 112 }
127 113
128 public abstract static class MulNode extends ArithmeticNode { 114 public abstract static class MulNode extends ArithmeticNode {
129 115
143 @Specialization 129 @Specialization
144 BigInteger mul(BigInteger left, BigInteger right) { 130 BigInteger mul(BigInteger left, BigInteger right) {
145 return left.multiply(right); 131 return left.multiply(right);
146 } 132 }
147 133
148 @Generic
149 public Object mul(Object left, Object right) {
150 throw new RuntimeException("Arithmetic not defined for types " + left.getClass().getSimpleName() + ", " + right.getClass().getSimpleName());
151 }
152 } 134 }
153 135
154 } 136 }