Parse a function body; the caller will parse the surrounding "{}" { [type arg,] -> expr } { expr } // The no-argument function
()
| 1651 | * </pre> |
| 1652 | */ |
| 1653 | private Node func() { |
| 1654 | Ary<Type> ts = new Ary<>(Type.class); |
| 1655 | Ary<String> ids = new Ary<>(String.class); |
| 1656 | |
| 1657 | // Defined in constructor? Add `self` argument. "static" calls still |
| 1658 | // add a `self` they just ignore it. |
| 1659 | if( _scope._kinds.last() instanceof Kind.Define define ) { |
| 1660 | // Upgrade defined struct to latest fields |
| 1661 | TypeMemPtr tmp = (TypeMemPtr)TYPES.get(define._tmp._obj._name); |
| 1662 | ts .push(tmp); |
| 1663 | ids.push("self"); |
| 1664 | } |
| 1665 | |
| 1666 | // Parse other arguments |
| 1667 | _lexer.skipWhiteSpace(); |
| 1668 | Lexer loc = loc(); // First argument location |
| 1669 | while( true ) { |
| 1670 | Type t = type(); // Arg type |
| 1671 | if( t==null ) break; |
| 1672 | String id = requireId(); |
| 1673 | ts .push(t ); // Push type/arg pairs |
| 1674 | ids.push(id); |
| 1675 | match(","); |
| 1676 | } |
| 1677 | require("->"); |
| 1678 | // Make a concrete function type, with a fidx |
| 1679 | TypeFunPtr tfp = _code.makeFun(TypeFunPtr.make(false,false,ts.asAry(),Type.BOTTOM)); |
| 1680 | ReturnNode ret = parseFunctionBody(tfp,loc,ids.asAry()); |
| 1681 | return con(ret._fun.sig()); |
| 1682 | } |
| 1683 | |
| 1684 | /** |
| 1685 | * Parse function call arguments; caller will parse the surrounding "()" |
no test coverage detected