comparison graal/com.oracle.truffle.api.codegen/src/com/oracle/truffle/api/codegen/TypeSystem.java @ 7530:5e3d1a68664e

applied mx eclipseformat to all Java files
author Doug Simon <doug.simon@oracle.com>
date Wed, 23 Jan 2013 16:34:57 +0100
parents 2232848be438
children 33e08aca06ff
comparison
equal deleted inserted replaced
7529:4a11124a3563 7530:5e3d1a68664e
24 24
25 import java.lang.annotation.*; 25 import java.lang.annotation.*;
26 26
27 /** 27 /**
28 * <p> 28 * <p>
29 * Annotates a type system class that represents type information for a node. Generates code for converting and managing 29 * Annotates a type system class that represents type information for a node. Generates code for
30 * types. Methods contained in the type system may be annotated with {@link TypeCast}, {@link TypeCheck} or 30 * converting and managing types. Methods contained in the type system may be annotated with
31 * {@link GuardCheck}. These methods alter the default behavior of the type system. 31 * {@link TypeCast}, {@link TypeCheck} or {@link GuardCheck}. These methods alter the default
32 * behavior of the type system.
32 * </p> 33 * </p>
33 * 34 *
34 * 35 *
35 * <b>Example:</b> 36 * <b>Example:</b>
36 * <p> 37 * <p>
37 * Shows a <code>@TypeSystem</code> definition with three types. In this example BigIntegers can be also treated as 38 * Shows a <code>@TypeSystem</code> definition with three types. In this example BigIntegers can be
38 * integers if their bit width is less than 32. 39 * also treated as integers if their bit width is less than 32.
39 * </p> 40 * </p>
40 * 41 *
41 * <pre> 42 * <pre>
42 * 43 *
43 * {@literal @}TypeSystem(types = {int.class, BigInteger.class, String.class}, nodeBaseClass = TypedNode.class) 44 * {@literal @}TypeSystem(types = {int.class, BigInteger.class, String.class}, nodeBaseClass = TypedNode.class)
44 * public abstract class Types { 45 * public abstract class Types {
45 * 46 *
46 * {@literal @}TypeCheck 47 * {@literal @}TypeCheck
47 * public boolean isInteger(Object value) { 48 * public boolean isInteger(Object value) {
48 * return value instanceof Integer || (value instanceof BigInteger &amp;&amp; ((BigInteger) value).bitLength() &lt; Integer.SIZE); 49 * return value instanceof Integer || (value instanceof BigInteger &amp;&amp; ((BigInteger) value).bitLength() &lt; Integer.SIZE);
49 * } 50 * }
50 * 51 *
51 * {@literal @}TypeCast 52 * {@literal @}TypeCast
52 * public int asInteger(Object value) { 53 * public int asInteger(Object value) {
53 * if (value instanceof Integer) { 54 * if (value instanceof Integer) {
54 * return (int) value; 55 * return (int) value;
55 * } else { 56 * } else {
56 * return ((BigInteger) value).intValue(); 57 * return ((BigInteger) value).intValue();
57 * } 58 * }
58 * } 59 * }
59 * } 60 * }
60 * </pre> 61 * </pre>
61 * 62 *
62 * @see TypeCast 63 * @see TypeCast
63 * @see TypeCheck 64 * @see TypeCheck
64 * @see GuardCheck 65 * @see GuardCheck
65 */ 66 */
66 @Retention(RetentionPolicy.CLASS) 67 @Retention(RetentionPolicy.CLASS)
67 @Target({ElementType.TYPE}) 68 @Target({ElementType.TYPE})
68 public @interface TypeSystem { 69 public @interface TypeSystem {
69 70
70 /** 71 /**
71 * Sets the types contained by this type system. The order of types also determines the order of specialization. 72 * Sets the types contained by this type system. The order of types also determines the order of
73 * specialization.
72 */ 74 */
73 Class[] value(); 75 Class[] value();
74 76
75 } 77 }