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

Method func

chapter18/src/main/java/com/seaofnodes/simple/Parser.java:1354–1372  ·  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

1352 private Node zsMask(Node val, Type t ) {
1353 if( val._type instanceof TypeFloat && t instanceof TypeInteger )
1354 val = new ToIntegerNode(val).peephole();
1355 if( !(val._type instanceof TypeInteger tval && t instanceof TypeInteger t0 && !tval.isa(t0)) ) {
1356 if( !(val._type instanceof TypeFloat tval && t instanceof TypeFloat t0 && !tval.isa(t0)) )
1357 return val;
1358 // Float rounding
1359 return peep(new RoundF32Node(val));
1360 }
1361 if( t0._min==0 ) // Unsigned
1362 return peep(new AndNode(null,val,con(t0._max)));
1363 // Signed extension
1364 int shift = Long.numberOfLeadingZeros(t0._max)-1;
1365 Node shf = con(shift);
1366 if( shf._type==TypeInteger.ZERO )
1367 return val;
1368 return peep(new SarNode(null,peep(new ShlNode(null,val,shf.keep())),shf.unkeep()));
1369 }
1370
1371 /**
1372 * Parse a function body; the caller will parse the surrounding "{}"
1373 *
1374 * <pre>
1375 * { [type arg,]* -> expr }

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
makeFunMethod · 0.95
makeMethod · 0.95
asAryMethod · 0.95
parseFunctionBodyMethod · 0.95
conMethod · 0.95
skipWhiteSpaceMethod · 0.45

Tested by

no test coverage detected