KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > expr > TypeValue


1 // Copyright (c) 2001, 2006 Per M.A. Bothner and Brainfood Inc.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.expr;
5 import gnu.bytecode.*;
6 import gnu.mapping.Procedure;
7
8 /** A Type or a Type expression.
9  * Can be used for higher-level types that do not map directly to a Type.
10  */

11
12 public interface TypeValue
13 {
14   /** The lower-level Type used to represent instances of this type. */
15   public Type getImplementationType();
16
17   /** Emit code for
18    * <tt>if (incoming instanceof this_type) decl = incoming ...</tt>.
19    * This method is designed for <tt>typeswitch</tt> applications, where this
20    * call is the first part of a conditional, so it must be followed
21    * by calls to <tt>emitElse</tt> and <tt>emitFi</tt>.
22    * @param incoming Contains the value we are testing to see if it has the
23    * type of <tt>this</tt>. If null, use top-of-stack.
24    * May not be null if incoming is non-null.
25    * @param decl If non-null, assign value after coercion to <tt>Declaration</tt>.
26    * @param comp The compilation state.
27    */

28   public void emitTestIf(Variable incoming, Declaration decl,
29              Compilation comp);
30
31   /** Emit code for <tt>incoming instanceof this_type</tt>.
32    * The implementation can use
33    * {@link gnu.kawa.reflect.InstanceOf#emitIsInstance InstanceOf
34    * .emitIsInstance} which is a conveniece method that calls
35    * {@link #emitTestIf emitTestIf}.
36    * @param incoming Contains the value we are testing to see if it has the
37    * the type of 'this'. If null, use top-of-stack.
38    * @param comp The compilation state.
39    * @param target Where to leave the result.
40    */

41   public void emitIsInstance(Variable incoming,
42                  Compilation comp, Target target);
43
44   /** Get the constructor function for this type.
45    * Returns null if there is no contructor function.
46    * Also returns null if this extends ClassType or ArrayType and
47    * standard Java constructors (<init> methods) should be used.
48    */

49   public Procedure getConstructor ();
50 }
51
Popular Tags