01: /**************************************************************************/
02: /* N I C E */
03: /* A high-level object-oriented research language */
04: /* (c) Daniel Bonniot 2000 */
05: /* */
06: /* This program is free software; you can redistribute it and/or modify */
07: /* it under the terms of the GNU General Public License as published by */
08: /* the Free Software Foundation; either version 2 of the License, or */
09: /* (at your option) any later version. */
10: /* */
11: /**************************************************************************/package nice.lang.inline;
12:
13: import gnu.bytecode.*;
14: import gnu.expr.*;
15:
16: /**
17: Utility functions for inlined operators.
18:
19: @version $Date: 2002/05/30 06:51:08 $
20: @author Daniel Bonniot
21: */
22:
23: class Tools {
24: static StackTarget intTarget = StackTarget.intTarget;
25:
26: static Type type(char typeChar) {
27: switch (typeChar) {
28: case 'z':
29: return Type.boolean_type;
30: case 'b':
31: return Type.byte_type;
32: case 's':
33: return Type.short_type;
34: case 'c':
35: return Type.char_type;
36: case 'i':
37: return Type.int_type;
38: case 'l':
39: return Type.long_type;
40: case 'f':
41: return Type.float_type;
42: case 'd':
43: return Type.double_type;
44: case 'o':
45: return Type.pointer_type;
46: default:
47: return null;
48: }
49: }
50:
51: static PrimType numericType(char typeChar) {
52: switch (typeChar) {
53: case 'i':
54: return Type.int_type;
55: case 'l':
56: return Type.long_type;
57: case 'f':
58: return Type.float_type;
59: case 'd':
60: return Type.double_type;
61: default:
62: return null;
63: }
64: }
65:
66: /**
67: Decides whether a type represents a stock array type.
68: This is especially useful to decide if an array instruction
69: can be used if the array is possibly polymorphic
70: (i.e. an array that might have primitive or reference elements).
71: Polymorphic array have the bytecode type java.lang.Object
72: and can only be manipulated using the methods in
73: java.lang.reflect.Array.
74: They are represented at compile time by a special instance of
75: nice.tools.code.SpecialArray, a subclass of gnu.bytecode.ArrayType.
76: */
77: static boolean monomorphicArray(Type type) {
78: return (type instanceof ArrayType)
79: && !type.getSignature().equals("Ljava/lang/Object;");
80: }
81: }
|