aa
TestApprox.java
Go to the documentation of this file.
1 package com.cliffc.aa.type;
2 
3 import com.cliffc.aa.Env;
4 import org.junit.Test;
5 
6 import java.util.HashMap;
7 
8 import static org.junit.Assert.*;
9 
10 
11 public class TestApprox {
12  // temp/junk holder for "instant" junits, when debugged moved into other tests
13  @Test public void testType() {
14  }
15 
16  // Check TypeStruct.meet for a more complex recursive case
17  @Test public void testTSMeet() {
18  Object dummy0 = TypeStruct.TYPES;
19  Object dummy1 = TypeMemPtr.TYPES;
20  int alias0 = BitsAlias.new_alias(BitsAlias.REC);
21 
22  // Build two structs pointing to each other.
23  // -> [,int] -> * -> [,flt] -> * ->
24  TypeFld fbint = TypeFld.make("b",TypeInt.INT64,1);
25  TypeFld fbflt = TypeFld.make("b",TypeFlt.FLT64,1);
27  TypeFld[] flds0 = TypeFlds.ts(TypeFld.malloc("a",null,0), fbint);
28  TypeFld[] flds1 = TypeFlds.ts(TypeFld.malloc("a",null,0), fbflt);
29  TypeStruct t0 = TypeStruct.malloc("",false,flds0,true);
30  TypeStruct t1 = TypeStruct.malloc("",false,flds1,true);
31  t0._hash = t0.compute_hash(); t0._cyclic = true;
32  t1._hash = t1.compute_hash(); t1._cyclic = true;
33  TypeMemPtr p0 = TypeMemPtr.make(alias0,t0);
34  TypeMemPtr p1 = TypeMemPtr.make(alias0,t1);
35  t0.fld(0).setX(p1 );
36  t1.fld(0).setX(p0 );
38  t0 = t0.install_cyclic(t0.reachable());
39 
40  // Meet them
41  TypeStruct mt = (TypeStruct)t0.meet(t1);
42 
43  // End result should be a cycle of length 1: [,real] -> * ->
44  // And NOT: [,real] -> * -> [,real] -> * ->
45  assertEquals(Type.REAL,mt.at(1));
46  TypeMemPtr pmt = (TypeMemPtr)mt.at(0);
47  assertSame(mt,pmt._obj);
48  TypeStruct head = mt.repeats_in_cycles();
49  assertNull(head);
50  }
51 
52  // Test approximating infinite recursive types. Most simple test case: a
53  // single linked-list chain of depth == CUTOFF.
54  @Test public void testApprox1() {
55  final int CUTOFF = 3;
56  int alias0 = BitsAlias.new_alias(BitsAlias.REC);
57 
58  // Build a depth-CUTOFF linked list chain
60  TypeFld.make("b",TypeInt.con(99),1));
61  TypeMemPtr p0 = TypeMemPtr.make(alias0,t0);
62  HashMap<Type,Integer> ds = p0.depth();
63  assertEquals(0,(int)ds.get(t0));
64 
65  TypeStruct t1 = TypeStruct.make(TypeFld.make("a",p0,0), TypeFld.make("b",TypeInt.con(98),1));
66  TypeMemPtr p1 = TypeMemPtr.make(alias0,t1);
67  ds = p1.depth();
68  assertEquals(1,(int)ds.get(t0));
69  assertEquals(0,(int)ds.get(t1));
70  assertEquals(0,(int)ds.get(p0));
71 
72  TypeStruct t2 = TypeStruct.make(TypeFld.make("a",p1,0), TypeFld.make("b",TypeInt.con(97),1));
73  TypeMemPtr p2 = TypeMemPtr.make(alias0,t2);
74  ds = p2.depth();
75  assertEquals(2,(int)ds.get(t0));
76 
77  TypeStruct t3 = TypeStruct.make(TypeFld.make("a",p2,0), TypeFld.make("b",TypeInt.con(96),1));
78  TypeMemPtr p3 = TypeMemPtr.make(alias0,t3);
79  ds = p3.depth();
80  assertEquals(CUTOFF ,(int)ds.get(t0));
81  assertEquals(CUTOFF-1,(int)ds.get(t1));
82  assertEquals(1,(int)ds.get(t2));
83  assertEquals(0,(int)ds.get(t3));
84  // No single depth is beyond cutoff
85  assertEquals(CUTOFF,TypeMemPtr.max(alias0,ds));
86 
87  // For all TypeStruct X at depth CUTOFF-1, make a clone of X and X's sub-
88  // graph, except every edge to a type at depth CUTOFF is replaced with the
89  // X clone.
90 
91  // original, too deep
92  // t3[,99] -> p2 -> t2[,99] -> p1 -> t1[,flt] -> p0 -> t0[,int] -> nil
93 
94  // replace ptrs to t0 with ptrs to t1
95  // t3[,99] -> p2 -> t2[,99] -> p1 -> t1[,flt] -> p0 -> t1*
96 
97  // collapse redundant ptrs to t1, and MEET t0-tail and t1-tail
98  // t3[,99] -> p2 -> t2[,99] -> {p0,p1} -> t1[,{flt&int}] -> {p0,p1}
99 
100  TypeStruct tax = t3.approx(CUTOFF,alias0);
101  TypeMemPtr pax = TypeMemPtr.make(alias0,tax);
102  HashMap<Type,Integer> ds2 = pax.depth();
103  assertEquals(CUTOFF,TypeMemPtr.max(alias0,ds2));
104  TypeMemPtr txp1 = (TypeMemPtr)tax.at(0);
105  assertEquals(0,(int)ds2.get(txp1));
106  TypeStruct txs1 = (TypeStruct)txp1._obj;
107  assertEquals(1,(int)ds2.get(txs1));
108  TypeMemPtr txp2 = (TypeMemPtr)txs1.at(0);
109  assertEquals(1,(int)ds2.get(txp2));
110  TypeStruct txs2 = (TypeStruct)txp2._obj;
111  assertEquals(2,(int)ds2.get(txs2));
112  assertEquals(TypeInt.NINT8,txs2.at(1));
113  TypeMemPtr txp3 = (TypeMemPtr)txs2.at(0);
114  assertEquals(2,(int)ds2.get(txp3));
115  // Weakened expected results after NIL expands to [0]->obj
116  assertEquals(txs2,txp3._obj);
117  //assertEquals(TypeObj.OBJ,txp3._obj);
118 
119  assertTrue(t3.isa(tax));
120  }
121 
122  // Test approximating infinite recursive types. End of chain is already
123  // cyclic, and we add a few more depth.
124  @Test public void testApprox2() {
125  final int CUTOFF = 3;
126  int alias0 = BitsAlias.new_alias(BitsAlias.REC);
127  BitsAlias alias = BitsAlias.make0(alias0);
128 
129  // p3 -> t3[,99] -> p2 -> t2[,99] -> p1 -> t1[,flt] -> p0 -> t0[,int] -> p1*
130 
131  // Build two structs pointing to each other
132  Object dummy0 = TypeStruct.TYPES;
133  Object dummy1 = TypeMemPtr.TYPES;
135  TypeFld[] flds0 = TypeFlds.ts(TypeFld.malloc("a",null,0), TypeFld.malloc("b",null,1));
136  TypeFld[] flds1 = TypeFlds.ts(TypeFld.malloc("a",null,0), TypeFld.malloc("b",null,1));
137  TypeStruct t0 = TypeStruct.malloc("",false,flds0,true);
138  TypeStruct t1 = TypeStruct.malloc("",false,flds1,true);
139  t0._hash = t0.compute_hash(); t0._cyclic = true;
140  t1._hash = t1.compute_hash(); t1._cyclic = true;
141  TypeMemPtr p0 = TypeMemPtr.make(alias0,t0);
142  TypeMemPtr p1 = TypeMemPtr.make(alias0,t1);
143  t0.fld(0).setX(p1 );
144  t0.fld(1).setX(TypeInt.INT64);
145  t1.fld(0).setX(p0 );
146  t1.fld(1).setX(TypeFlt.FLT64);
148  t0 = t0.install_cyclic(t0.reachable());
149  p1 = (TypeMemPtr)t0.at(0);
150 
151  HashMap<Type,Integer> ds = p1.depth();
152  assertEquals(1,(int)ds.get(t0));
153  assertEquals(0,(int)ds.get(t1));
154 
155  // Build a depth-CUTOFF linked list chain
156  TypeStruct t2 = TypeStruct.make(TypeFld.make("a",p1,0), TypeFld.make("b",TypeInt.con(99),1));
157  TypeMemPtr p2 = TypeMemPtr.make(alias0,t2);
158  ds = p2.depth();
159  assertEquals(2,(int)ds.get(t0));
160 
161  TypeStruct t3 = TypeStruct.make(TypeFld.make("a",p2,0), TypeFld.make("b",TypeInt.con(98),1));
162  TypeMemPtr p3 = TypeMemPtr.make(alias0,t3);
163  ds = p3.depth();
164  assertEquals(CUTOFF ,(int)ds.get(t0));
165  assertEquals(CUTOFF-1,(int)ds.get(t1));
166  assertEquals(1,(int)ds.get(t2));
167  assertEquals(0,(int)ds.get(t3));
168  // No single depth is beyond cutoff
169  assertEquals(CUTOFF,TypeMemPtr.max(alias0,ds));
170 
171  // For all TypeStruct X at depth CUTOFF-1, make a clone of X and X's sub-
172  // graph, except every edge to a type at depth CUTOFF is replaced with the
173  // X clone.
174 
175  // original, too deep
176  // t3[,98] -> p2 -> t2[,99] -> p1 -> t1[,flt] -> p0 -> t0[,int] -> p1*
177 
178  // replace ptrs to t0 with ptrs to t1
179  // t3[,98] -> p2 -> t2[,99] -> p1 -> t1[,flt] -> p0 -> t1*
180 
181  // collapse redundant ptrs to t1, and MEET t0-tail and t1-tail
182  // t3[,98] -> p2 -> t2[,99] -> {p0,p1} -> t1[,{flt&int}] -> {p0,p1}
183 
184  TypeStruct tax = t3.approx(CUTOFF,alias0);
185  TypeMemPtr pax = TypeMemPtr.make(alias0,tax);
186 
187  HashMap<Type,Integer> ds2 = pax.depth();
188  assertEquals(CUTOFF-1,TypeMemPtr.max(alias0,ds2));
189  TypeMemPtr txp1 = (TypeMemPtr)tax.at(0);
190  assertEquals(0,(int)ds2.get(txp1));
191  TypeStruct txs1 = (TypeStruct)txp1._obj;
192  assertEquals(1,(int)ds2.get(txs1));
193  TypeMemPtr txp2 = (TypeMemPtr)txs1.at(0);
194  assertEquals(1,(int)ds2.get(txp2));
195  TypeStruct txs2 = (TypeStruct)txp2._obj;
196  assertEquals(CUTOFF-1,(int)ds2.get(txs2));
197  assertEquals(Type.REAL,txs2.at(1));
198  TypeMemPtr txp3 = (TypeMemPtr)txs2.at(0);
199  // Pointer-equals; 'equals()' is not good enough
200  assertSame(txp2, txp3);
201  assertSame(txs2, txp3._obj);
202  assertTrue(t3.isa(tax));
203 
204  // Add another layer, and approx again
205  TypeStruct t4 = TypeStruct.make(TypeFld.make("a",pax,0), TypeFld.make("b",TypeInt.con(97),1));
206  TypeMemPtr p4 = TypeMemPtr.make(alias0,t4);
207  ds = p4.depth();
208  assertEquals(CUTOFF,(int)ds.get(txs2)); // Structure too deep
209  TypeStruct tax4 = t4.approx(CUTOFF,alias0);
210  TypeMemPtr pax4 = TypeMemPtr.make(alias0,tax4);
211 
212  ds2 = pax4.depth();
213  assertEquals(CUTOFF-1,TypeMemPtr.max(alias0,ds2));
214  TypeMemPtr t4p1 = (TypeMemPtr)tax4.at(0);
215  assertEquals(0,(int)ds2.get(t4p1));
216  TypeStruct t4s1 = (TypeStruct)t4p1._obj;
217  assertEquals(1,(int)ds2.get(t4s1));
218  TypeMemPtr t4p2 = (TypeMemPtr)t4s1.at(0);
219  assertEquals(1,(int)ds2.get(t4p2));
220  TypeStruct t4s2 = (TypeStruct)t4p2._obj;
221  assertEquals(CUTOFF-1,(int)ds2.get(t4s2));
222  assertEquals(Type.REAL,t4s2.at(1));
223  TypeMemPtr t4p3 = (TypeMemPtr)t4s2.at(0);
224  assertEquals(1,(int)ds2.get(t4p3));
225  assertEquals(t4s2,t4p3._obj);
226  assertTrue(t4.isa(tax4));
227  }
228 
229  // Interleaving unrelated type X, and approximating type A which is too deep.
230  // A0 -> (X0 <-> X1) -> A1 -> X2 -> A2 -> (X3 <-> X4 ) -> A3 -> X5
231  // Approx:
232  // A0 -> (X0 <-> X1) -> A1 -> X2 -> A23-> (X35<-> X45) -> A23
233  @Test public void testApprox3() {
234  int alias0 = BitsAlias.new_alias(BitsAlias.REC);
235  int alias1 = BitsAlias.new_alias(BitsAlias.REC);
236 
237  // ......................................................... -> X5
238  Type str_x5 = TypeStr.con("X5");
239  TypeStruct x5 = TypeStruct.make(TypeFld.make("v",str_x5 ,0),
240  TypeFld.make("x",Type.XNIL,1),
241  TypeFld.make("a",Type.XNIL,2));
242  TypeMemPtr px5 = TypeMemPtr.make(alias1,x5);
243 
244  // ................................................... -> A3 -> X5
245  TypeStr str_a3 = TypeStr.con("A3");
246  TypeStruct a3 = TypeStruct.make(TypeFld.make("v",str_a3,0),
247  TypeFld.make("x",px5 ,1));
248  TypeMemPtr pa3 = TypeMemPtr.make(alias0,a3);
249 
250  // Build two structs pointing to each other
251  // ...................................... (X3 <-> X4 ) -> A3 -> X5
252  Type i13 = TypeStr.con("X3");
253  Type i14 = TypeStr.con("X4");
254  TypeFld fi13 = TypeFld.make("v",i13,0);
255  TypeFld fi14 = TypeFld.make("v",i14,0);
256  TypeFld fpa3 = TypeFld.make("a",pa3,2);
258  TypeFld[] flds3 = TypeFlds.ts(fi13, TypeFld.malloc("x",null,1), fpa3);
259  TypeFld[] flds4 = TypeFlds.ts(fi14, TypeFld.malloc("x",null,1), fpa3);
260  TypeStruct x3 = TypeStruct.malloc("",false,flds3,true);
261  TypeStruct x4 = TypeStruct.malloc("",false,flds4,true);
262  x3._hash = x3.compute_hash(); x3._cyclic = true;
263  x4._hash = x4.compute_hash(); x4._cyclic = true;
264  TypeMemPtr px3 = TypeMemPtr.make(alias1,x3);
265  TypeMemPtr px4 = TypeMemPtr.make(alias1,x4);
266  x3.fld(1).setX(px4);
267  x4.fld(1).setX(px3);
269  x3 = x3.install_cyclic(x3.reachable());
270  px3 = (TypeMemPtr)x4.at(1);
271 
272  // ................................ A2 -> (X3 <-> X4 ) -> A3 -> X5
273  TypeStr str_a2 = TypeStr.con("A2");
274  TypeStruct a2 = TypeStruct.make(TypeFld.make("v",str_a2,0),
275  TypeFld.make("x",px3 ,1));
276  TypeMemPtr pa2 = TypeMemPtr.make(alias0,a2);
277 
278  // Check sanity
279  HashMap<Type,Integer> depths = pa2.depth();
280  int maxd = TypeMemPtr.max(alias0,depths);
281  assertEquals(1,maxd);
282  assertEquals(1,(int)depths.get(a3));
283 
284  // .......................... X2 -> A2 -> (X3 <-> X4 ) -> A3 -> X5
285  TypeStruct x2 = TypeStruct.make(TypeFld.make("v",TypeStr.con("X2"),0),
286  TypeFld.make("x",Type.NIL,1),
287  TypeFld.make("a",pa2,2));
288  TypeMemPtr px2 = TypeMemPtr.make(alias1,x2);
289 
290  // .................... A1 -> X2 -> A2 -> (X3 <-> X4 ) -> A3 -> X5
291  TypeStruct a1 = TypeStruct.make(TypeFld.make("v",TypeStr.con("A1"),0),
292  TypeFld.make("x",px2,1));
293  TypeMemPtr pa1 = TypeMemPtr.make(alias0,a1);
294 
295  // Build two structs pointing to each other
296  // ..... (X0 <-> X1) -> A1 -> X2 -> A2 -> (X3 <-> X4 ) -> A3 -> X5
297  Type i10 = TypeStr.con("X0");
298  Type i11 = TypeStr.con("X1");
299  TypeFld fil0 = TypeFld.make("v",i10,0);
300  TypeFld fil1 = TypeFld.make("v",i11,0);
301  TypeFld fpa1 = TypeFld.make("a",pa1,2);
303  TypeFld[] flds0 = TypeFlds.ts(fil0, TypeFld.malloc("x",null,1), fpa1);
304  TypeFld[] flds1 = TypeFlds.ts(fil1, TypeFld.malloc("x",null,1), fpa1);
305  TypeStruct x0 = TypeStruct.malloc("",false,flds0,true);
306  TypeStruct x1 = TypeStruct.malloc("",false,flds1,true);
307  x0._hash = x0.compute_hash(); x0._cyclic = true;
308  x1._hash = x1.compute_hash(); x1._cyclic = true;
309  TypeMemPtr px0 = TypeMemPtr.make(alias1,x0);
310  TypeMemPtr px1 = TypeMemPtr.make(alias1,x1);
311  x0.fld(1).setX(px1);
312  x1.fld(1).setX(px0);
314  x0 = x0.install_cyclic(x0.reachable());
315  px0 = (TypeMemPtr)x1.at(1);
316 
317  // A0 -> (X0 <-> X1) -> A1 -> X2 -> A2 -> (X3 <-> X4 ) -> A3 -> X5
318  TypeStruct a0 = TypeStruct.make(TypeFld.make("v",TypeStr.con("A0"),0),
319  TypeFld.make("x",px0,1));
320  TypeMemPtr pa0 = TypeMemPtr.make(alias0,a0);
321 
322  // Check sanity
323  depths = pa0.depth();
324  assertEquals(0,(int)depths.get(a0));
325  assertEquals(1,(int)depths.get(a1));
326  assertEquals(2,(int)depths.get(a2));
327  assertEquals(3,(int)depths.get(a3));
328  assertEquals(3,TypeMemPtr.max(alias0,depths));
329 
330  // Approximate
331  TypeStruct zsa0 = a0.approx(3,alias0);
332  TypeMemPtr pzsa0 = TypeMemPtr.make(alias0,zsa0);
333 
334  // Check sanity!
335  // Was: A0 -> (X0 <-> X1) -> A1 -> X2 -> A2 -> (X3 <-> X4) -> A3 -> X5
336  // Apx: A0 -> (X0 <-> X1) -> A1 -> X2 -> A23-> X35 -> (X4 <-> X3) -> A23
337  assertSame(TypeStr.con("A0"), zsa0.at(0));
338  TypeMemPtr zpx0 = (TypeMemPtr)zsa0.at(1);
339 
340  TypeStruct zsx0 = (TypeStruct)zpx0._obj;
341  assertSame (i10 , zsx0.at(0));
342  TypeMemPtr zpx1 = (TypeMemPtr)zsx0.at(1);
343  TypeMemPtr zpa1 = (TypeMemPtr)zsx0.at(2);
344 
345  TypeStruct zsx1 = (TypeStruct)zpx1._obj;
346  assertSame (i11 , zsx1.at(0));
347  assertSame (zpx0, zsx1.at(1));
348  assertSame (zpa1, zsx1.at(2));
349 
350  TypeStruct zsa1 = (TypeStruct)zpa1._obj;
351  assertSame(TypeStr.con("A1"), zsa1.at(0));
352  TypeMemPtr zpx2 = (TypeMemPtr)zsa1.at(1);
353 
354  TypeStruct zsx2 = (TypeStruct)zpx2._obj;
355  assertSame(TypeStr.con("X2"), zsx2.at(0));
356  assertSame(Type.NIL, zsx2.at(1));
357  TypeMemPtr zpa23= (TypeMemPtr)zsx2.at(2);
358 
359  TypeStruct zsa23= (TypeStruct)zpa23._obj;
360  assertSame(str_a2.meet(str_a3), zsa23.at(0));
361  TypeMemPtr zpx35= (TypeMemPtr)zsa23.at(1);
362 
363  TypeStruct zsx35= (TypeStruct)zpx35._obj;
364  assertSame(str_x5.meet(i13), zsx35.at(0));
365  TypeMemPtr zpa4 = (TypeMemPtr)zsx35.at(1) ;
366  TypeMemPtr zpa23q=(TypeMemPtr)zsx35.at(2) ;
367  // Weakened expected results after NIL expands to [0]->obj
368  assertSame(zsa23, zpa23q._obj);
369  //assertSame(TypeObj.OBJ, zpa23q._obj);
370  TypeStruct zsx4 = (TypeStruct)zpa4._obj;
371  assertSame(i14, zsx4.at(0));
372  assertSame(zpx35, zsx4.at(1));
373  assertSame(zpa23, zsx4.at(2));
374 
375  depths = pzsa0.depth();
376  assertEquals(0,(int)depths.get(zsa0));
377  assertEquals(1,(int)depths.get(zsa1));
378  assertEquals(2,(int)depths.get(zsa23));
379  assertEquals(3,TypeMemPtr.max(alias0,depths));
380  assertTrue(a0.isa(zsa0));
381  }
382 
383 
384  // Type A expands tree-like and gets too deep.
385  // A1 -> A2 -> A4
386  // -> A5
387  // A3 -> A6
388  // -> A7
389  // And then:
390  // A1 -> A2 -> A4 -> A8
391  // A1 -> A2 -> A4 -> A9
392  // A1 -> A2 -> A5 -> A10
393  // A1 -> A2 -> A6 -> A12
394  // Approx:
395  // A1 -> A2 -> A4.8.9 A1.l -> A2.l -> (nint8, T?, T?)
396  // -> A5.10 A2.r -> T:(nint8, T?, nil)
397  // A3 -> A6.12 A1.r -> A3.l -> T
398  // -> A7 -> A3.r -> (nint8, nil, nil)
399  // ... and so forth.
400  // The first few tree layers remain expanded, but the tree tail collapses.
401  @Test public void testApprox4() {
402  final int CUTOFF = 3;
403  int alias = BitsAlias.new_alias(BitsAlias.REC);
404  TypeFld lnil = TypeFld.make("l",Type.NIL,1);
405  TypeFld rnil = TypeFld.make("r",Type.NIL,2);
406 
407  TypeStruct x12= TypeStruct.make(TypeFld.make("v",TypeInt.con(12),0),lnil,rnil);
408  TypeMemPtr px12= TypeMemPtr.make(alias,x12);
409 
410  TypeStruct x10= TypeStruct.make(TypeFld.make("v",TypeInt.con(10),0),lnil,rnil);
411  TypeMemPtr px10= TypeMemPtr.make(alias,x10);
412 
413  TypeStruct x9 = TypeStruct.make(TypeFld.make("v",TypeInt.con( 9),0),lnil,rnil);
414  TypeMemPtr px9 = TypeMemPtr.make(alias,x9 );
415 
416  TypeStruct x8 = TypeStruct.make(TypeFld.make("v",TypeInt.con( 8),0),lnil,rnil);
417  TypeMemPtr px8 = TypeMemPtr.make(alias,x8 );
418 
419  TypeStruct x7 = TypeStruct.make(TypeFld.make("v",TypeInt.con( 7),0),lnil,rnil);
420  TypeMemPtr px7 = TypeMemPtr.make(alias,x7 );
421 
422  TypeStruct x6 = TypeStruct.make(TypeFld.make("v",TypeInt.con( 6),0),TypeFld.make("l",px12,1),rnil);
423  TypeMemPtr px6 = TypeMemPtr.make(alias,x6 );
424 
425  TypeStruct x5 = TypeStruct.make(TypeFld.make("v",TypeInt.con( 5),0),TypeFld.make("l",px10,1),rnil);
426  TypeMemPtr px5 = TypeMemPtr.make(alias,x5 );
427 
428  TypeStruct x4 = TypeStruct.make(TypeFld.make("v",TypeInt.con( 4),0),TypeFld.make("l",px8 ,1),TypeFld.make("r",px9,2) );
429  TypeMemPtr px4 = TypeMemPtr.make(alias,x4 );
430 
431  TypeStruct x3 = TypeStruct.make(TypeFld.make("v",TypeInt.con( 3),0),TypeFld.make("l",px6 ,1),TypeFld.make("r",px7,2) );
432  TypeMemPtr px3 = TypeMemPtr.make(alias,x3 );
433 
434  TypeStruct x2 = TypeStruct.make(TypeFld.make("v",TypeInt.con( 2),0),TypeFld.make("l",px4 ,1),TypeFld.make("r",px5,2) );
435  TypeMemPtr px2 = TypeMemPtr.make(alias,x2 );
436 
437  TypeStruct x1 = TypeStruct.make(TypeFld.make("v",TypeInt.con( 1),0),TypeFld.make("l",px2 ,1),TypeFld.make("r",px3,2) );
438  TypeMemPtr px1 = TypeMemPtr.make(alias,x1 );
439 
440  // Check sanity
441  HashMap<Type,Integer> depths = px1.depth();
442  assertEquals(0,(int)depths.get(x1));
443  assertEquals(1,(int)depths.get(x2));
444  assertEquals(1,(int)depths.get(x3));
445  assertEquals(2,(int)depths.get(x4));
446  assertEquals(2,(int)depths.get(x5));
447  assertEquals(2,(int)depths.get(x6));
448  assertEquals(2,(int)depths.get(x7));
449  assertEquals(3,(int)depths.get(x8));
450  assertEquals(3,(int)depths.get(x9));
451  assertEquals(3,(int)depths.get(x10));
452  assertEquals(3,(int)depths.get(x12));
453  assertEquals(3,TypeMemPtr.max(alias,depths));
454 
455  // Approximate
456  TypeStruct z1 = x1.approx(CUTOFF,alias);
457  TypeMemPtr pz1 = TypeMemPtr.make(alias,z1);
458  assertSame( TypeInt.con(1), z1.at(0));
459  TypeMemPtr p2 = (TypeMemPtr)z1.at(1) ;
460  TypeMemPtr p3 = (TypeMemPtr)z1.at(2) ;
461 
462  TypeStruct z2 = (TypeStruct)p2._obj ;
463  assertSame( TypeInt.con(2), z2.at(0));
464  TypeMemPtr p4 = (TypeMemPtr)z2.at(1) ;
465  TypeMemPtr p5 = (TypeMemPtr)z2.at(2) ;
466 
467  TypeStruct z3 = (TypeStruct)p3._obj ;
468  assertSame( TypeInt.con(3), z3.at(0));
469  TypeMemPtr p6 = (TypeMemPtr)z3.at(1) ;
470  TypeMemPtr p7 = (TypeMemPtr)z3.at(2) ;
471 
472  check_leaf(p4,alias,TypeInt.NINT8);
473  check_leaf(p5,alias,TypeInt.NINT8);
474  check_leaf(p6,alias,TypeInt.NINT8);
475  check_leaf(p7,alias,TypeInt.con(7));
476 
477  depths = pz1.depth();
478  assertEquals(3,TypeMemPtr.max(alias,depths));
479  }
480 
481  // Leaf is a TypeInt.NINT8, and both pointer fields are either NIL or contain
482  // alias 8 (and optionally nil) and point to a leaf type.
483  private void check_leaf( TypeMemPtr p, int alias, TypeInt vt ) {
484  TypeStruct z = (TypeStruct)p._obj;
485  assertSame( vt, z.at(0));
486  Type x1 = z.at(1);
487  if( x1 != Type.NIL ) {
488  TypeMemPtr px = (TypeMemPtr)x1;
489  assertTrue(px._aliases.test(alias));
490  }
491  Type x2 = z.at(2);
492  if( x2 != Type.NIL ) {
493  TypeMemPtr px = (TypeMemPtr)x2;
494  assertTrue(px._aliases.test(alias));
495  }
496  }
497 
498  // Type A expands tree-like and gets too deep; CUTOFF=2
499  // A1 -> {l=S ,r=S ,v} depth=1
500  // A2 -> {l=A1,r=S ,v} depth=2
501  // A3 -> {l=A1,r=A1,v} depth=2
502  // A4 -> {l=A2,r=A3,v} depth=3
503  // Should approx to:
504  // Z1 -> {l=A1,r=A1,v} depth=2, and Z1=A3
505  @Test public void testApprox5() {
506  final int CUTOFF = 2;
507  int alias = BitsAlias.new_alias(BitsAlias.REC);
508 
510  TypeMemPtr px1= TypeMemPtr.make(alias,x1);
511  assertEquals(0,TypeMemPtr.max(alias,px1.depth()));
512 
513  TypeStruct x2= TypeStruct.make(TypeFld.make("l", px1 ,0),TypeFld.make("r",Type.SCALAR,0),TypeFld.make("v",Type.SCALAR,0));
514  TypeMemPtr px2= TypeMemPtr.make(alias,x2);
515  assertEquals(1,TypeMemPtr.max(alias,px2.depth()));
516 
517  TypeStruct x3= TypeStruct.make(TypeFld.make("l", px1 ,0),TypeFld.make("r", px1 ,0),TypeFld.make("v",Type.SCALAR,0));
518  TypeMemPtr px3= TypeMemPtr.make(alias,x3);
519  assertEquals(1,TypeMemPtr.max(alias,px3.depth()));
520 
521  TypeStruct x4= TypeStruct.make(TypeFld.make("l", px2 ,0),TypeFld.make("r", px3 ,0),TypeFld.make("v",Type.SCALAR,0));
522  TypeMemPtr px4= TypeMemPtr.make(alias,x4);
523  assertEquals(2,TypeMemPtr.max(alias,px4.depth()));
524 
525  // Approximate
526  TypeStruct z1 = x4.approx(CUTOFF,alias);
527  TypeMemPtr pz1 = TypeMemPtr.make(alias,z1);
528  assertEquals(1,TypeMemPtr.max(alias,pz1.depth()));
529  assertSame(x3,z1);
530  }
531 
532  // Type A expands tree-like and gets too deep; CUTOFF=2
533  // A1[0,18] -> {l=0 ,r=A1,v} depth=1, cyclic
534  // A2[0,18] -> {l=A1,r=A1,v} depth=2, not cyclic
535  // {l=A1,r=A2,v} depth=3, not cyclic
536  // Should approx to:
537  // A3[0,18] -> {l=A3,r=A3,v} depth=1, cyclic
538  // {l=A1,r=A3,v} depth=2
539  @Test public void testApprox6() {
540  Object dummy0 = TypeStruct.TYPES;
541  Object dummy1 = TypeMemPtr.TYPES;
542  final int CUTOFF = 2;
543  int alias = BitsAlias.new_alias(BitsAlias.REC);
544 
546  TypeFld[] flds1 = TypeFlds.ts(TypeFld.malloc("l",null,0), TypeFld.malloc("r",null,1), TypeFld.malloc("v",null,2));
547  TypeStruct x1 = TypeStruct.malloc("",false,flds1,true);
548  x1._hash = x1.compute_hash(); x1._cyclic = true;
549  TypeMemPtr px1 = TypeMemPtr.make_nil(alias,x1);
550  x1.fld(0).setX(Type.XNIL );
551  x1.fld(1).setX(px1 );
552  x1.fld(2).setX(Type.SCALAR);
554  x1 = x1.install_cyclic(x1.reachable());
555  assertSame(px1,x1.at(1));
556 
557  TypeStruct x2= TypeStruct.make(TypeFld.make("l",px1,0),TypeFld.make("r",px1,1),TypeFld.make("v",Type.SCALAR,2));
558  TypeMemPtr px2= TypeMemPtr.make_nil(alias,x2);
559 
560  TypeStruct z0= TypeStruct.make(TypeFld.make("l",px1,0),TypeFld.make("r",px2,1),TypeFld.make("v",Type.SCALAR,2));
561  // Approximate
562  TypeStruct z1 = z0.approx(CUTOFF,alias);
563 
565  TypeFld[] flds3 = TypeFlds.ts(TypeFld.malloc("l",null,0), TypeFld.malloc("r",null,1), TypeFld.malloc("v",null,2));
566  TypeStruct x3 = TypeStruct.malloc("",false,flds3,true);
567  x3._hash = x3.compute_hash(); x3._cyclic = true;
568  TypeMemPtr px3 = TypeMemPtr.make_nil(alias,x3);
569  x3.fld(0).setX(px3);//TypeMemPtr.make_nil(alias,TypeObj.OBJ);
570  x3.fld(1).setX(px3);
571  x3.fld(2).setX(Type.SCALAR);
573  x3 = x3.install_cyclic(x3.reachable());
574  px3 = (TypeMemPtr)x3.at(1);
575 
576  TypeStruct x4= TypeStruct.make(TypeFld.make("l",px1,0),TypeFld.make("r",px3,1),TypeFld.make("v",Type.SCALAR,2));
577 
578  assertSame(x4,z1);
579  }
580 
581  // Regression test. Verify that a closed DATA cycle in the Node graph makes
582  // a finite Type graph. Basically, endless applying NewObj results to a
583  // NewObj (as happens when making simple cyclic structures via storing fields
584  // from one into the other) ends with a simple cyclic graph and not an
585  // endlessly growing or endlessly "ping ponging" result.
586  @Test public void testApprox7() {
587 
588  // Make a short cycle using alias RECORD. Repeated add instances & approx,
589  // until fixed point.
590  final int CUTOFF=2;
592  TypeMemPtr tmp0 = TypeMemPtr.make(BitsAlias.RECORD_BITS0,ts0), tmp1=null;
593 
594  int cnt=0;
595  while( tmp0 != tmp1 && cnt < 100 ) {
596  TypeStruct ts1 = TypeStruct.make(TypeFld.make("^",tmp1=tmp0,0));
597  TypeStruct ts1x = ts1.approx(CUTOFF,BitsAlias.REC);
598  // Extend with nil-or-not endlessly.
599  tmp0 = TypeMemPtr.make(BitsAlias.RECORD_BITS0,ts1x);
600  cnt++;
601  }
602  // End result has no prefix, since NIL is allowed at every step. i.e., we
603  // added NIL-or-ptr-to-self 3 times, which is exactly approximated by a
604  // tight loop with no prefix.
605  assertEquals(CUTOFF+1,cnt);
606 
607 
608  // Make some child aliases.
609  final int alias6 = BitsAlias.new_alias(BitsAlias.REC);
610  final int alias7 = BitsAlias.new_alias(BitsAlias.REC);
611  final int alias8 = BitsAlias.new_alias(BitsAlias.REC);
612  final BitsAlias ba6 = BitsAlias.make0(alias6);
613  final BitsAlias ba7 = BitsAlias.make0(alias7);
614  final BitsAlias ba8 = BitsAlias.make0(alias8);
615  final BitsAlias ba60 = ba6.meet_nil();
616  final BitsAlias ba70 = ba7.meet_nil();
617  final BitsAlias ba80 = ba8.meet_nil();
618 
619  // Add a struct with alias6 & approx. Expect no change, despite alias6
620  // being a child of RECORD.
621  TypeStruct ts6 = TypeStruct.make(TypeFld.make("^",tmp0,0));
622  TypeStruct ts6x = ts6.approx(CUTOFF,alias6);
623  assertEquals(ts6,ts6x);
624  TypeMemPtr tmp6 = TypeMemPtr.make(ba60,ts6);
625  // Again with alias7
626  TypeStruct ts7 = TypeStruct.make(TypeFld.make("^",tmp6,0));
627  TypeStruct ts7x = ts7.approx(CUTOFF,alias7);
628  assertEquals(ts7,ts7x);
629  TypeMemPtr tmp7 = TypeMemPtr.make(ba70,ts7);
630  // Again with alias8
631  TypeStruct ts8 = TypeStruct.make(TypeFld.make("^",tmp7,0));
632  TypeStruct ts8x = ts8.approx(CUTOFF,alias8);
633  assertEquals(ts8,ts8x);
634 
635 
636  // Start with short cycle:
637  // 10_( 11_* ); 11#2 -> 10
638  // Add this on top (alias#4 and#3 are children of #2):
639  // 12#4 -> 13; 13_( 17_*, 14_* ); 14#3 -> 15; 15_( 16_*, 2.3 ); 16#4 -> 10; 17#5 -> 18; 18_(nil,1.2)
640  // Approx alias#4 should do nothing (only depth 2 for alias#4 till hit cycle).
641  // Then add it again & approx at depth 2 for alias#2.
642 
643 
644  // Start with: A -> A
645  // A is basic RECORD type, actually equal to TypeStruct.DISPLAY.
646  // B,C,D are child aliases of A and are alias6,7,8.
647  // D is a LHS end type: D -> (nil,88)
649  TypeMemPtr tmpD = TypeMemPtr.make(ba8,tsD); // Note not nil
650  // Add (alternating the repeating field left and right):
651  // B1 = ( A , 99 )
653  assertEquals(tsB1,tsB1.approx(CUTOFF,alias6));
654  TypeMemPtr tmpB1= TypeMemPtr.make(ba6,tsB1); // Note not nil
655  // C1 = ( D , B1 )
656  TypeStruct tsC1 = TypeStruct.make(TypeFld.make("^",tmpD,0),TypeFld.make(TypeFld.fldBot,tmpB1,1));
657  assertEquals(tsC1,tsC1.approx(CUTOFF,alias7));
658  TypeMemPtr tmpC1= TypeMemPtr.make(ba7,tsC1); // Note not nil
659 
660  // Add repeatedly until stable:
661  // B2 = ( C1, 99 )
662  // C2 = ( D , B2 )
663  // This should approx by meeting a C with a A, which should drop off the
664  // RHS of the C. The C LHS is a D, which again meets with A to finish the
665  // collapse. Bug is that types flip-flop between 2 variants endlessly.
666  cnt = 0; tmp1 = null;
667  while( tmpC1 != tmp1 && cnt < 100 ) {
668  tmp1 = tmpC1;
669  // B2 = ( C1, 99 )
670  TypeStruct tsB2 = TypeStruct.make(TypeFld.make("^",tmpC1,0),TypeFld.make(TypeFld.fldBot,TypeInt.con(99),1));
671  TypeStruct tsB2x = tsB2.approx(CUTOFF,alias6);
672  TypeMemPtr tmpB2= TypeMemPtr.make(ba6,tsB2x); // Note not nil
673 
674  // C2 = ( D , B2 )
675  TypeStruct tsC2 = TypeStruct.make(TypeFld.make("^",tmpD,0),TypeFld.make(TypeFld.fldBot,tmpB2,1));
676  TypeStruct tsC2x = tsC2.approx(CUTOFF,alias7);
677  TypeMemPtr tmpC2= TypeMemPtr.make(ba7,tsC2x); // Note not nil
678  tmpC1 = tmpC2;
679  cnt++;
680  }
681  assertEquals(CUTOFF,cnt);
682 
683  }
684 
685  @Test public void testApprox8() {
686  Object dummy0 = TypeStruct.TYPES;
687  Object dummy1 = TypeFunPtr.TYPES;
688  Object dummy2 = Env.GVN;
689  final int CUTOFF=2;
690  final int fidx = BitsFun.new_fidx(1), fidx0 = BitsFun.new_fidx(fidx), fidx1 = BitsFun.new_fidx(fidx);
691  final BitsFun fidxs = BitsFun.make0(fidx0,fidx1).dual();
692  final int alias = BitsAlias.new_alias(BitsAlias.REC);
693  Env.ALL_DISPLAYS = Env.ALL_DISPLAYS.set(alias); // Declare a display
694 
695  // Args for the forward-ref fib(^ ->Scalar). This has to start as hi-args
696  // for this test, as the cyclic approx is supposed to be low - and it has
697  // args known post-parse but not pre-parse.
698  TypeStruct tfp0_args = TypeStruct.make("", true, TypeFlds.ts(TypeMemPtr.DISP_FLD), false);
699 
700  TypeFunPtr tfp0 = TypeFunPtr.make(BitsFun.ANY,2,(TypeMemPtr)TypeFunPtr.DISP.simple_ptr()); // fib with generic display
701  TypeStruct dsp0 = TypeStruct.make(TypeMemPtr.DISP_FLD,TypeFld.make("fib",tfp0,1));// The display with weak fib-type
702  TypeMemPtr ptr0 = TypeMemPtr.make(alias,dsp0);
703  // Args for a strong fib: { ^:ptr0 x:int64 -> ~Scalar } // LOW
705  TypeFld.make("^",ptr0.simple_ptr(),1),
706  TypeFld.make("x",TypeInt.INT64,2));
707 
708  TypeFunPtr tfp1 = TypeFunPtr.make(fidxs,2,(TypeMemPtr)ptr0.simple_ptr()); // FIB with weak display
709  TypeStruct dsp1 = TypeStruct.make(TypeMemPtr.DISP_FLD,TypeFld.make("fib",tfp1,1)); // Display with stronger FIB-type
710  TypeMemPtr ptr1 = TypeMemPtr.make(alias,dsp1);
711  // Args for a strong fib: { ^:ptr x:int -> ~Scalar } // LOW. Display still not recursive.
713  TypeFld.make("^",ptr1.simple_ptr(),1),
714  TypeFld.make("x",TypeInt.INT64,2));
715 
716  TypeFunPtr tfp2 = TypeFunPtr.make(fidxs,2,(TypeMemPtr)ptr1.simple_ptr()); // fib2->dsp1->fib1->dsp0->fib0->generic_display
717  TypeStruct dsp2 = TypeStruct.make(TypeMemPtr.DISP_FLD,TypeFld.make("fib",tfp2,1)); // dsp2->fib2->dsp1->fib1->dsp0->fib0->generic_display
718 
719  // The approx that gets built: fib3->dsp3->fib3->dsp3->...
721  TypeFld[] flds3 = TypeFlds.ts(TypeFld.malloc("^",null,0), TypeFld.malloc("fib",null,1));
722  TypeStruct dsp3 = TypeStruct.malloc("",false,flds3,false);
723  dsp3._hash = dsp3.compute_hash(); dsp3._cyclic = true;
724  TypeMemPtr ptr3 = TypeMemPtr.make(alias,dsp3);
726  TypeFld.make("^",ptr3.simple_ptr(),1),
727  TypeFld.make("x",TypeInt.INT64,2));
728  TypeFunPtr tfp3 = TypeFunPtr.make(fidxs,2,(TypeMemPtr)ptr3.simple_ptr());
729  dsp3.fld(0).setX(TypeMemPtr.DISPLAY_PTR);
730  dsp3.fld(1).setX(tfp3);
732  dsp3 = dsp3.install_cyclic(dsp3.reachable());
733 
734  // This should pass an isa-test (was crashing)
735  Type mt0 = dsp0.meet(dsp3);
736 
737  // This should pass an isa-test (was crashing)
738  Type mt1 = dsp1.meet(dsp3);
739 
740  // Check the isa
741  Type mt = dsp2.meet(dsp3);
742  assertEquals(dsp3,mt);
743 
744  // Build the approx
745  TypeStruct rez = dsp2.approx(CUTOFF,alias);
746  assertEquals(dsp3,rez);
747  }
748 }
com.cliffc.aa.type.Bits.dual
B dual()
Definition: Bits.java:368
com.cliffc.aa.type.TypeMemPtr.TYPES
static final Type[] TYPES
Definition: TypeMemPtr.java:106
com.cliffc.aa.type.TypeFunPtr.DISP
static TypeMemPtr DISP
Definition: TypeFunPtr.java:78
com.cliffc.aa.type.BitsAlias.RECORD_BITS0
static BitsAlias RECORD_BITS0
Definition: BitsAlias.java:27
com.cliffc.aa.type.TypeStruct.repeats_in_cycles
TypeStruct repeats_in_cycles()
Definition: TypeStruct.java:450
com.cliffc.aa.type.TypeFunPtr
Definition: TypeFunPtr.java:23
com.cliffc.aa.type.TypeMemPtr.DISPLAY_PTR
static final TypeMemPtr DISPLAY_PTR
Definition: TypeMemPtr.java:79
com.cliffc.aa.type.BitsFun.make0
static BitsFun make0(int bit)
Definition: BitsFun.java:44
com.cliffc.aa.type.TypeStruct.compute_hash
int compute_hash()
Definition: TypeStruct.java:66
com.cliffc.aa.type.Type.SCALAR
static final Type SCALAR
Definition: Type.java:328
com.cliffc
com.cliffc.aa.type.TypeMemPtr.DISP_FLD
static final TypeFld DISP_FLD
Definition: TypeMemPtr.java:77
com.cliffc.aa.type.TypeFld
Definition: TypeFld.java:12
com.cliffc.aa.type.TypeInt
Definition: TypeInt.java:9
com.cliffc.aa.type.TestApprox.testApprox5
void testApprox5()
Definition: TestApprox.java:505
com.cliffc.aa.type.Type
an implementation of language AA
Definition: Type.java:94
com.cliffc.aa.type.TypeFlt
Definition: TypeFlt.java:9
com.cliffc.aa.type.TestApprox.testTSMeet
void testTSMeet()
Definition: TestApprox.java:17
com.cliffc.aa.type.BitsAlias
Definition: BitsAlias.java:8
com.cliffc.aa.type.TestApprox.testApprox6
void testApprox6()
Definition: TestApprox.java:539
com.cliffc.aa.type.TypeFld.NO_DISP
static final TypeFld NO_DISP
Definition: TypeFld.java:170
com.cliffc.aa.type.TypeInt.con
static TypeInt con(long con)
Definition: TypeInt.java:37
com.cliffc.aa.type.TypeFlds
Definition: TypeFlds.java:8
com.cliffc.aa.type.TypeStruct.install_cyclic
TypeStruct install_cyclic(Ary< Type > reachs)
Definition: TypeStruct.java:422
com.cliffc.aa.type.BitsAlias.new_alias
static int new_alias(int par)
Definition: BitsAlias.java:75
com.cliffc.aa.type.TypeFunPtr.TYPES
static final TypeFunPtr[] TYPES
Definition: TypeFunPtr.java:82
com.cliffc.aa.type.Type.meet
final Type meet(Type t)
Definition: Type.java:412
com.cliffc.aa.type.TypeStruct
A memory-based collection of optionally named fields.
Definition: TypeStruct.java:50
com.cliffc.aa.type.TypeFld.make
static TypeFld make(String fld, Type t, int order)
Definition: TypeFld.java:58
com.cliffc.aa.type.Bits.test
static boolean test(long[] bits, int i)
Definition: Bits.java:224
com.cliffc.aa.Env.ALL_DISPLAYS
static BitsAlias ALL_DISPLAYS
Definition: Env.java:28
com.cliffc.aa.type.TypeMemPtr._obj
TypeObj _obj
Definition: TypeMemPtr.java:26
com.cliffc.aa.type.TypeStruct.at
Type at(int idx)
Definition: TypeStruct.java:1013
com.cliffc.aa.type.BitsAlias.REC
static final int REC
Definition: BitsAlias.java:25
com.cliffc.aa.type.TestApprox.testApprox8
void testApprox8()
Definition: TestApprox.java:685
com.cliffc.aa.Env.GVN
static final GVNGCM GVN
Definition: Env.java:13
com.cliffc.aa.type.TypeInt.INT64
static final TypeInt INT64
Definition: TypeInt.java:39
com.cliffc.aa.type.TypeFld.fldBot
static final String fldBot
Definition: TypeFld.java:140
com.cliffc.aa.type.TypeFld.setX
TypeFld setX(Type t)
Definition: TypeFld.java:173
com.cliffc.aa.type.Type.RECURSIVE_MEET
static int RECURSIVE_MEET
Definition: Type.java:163
com.cliffc.aa.type.TestApprox.check_leaf
void check_leaf(TypeMemPtr p, int alias, TypeInt vt)
Definition: TestApprox.java:483
com.cliffc.aa.type.TypeInt.NINT8
static final TypeInt NINT8
Definition: TypeInt.java:47
com.cliffc.aa.type.TestApprox.testType
void testType()
Definition: TestApprox.java:13
com.cliffc.aa.type.TypeStruct.reachable
Ary< Type > reachable()
Definition: TypeStruct.java:779
com.cliffc.aa.type.Bits.meet_nil
B meet_nil()
Definition: Bits.java:212
com.cliffc.aa.type.TypeStr.con
static TypeStr con(String con)
Definition: TypeStr.java:42
com.cliffc.aa.type.TypeFunPtr.make
static TypeFunPtr make(BitsFun fidxs, int nargs, Type disp)
Definition: TypeFunPtr.java:67
com.cliffc.aa.type.TestApprox
Definition: TestApprox.java:11
com.cliffc.aa.type.TypeStr
Definition: TypeStr.java:14
com.cliffc.aa.type.TestApprox.testApprox3
void testApprox3()
Definition: TestApprox.java:233
com.cliffc.aa.type.BitsFun
Definition: BitsFun.java:7
com.cliffc.aa.type.Type.NIL
static final Type NIL
Definition: Type.java:332
com.cliffc.aa.type.TestApprox.testApprox4
void testApprox4()
Definition: TestApprox.java:401
com.cliffc.aa.type.TypeFld.malloc
static TypeFld malloc(String fld, Type t, Access access, int order)
Definition: TypeFld.java:53
com.cliffc.aa.type.TypeMemPtr.simple_ptr
Type simple_ptr()
Definition: TypeMemPtr.java:160
com.cliffc.aa.type.TypeStruct.approx
TypeStruct approx(int cutoff, int alias)
Definition: TypeStruct.java:477
com.cliffc.aa
Definition: AA.java:1
com.cliffc.aa.type.BitsAlias.make0
static BitsAlias make0(int bit)
Definition: BitsAlias.java:72
com.cliffc.aa.type.TypeStruct.fld
TypeFld fld(int idx)
Definition: TypeStruct.java:1012
com.cliffc.aa.type.BitsFun.ANY
static final BitsFun ANY
Definition: BitsFun.java:34
com.cliffc.aa.type.TestApprox.testApprox1
void testApprox1()
Definition: TestApprox.java:54
com.cliffc.aa.type.TypeStruct.TYPES
static final TypeStruct[] TYPES
Definition: TypeStruct.java:242
com.cliffc.aa.type.TypeMemPtr._aliases
BitsAlias _aliases
Definition: TypeMemPtr.java:16
com.cliffc.aa.type.TestApprox.testApprox2
void testApprox2()
Definition: TestApprox.java:124
com.cliffc.aa.type.Type.REAL
static final Type REAL
Definition: Type.java:334
com.cliffc.aa.type.TypeStruct.make
static TypeStruct make(String fld_name, Type t)
Definition: TypeStruct.java:190
com.cliffc.aa.type.TestApprox.testApprox7
void testApprox7()
Definition: TestApprox.java:586
com.cliffc.aa.type.Type.XNIL
static final Type XNIL
Definition: Type.java:333
com.cliffc.aa.type.TypeMemPtr.depth
HashMap< Type, Integer > depth()
Definition: TypeMemPtr.java:217
com.cliffc.aa.type.TypeStruct.malloc
static TypeStruct malloc(String name, boolean any, TypeFld[] flds, boolean open)
Definition: TypeStruct.java:175
com.cliffc.aa.type.TypeMemPtr.max
static int max(int alias, HashMap< Type, Integer > ds)
Definition: TypeMemPtr.java:243
com.cliffc.aa.type.TypeMemPtr.make_nil
static TypeMemPtr make_nil(int alias, TypeObj obj)
Definition: TypeMemPtr.java:72
com.cliffc.aa.type.TypeStruct._cyclic
boolean _cyclic
Definition: TypeStruct.java:54
com
com.cliffc.aa.type.TypeFlds.ts
static TypeFld[] ts(TypeFld t0)
Definition: TypeFlds.java:82
com.cliffc.aa.type.BitsFun.new_fidx
static int new_fidx(int par)
Definition: BitsFun.java:25
com.cliffc.aa.Env
Definition: Env.java:12
com.cliffc.aa.type.TypeMemPtr
Definition: TypeMemPtr.java:14
com.cliffc.aa.type.TypeFlt.FLT64
static final TypeFlt FLT64
Definition: TypeFlt.java:38
com.cliffc.aa.type.TypeMemPtr.make
static TypeMemPtr make(BitsAlias aliases, TypeObj obj)
Definition: TypeMemPtr.java:66