1 package gnu.expr; 2 import gnu.bytecode.*; 3 4 5 6 public class Literal 7 { 8 Literal next; 9 10 public Field field; 11 12 Object value; 13 14 17 int index; 18 19 public Type type; 20 21 public int flags; 22 23 24 static final int WRITING = 1; 25 26 27 static final int WRITTEN = 2; 28 29 static final int CYCLIC = 4; 30 31 32 static final int EMITTED = 8; 33 34 35 Object [] argValues; 36 37 Type[] argTypes; 38 39 public static final Literal nullLiteral 40 = new Literal(null, Type.nullType); 41 42 public final Object getValue() { return value; } 43 44 void assign (LitTable litTable) 45 { 46 assign((String ) null, litTable); 47 } 48 49 51 void assign (String name, LitTable litTable) 52 { 53 int flags = litTable.comp.immediate ? Access.STATIC|Access.PUBLIC 54 : Access.STATIC|Access.FINAL; 55 if (name == null) 56 { 57 index = litTable.literalsCount++; 58 name = "Lit" + index; 59 } 60 else 61 flags |= Access.PUBLIC; 62 assign(litTable.mainClass.addField (name, type, flags), litTable); 63 } 64 65 void assign (Field field, LitTable litTable) 66 { 67 next = litTable.literalsChain; 68 litTable.literalsChain = this; 69 this.field = field; 70 } 71 72 73 public Literal (Object value, LitTable litTable) 74 { 75 this (value, (String ) null, litTable); 76 } 77 78 public Literal (Object value, String name, LitTable litTable) 79 { 80 this.value = value; 81 litTable.literalTable.put (value, this); 82 this.type = Type.make(value.getClass()); 83 assign(name, litTable); 84 } 85 86 88 public Literal (Object value, Field field, LitTable litTable) 89 { 90 this.value = value; 91 litTable.literalTable.put(value, this); 92 this.field = field; 93 this.type = field.getType(); 94 flags = WRITTEN|EMITTED; 95 } 96 97 public Literal (Object value, Type type, LitTable litTable) 98 { 99 this.value = value; 100 litTable.literalTable.put (value, this); 101 this.type = type; 102 } 103 104 Literal (Object value, Type type) 105 { 106 this.value = value; 107 this.type = type; 108 } 109 } 110 111 | Popular Tags |