comparison graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeCast.java @ 18782:3ea386a1036f

Truffle-DSL: breaking: @TypeCheck and @TypeCast now require casted/checked type as explicit parameter. Previously the type was parsed from the method name. (GRAAL-446 #resolve)
author Christian Humer <christian.humer@gmail.com>
date Mon, 05 Jan 2015 20:23:22 +0100
parents 494b818b527c
children
comparison
equal deleted inserted replaced
18781:941761f6b736 18782:3ea386a1036f
24 */ 24 */
25 package com.oracle.truffle.api.dsl; 25 package com.oracle.truffle.api.dsl;
26 26
27 import java.lang.annotation.*; 27 import java.lang.annotation.*;
28 28
29 /**
30 * Overrides the standard way of casting a certain type in a {@link TypeSystem}. This is useful for
31 * types where the guest language specific type cast can be implemented more efficiently than an
32 * instanceof check. The annotated method must be contained in a {@link TypeSystem} annotated class.
33 * Type checks must conform to the following signature: <code>public static Type as{TypeName}(Object
34 * value)</code>. The casted type must be a type declared in the {@link TypeSystem}.
35 *
36 * <p>
37 * If no {@link TypeCast} is declared then the type system implicitly uses a type cast that can be
38 * declared as follows:
39 *
40 * <pre>
41 * {@literal @}TypeCast(Type.class)
42 * public static Type asType(Object value) {
43 * return (Type) value;
44 * }
45 * </pre>
46 *
47 * @see TypeCheck
48 */
29 @Retention(RetentionPolicy.CLASS) 49 @Retention(RetentionPolicy.CLASS)
30 @Target({ElementType.METHOD}) 50 @Target({ElementType.METHOD})
31 public @interface TypeCast { 51 public @interface TypeCast {
32 52
53 Class<?> value();
54
33 } 55 }