Parse a function body; the caller will parse the surrounding "{}" { [type arg,] -> expr } { expr } // The no-argument function
()
| 1591 | |
| 1592 | expr.keep(); |
| 1593 | // Field offset; fixed for structs, computed for arrays |
| 1594 | Node off = (name.equals("[]") // If field is an array body |
| 1595 | // Array index math |
| 1596 | ? peep(new AddNode(off(base,"[]"),peep(new ShlNode(null,require(parseAsgn(),"]"),con(base.aryScale()))))) |
| 1597 | // Struct field offsets are hardwired |
| 1598 | : off(base,name)).keep(); |
| 1599 | |
| 1600 | // Disambiguate "obj.fld==x" boolean test from "obj.fld=x" field assignment |
| 1601 | if( pre==0 && matchOpx('=','=') ) { |
| 1602 | Node val = parseAsgn().keep(); |
| 1603 | Node lift = liftExpr( val, tf, false ); |
| 1604 | |
| 1605 | store(name,f._alias,tf,expr.unkeep(),off.unkeep(),lift,false,base.isAry() ? ctrl() : null); |
| 1606 | return val.unkeep(); // "obj.a = expr" returns the expression while updating memory |
| 1607 | } |
| 1608 | |
| 1609 | // Load field |
| 1610 | Node load = f._one && INITS.containsKey( base._name ) |
| 1611 | ? INITS.get(base._name).in(base.find(name)) |
| 1612 | : new LoadNode(loc(),name, f._alias, tf, mem(), expr, off); |
| 1613 | // Arrays include control, as a proxy for a safety range check |
| 1614 | // Structs don't need this; they only need a NPE check which is |
| 1615 | // done via the type system. |
| 1616 | if( base.isAry() && !name.equals("#") ) load.setDef(0,ctrl()); |
| 1617 | load = peep(load); |
| 1618 | |
| 1619 | // Check for assign-update, "ptr.fld += expr" or "ary[idx]++" |
| 1620 | char ch = pre==0 ? _lexer.matchOperAssign() : (char)pre; |
| 1621 | if( ch!=0 ) { |
| 1622 | Node op = opAssign(ch,load,tf); |
| 1623 | // A narrow Store may drop its conversion; prefix still returns it. |
| 1624 | if( pre!=0 ) op.keep(); |
| 1625 | store(name,f._alias,tf,expr.unkeep(),off.unkeep(),op,false,base.isAry() ? ctrl() : null); |
no test coverage detected