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

Method func

chapter19/src/main/java/com/seaofnodes/simple/Parser.java:1346–1364  ·  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

1344 val = new ToIntegerNode(val).peephole();
1345 if( !(val._type instanceof TypeInteger tval && t instanceof TypeInteger t0 && !tval.isa(t0)) ) {
1346 if( !(val._type instanceof TypeFloat tval && t instanceof TypeFloat t0 && !tval.isa(t0)) )
1347 return val;
1348 // Float rounding
1349 return peep(new RoundF32Node(val));
1350 }
1351 if( t0._min==0 ) // Unsigned
1352 return peep(new AndNode(null,val,con(t0._max)));
1353 // Signed extension
1354 int shift = Long.numberOfLeadingZeros(t0._max)-1;
1355 Node shf = con(shift);
1356 if( shf._type==TypeInteger.ZERO )
1357 return val;
1358 return peep(new SarNode(null,peep(new ShlNode(null,val,shf.keep())),shf.unkeep()));
1359 }
1360
1361 /**
1362 * Parse a function body; the caller will parse the surrounding "{}"
1363 *
1364 * <pre>
1365 * { [type arg,]* -> expr }
1366 * { expr } // The no-argument function
1367 * </pre>

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