Mercurial > hg > truffle
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLTypes.java @ 12396:3faec5ab0696
SL: updated simple lanugage type system to use an implicit cast.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 11 Oct 2013 20:06:33 +0200 |
parents | f1c3f50ac36e |
children | 71991b7a0f14 |
comparison
equal
deleted
inserted
replaced
12395:8e8347ecabbc | 12396:3faec5ab0696 |
---|---|
44 assert BigInteger.valueOf(result).equals(value) : "Losing precision"; | 44 assert BigInteger.valueOf(result).equals(value) : "Losing precision"; |
45 return result; | 45 return result; |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 @TypeCheck | 49 @ImplicitCast |
50 public boolean isBigInteger(Object value) { | 50 public BigInteger castBigInteger(int integer) { |
51 return value instanceof Integer || value instanceof BigInteger; | 51 return BigInteger.valueOf(integer); |
52 } | 52 } |
53 | 53 |
54 @TypeCast | |
55 public BigInteger asBigInteger(Object value) { | |
56 if (value instanceof Integer) { | |
57 return BigInteger.valueOf((int) value); | |
58 } else { | |
59 return (BigInteger) value; | |
60 } | |
61 } | |
62 | |
63 @TypeCast | |
64 public BigInteger asBigInteger(int value) { | |
65 return BigInteger.valueOf(value); | |
66 } | |
67 | |
68 @TypeCheck | |
69 public boolean isBigInteger(@SuppressWarnings("unused") int value) { | |
70 return true; | |
71 } | |
72 | |
73 @ImplicitCast | |
74 public BigInteger castBigInteger(int value) { | |
75 return BigInteger.valueOf(value); | |
76 } | |
77 } | 54 } |