MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / Type

Class Type

chapter20/src/main/java/com/seaofnodes/simple/type/Type.java:24–235  ·  view source on GitHub ↗

These types are part of a Monotone Analysis Framework, @see see for example this set of slides . The types form a lattice; @see a symmetric comple

Source from the content-addressed store, hash-verified

22 */
23
24public class Type {
25 static final HashMap<Type,Type> INTERN = new HashMap<>();
26
27 // ----------------------------------------------------------
28 // Simple types are implemented fully here. "Simple" means: the code and
29 // type hierarchy are simple, not that the Type is conceptually simple.
30 static final byte TBOT = 0; // Bottom (ALL)
31 static final byte TTOP = 1; // Top (ANY)
32 static final byte TCTRL = 2; // Ctrl flow bottom
33 static final byte TXCTRL = 3; // Ctrl flow top (mini-lattice: any-xctrl-ctrl-all)
34 static final byte TNIL = 4; // low null of all flavors
35 static final byte TXNIL = 5; // high or choice null
36 static final byte TSIMPLE = 6; // End of the Simple Types
37
38 static final byte TPTR = 7; // All nil-able scalar values
39 static final byte TINT = 8; // All Integers; see TypeInteger
40 static final byte TFLT = 9; // All Floats ; see TypeFloat
41 static final byte TMEMPTR =10; // Memory pointer to a struct type
42 static final byte TFUNPTR =11; // Function pointer; unique signature and code address (just a bit)
43 static final byte TTUPLE =12; // Tuples; finite collections of unrelated Types, kept in parallel
44 static final byte TMEM =13; // All memory (alias 0) or A slice of memory - with specific alias
45 static final byte TSTRUCT =14; // Structs; tuples with named fields
46 static final byte TFLD =15; // Named fields in structs
47 static final byte TRPC =16; // Return Program Control (Return PC or RPC)
48
49 public final byte _type;
50
51 public boolean is_simple() { return _type < TSIMPLE; }
52 private static final String[] STRS = new String[]{"Bot","Top","Ctrl","~Ctrl","null","~nil"};
53 protected Type(byte type) { _type = type; }
54
55 public static final Type BOTTOM = new Type( TBOT ).intern(); // ALL
56 public static final Type TOP = new Type( TTOP ).intern(); // ANY
57 public static final Type CONTROL = new Type( TCTRL ).intern(); // Ctrl
58 public static final Type XCONTROL = new Type( TXCTRL ).intern(); // ~Ctrl
59 public static final Type NIL = new Type( TNIL ).intern(); // low null of all flavors
60 public static final Type XNIL = new Type( TXNIL ).intern(); // high or choice null
61 public static Type[] gather() {
62 ArrayList<Type> ts = new ArrayList<>();
63 ts.add(BOTTOM);
64 ts.add(CONTROL);
65 ts.add(NIL);
66 ts.add(XNIL);
67 TypeNil.gather(ts);
68 TypePtr.gather(ts);
69 TypeInteger.gather(ts);
70 TypeFloat.gather(ts);
71 TypeMemPtr.gather(ts);
72 TypeFunPtr.gather(ts);
73 TypeMem.gather(ts);
74 Field.gather(ts);
75 TypeStruct.gather(ts);
76 TypeTuple.gather(ts);
77 TypeRPC.gather(ts);
78 int sz = ts.size();
79 for( int i = 0; i < sz; i++ )
80 ts.add(ts.get(i).dual());
81 return ts.toArray(new Type[ts.size()]);

Callers

nothing calls this directly

Calls 1

internMethod · 0.45

Tested by

no test coverage detected