Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeSystem.java @ 19510:1cde96b96673
Fixed code format issues.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 19 Feb 2015 16:15:56 +0100 |
parents | f57d86eb036f |
children |
comparison
equal
deleted
inserted
replaced
19508:8c7536965c95 | 19510:1cde96b96673 |
---|---|
35 * a single {@link Node} hierarchy. A {@link TypeSystem} defines a list of types as its child | 35 * a single {@link Node} hierarchy. A {@link TypeSystem} defines a list of types as its child |
36 * elements, in which every type precedes its super types.The latter condition ensures that the most | 36 * elements, in which every type precedes its super types.The latter condition ensures that the most |
37 * concrete type is found first when searching the list sequentially for the type of a given generic | 37 * concrete type is found first when searching the list sequentially for the type of a given generic |
38 * value. | 38 * value. |
39 * </p> | 39 * </p> |
40 * | 40 * |
41 * <p> | 41 * <p> |
42 * Each {@link #value()} is represented as a java type. A type can specify two annotations: | 42 * Each {@link #value()} is represented as a java type. A type can specify two annotations: |
43 * {@link TypeCheck} and {@link TypeCast}. The {@link TypeCheck} checks whether a given generic | 43 * {@link TypeCheck} and {@link TypeCast}. The {@link TypeCheck} checks whether a given generic |
44 * value matches to the current type. The {@link TypeCast} casts a generic type value to the current | 44 * value matches to the current type. The {@link TypeCast} casts a generic type value to the current |
45 * type. If the {@link TypeCheck} and {@link TypeCast} annotations are not declared in the | 45 * type. If the {@link TypeCheck} and {@link TypeCast} annotations are not declared in the |
49 * used to extend the definition of a type in the language. In our example, the | 49 * used to extend the definition of a type in the language. In our example, the |
50 * <code>isInteger</code> and <code>asInteger</code> methods are defined in a way so that they | 50 * <code>isInteger</code> and <code>asInteger</code> methods are defined in a way so that they |
51 * accept also {@link Integer} values, implicitly converting them to {@link Double} . This example | 51 * accept also {@link Integer} values, implicitly converting them to {@link Double} . This example |
52 * points out how we express implicit type conversions. | 52 * points out how we express implicit type conversions. |
53 * </p> | 53 * </p> |
54 * | 54 * |
55 * <p> | 55 * <p> |
56 * <b>Example:</b> The {@link TypeSystem} contains the types {@link Boolean}, {@link Integer}, and | 56 * <b>Example:</b> The {@link TypeSystem} contains the types {@link Boolean}, {@link Integer}, and |
57 * {@link Double}. The type {@link Object} is always used implicitly as the generic type represent | 57 * {@link Double}. The type {@link Object} is always used implicitly as the generic type represent |
58 * all values. | 58 * all values. |
59 * | 59 * |
60 * <pre> | 60 * <pre> |
61 * | 61 * |
62 * {@literal @}TypeSystem(types = {boolean.class, int.class, double.class}) | 62 * {@literal @}TypeSystem(types = {boolean.class, int.class, double.class}) |
63 * public abstract class ExampleTypeSystem { | 63 * public abstract class ExampleTypeSystem { |
64 * | 64 * |
65 * {@literal @}TypeCheck | 65 * {@literal @}TypeCheck |
66 * public boolean isInteger(Object value) { | 66 * public boolean isInteger(Object value) { |
67 * return value instanceof Integer || value instanceof Double; | 67 * return value instanceof Integer || value instanceof Double; |
68 * } | 68 * } |
69 * | 69 * |
70 * {@literal @}TypeCast | 70 * {@literal @}TypeCast |
71 * public double asInteger(Object value) { | 71 * public double asInteger(Object value) { |
72 * return ((Number)value).doubleValue(); | 72 * return ((Number)value).doubleValue(); |
73 * } | 73 * } |
74 * } | 74 * } |
75 * </pre> | 75 * </pre> |
76 * | 76 * |
77 * | 77 * |
78 * @see TypeCast | 78 * @see TypeCast |
79 * @see TypeCheck | 79 * @see TypeCheck |
80 */ | 80 */ |
81 @Retention(RetentionPolicy.CLASS) | 81 @Retention(RetentionPolicy.CLASS) |
82 @Target({ElementType.TYPE}) | 82 @Target({ElementType.TYPE}) |