Parse a function body; the caller will parse the surrounding "{}" { [type arg,] -> expr } { expr } // The no-argument function
()
| 1591 | * </pre> |
| 1592 | */ |
| 1593 | private Node func() { |
| 1594 | Ary<Type> ts = new Ary<>(Type.class); |
| 1595 | Ary<String> ids = new Ary<>(String.class); |
| 1596 | |
| 1597 | // Defined in constructor? Add `self` argument. "static" calls still |
| 1598 | // add a `self` they just ignore it. |
| 1599 | if( _scope._kinds.last() instanceof Kind.Define define ) { |
| 1600 | // Upgrade defined struct to latest fields |
| 1601 | TypeMemPtr tmp = (TypeMemPtr)TYPES.get(define._tmp._obj._name); |
| 1602 | ts .push(tmp); |
| 1603 | ids.push("self"); |
| 1604 | } |
| 1605 | |
| 1606 | // Parse other arguments |
| 1607 | _lexer.skipWhiteSpace(); |
| 1608 | Lexer loc = loc(); // First argument location |
| 1609 | while( true ) { |
| 1610 | Type t = type(); // Arg type |
| 1611 | if( t==null ) break; |
| 1612 | String id = requireId(); |
| 1613 | ts .push(t ); // Push type/arg pairs |
| 1614 | ids.push(id); |
| 1615 | match(","); |
| 1616 | } |
| 1617 | require("->"); |
| 1618 | // Make a concrete function type, with a fidx |
| 1619 | TypeFunPtr tfp = _code.makeFun(TypeFunPtr.make(false,false,ts.asAry(),Type.BOTTOM)); |
| 1620 | ReturnNode ret = parseFunctionBody(tfp,loc,ids.asAry()); |
| 1621 | return con(ret._fun.sig()); |
| 1622 | } |
| 1623 | |
| 1624 | /** |
| 1625 | * Parse function call arguments; caller will parse the surrounding "()" |
no test coverage detected