Appearance
| 1 | namespace Syntax.Trees.Expressions is | |
| 2 | use Source; | |
| 3 | ||
| 4 | class FUNCTION: Expression, ScopeCarrier is | |
| 5 | scope: Semantic.Scope? public; | |
| 6 | ||
| 7 | arguments: LIST; | |
| 8 | type_expression: TypeExpressions.TypeExpression; | |
| 9 | is_recursive: bool; | |
| 10 | ||
| 11 | // True when the lambda's body contains an `await` expression | |
| 12 | // (not inside a nested lambda). Set by declare-symbols. | |
| 13 | // Read by compile-lambdas to decide whether an implicit-INFER | |
| 14 | // return type becomes a plain placeholder or settles to | |
| 15 | // `Tasks.TASK[T]`. | |
| 16 | contains_let_await: bool public; | |
| 17 | ||
| 18 | // True when `contains_let_await` is set AND the body has no | |
| 19 | // value-returning `return X;` statements — meaning the | |
| 20 | // lambda's inferred return type should be the non-generic | |
| 21 | // `Tasks.TASK` (rather than `Tasks.TASK[T]` for some T). | |
| 22 | // End-of-body fallthrough and bare `return;` in such a body | |
| 23 | // produce a TaskCompletionSource.SetResult() with no value. | |
| 24 | is_void_async: bool public; | |
| 25 | ||
| 26 | body: Bodies.Body; | |
| 27 | ||
| 28 | // Constraint pushed in by the parent context (LHS of an | |
| 29 | // assignment, declared variable type, etc.). Read by the | |
| 30 | // compile_expressions function-literal visitor as a fallback | |
| 31 | // for argument-type inference when the existing | |
| 32 | // _partial_argument_function_type implication channel hasn't | |
| 33 | // been set. | |
| 34 | ||
| 35 | init( | |
| 36 | location: LOCATION, | |
| 37 | arguments: LIST, | |
| 38 | type_expression: TypeExpressions.TypeExpression, | |
| 39 | body: Bodies.Body, | |
| 40 | is_recursive: bool | |
| 41 | ) | |
| 42 | is | |
| 43 | super.init(location); | |
| 44 | ||
| 45 | self.arguments = arguments; | |
| 46 | self.type_expression = type_expression; | |
| 47 | self.is_recursive = is_recursive; | |
| 48 | ||
| 49 | self.body = body; | |
| 50 | si | |
| 51 | ||
| 52 | set_expected_type(expected_type: Semantic.Types.Type?, error_message: string?) is | |
| 53 | compile_expressions_state.set_expected_type(expected_type, error_message); | |
| 54 | si | |
| 55 | ||
| 56 | accept(visitor: Visitor) is | |
| 57 | visitor.visit(self); | |
| 58 | si | |
| 59 | ||
| 60 | walk(visitor: Visitor) is | |
| 61 | if !visitor.pre(self) then | |
| 62 | type_expression.walk(visitor); | |
| 63 | arguments.walk(visitor); | |
| 64 | body.walk(visitor); | |
| 65 | fi | |
| 66 | ||
| 67 | accept(visitor); | |
| 68 | si | |
| 69 | si | |
| 70 | si |