01: // Copyright (c) 2001, 2006 Per M.A. Bothner and Brainfood Inc.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.expr;
05:
06: import gnu.bytecode.*;
07: import gnu.mapping.Procedure;
08:
09: /** A Type or a Type expression.
10: * Can be used for higher-level types that do not map directly to a Type.
11: */
12:
13: public interface TypeValue {
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, Compilation comp,
42: 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: }
|