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

Method xmeet

chapter22/src/main/java/com/seaofnodes/simple/type/Type.java:156–173  ·  view source on GitHub ↗
(Type t)

Source from the content-addressed store, hash-verified

154 // Handle cases where 'this.is_simple()' and unequal to 't'.
155 // Subclassed xmeet calls can assert that '!t.is_simple()'.
156 Type xmeet(Type t) {
157 assert is_simple(); // Should be overridden in subclass
158 // ANY meet anything is thing; thing meet ALL is ALL
159 if( _type==TBOT || t._type==TTOP ) return this;
160 if( _type==TTOP || t._type==TBOT ) return t;
161
162 // RHS TypeNil vs NIL/XNIL
163 if( _type== TNIL ) return t instanceof TypeNil ptr ? ptr.meet0() : (t._type==TXNIL ? TypePtr.PTR : BOTTOM);
164 if( _type== TXNIL ) return t instanceof TypeNil ptr ? ptr.meetX() : (t._type== TNIL ? TypePtr.PTR : BOTTOM);
165
166 // 'this' is only {TCTRL,TXCTRL}
167 // Other non-simple RHS things bottom out
168 if( !t.is_simple() ) return BOTTOM;
169 // If RHS is NIL/XNIL
170 if( t._type==TNIL || t._type==TXNIL ) return BOTTOM;
171 // Both are {TCTRL,TXCTRL} and unequal to each other
172 return _type==TCTRL || t._type==TCTRL ? CONTROL : XCONTROL;
173 }
174
175 public Type dual() {
176 return switch( _type ) {

Callers 1

meetMethod · 0.95

Calls 3

is_simpleMethod · 0.95
meet0Method · 0.45
meetXMethod · 0.45

Tested by

no test coverage detected