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

Method con

chapter23/src/test/java/com/seaofnodes/simple/Eval2.java:303–323  ·  view source on GitHub ↗
( Type t )

Source from the content-addressed store, hash-verified

301
302 // Java box ints and floats. Other things can just be null or some informative string
303 private static Object con( Type t ) {
304 return switch ( t ) {
305 case TypeInteger i -> i.isConstant() ? (Long )i.value() : "INT";
306 case TypeFloat f -> f.isConstant() ? (Double)f.value() : "FLT";
307 case TypeFunPtr tfp -> tfp;
308 case TypeMem mem -> "MEM";
309 case TypeMemPtr tmp -> {
310 if( tmp._obj.isAry() ) { // Constant array ptr
311 TypeConAry con = (TypeConAry)tmp._obj.field("[]")._t;
312 Object[] xs = new Object[con.len()];
313 for( int i=0; i<con.len(); i++ )
314 xs[i] = con.at8(i);
315 yield xs;
316
317 } else {
318 throw Utils.TODO(); // Constant non-array ptr
319 }
320 }
321 default -> null;
322 };
323 }
324
325 // Convert array size to array element count
326 private static int offToIdx( long off, TypeStruct t) {

Callers 2

computeMethod · 0.95
allocMethod · 0.95

Calls 7

lenMethod · 0.95
at8Method · 0.95
TODOMethod · 0.95
isConstantMethod · 0.45
valueMethod · 0.45
isAryMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected