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

Method intern

chapter23/src/main/java/com/seaofnodes/simple/type/Type.java:137–168  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

135
136 // Factory method which interns "this"
137 @SuppressWarnings("unchecked")
138 <T extends Type> T intern() {
139 //assert check();
140 assert !_terned; // Do not ask for already-interned
141 T t2 = (T)INTERN.get(this);
142 if( t2!=null ) {
143 assert t2._dual != null; // Prior is complete with dual
144 assert this != t2; // Do not hashcons twice, should not get self back
145 return t2; // Return prior
146 }
147 // Mid recursive type construction
148 if( !VISIT.isEmpty() && _type >= TCYCLIC ) {
149 // No intern attempt at all
150 return (T)this;
151 }
152 // Not in type table
153 _dual = null; // No dual yet
154 INTERN.put(this,this); // Put in table without dual
155 _terned = true;
156 //Util.hash_quality_check_per(INTERN,"INTERN");
157 T d = xdual(); // Compute dual without requiring table lookup, and not setting name
158 _dual = d;
159 if( this==d ) return d; // Self-symmetric? Dual is self
160 assert !equals(d); // Self-symmetric is handled by caller
161 assert d._dual==null; // Else dual-dual not computed yet
162 assert INTERN.get(d)==null;
163 d._dual = (T)this;
164 INTERN.put(d,d); // Install dual also
165 d._terned = true;
166 //assert check();
167 return (T)this;
168 }
169
170 // Recursive visit elsewhere, interns with dual already
171 <T extends Type> T _intern() {

Callers 15

memNameMethod · 0.45
requireIdMethod · 0.45
makeMethod · 0.45
makeMethod · 0.45
TypeTupleClass · 0.45
makeMethod · 0.45
makeMethod · 0.45
makeMethod · 0.45
makeMethod · 0.45
TypeConAryClass · 0.45
makeMethod · 0.45
makeMethod · 0.45

Calls 5

xdualMethod · 0.95
equalsMethod · 0.95
getMethod · 0.45
isEmptyMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected