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

Method func

chapter21/src/main/java/com/seaofnodes/simple/Parser.java:1366–1384  ·  view source on GitHub ↗

Parse a function body; the caller will parse the surrounding "{}" { [type arg,] -> expr } { expr } // The no-argument function

()

Source from the content-addressed store, hash-verified

1364 if( !(val._type instanceof TypeInteger tval && t instanceof TypeInteger t0 && !tval.isa(t0)) ) {
1365 if( !(val._type instanceof TypeFloat tval && t instanceof TypeFloat t0 && !tval.isa(t0)) )
1366 return val;
1367 // Float rounding
1368 return peep(new RoundF32Node(val));
1369 }
1370 if( t0._min==0 ) // Unsigned
1371 return peep(new AndNode(null,val,con(t0._max)));
1372 // Signed extension
1373 int shift = Long.numberOfLeadingZeros(t0._max)-1;
1374 Node shf = con(shift);
1375 if( shf._type==TypeInteger.ZERO )
1376 return val;
1377 return peep(new SarNode(null,peep(new ShlNode(null,val,shf.keep())),shf.unkeep()));
1378 }
1379
1380 /**
1381 * Parse a function body; the caller will parse the surrounding "{}"
1382 *
1383 * <pre>
1384 * { [type arg,]* -> expr }
1385 * { expr } // The no-argument function
1386 * </pre>
1387 */

Callers 1

parsePrimaryMethod · 0.95

Calls 13

locMethod · 0.95
typeMethod · 0.95
requireIdMethod · 0.95
pushMethod · 0.95
matchMethod · 0.95
requireMethod · 0.95
makeMethod · 0.95
asAryMethod · 0.95
parseFunctionBodyMethod · 0.95
conMethod · 0.95
skipWhiteSpaceMethod · 0.45
makeFunMethod · 0.45

Tested by

no test coverage detected