Appearance
| 1 | namespace Syntax.Trees.Expressions is | |
| 2 | use IO.Std | |
| 3 | ||
| 4 | use Source | |
| 5 | ||
| 6 | class BINARY( | |
| 7 | location: LOCATION, | |
| 8 | operation: Identifiers.Identifier, | |
| 9 | actual_operation: string?, | |
| 10 | left: Expression, | |
| 11 | right: Expression | |
| 12 | ): Expression is | |
| 13 | super(location) | |
| 14 | ||
| 15 | // An operator whose declared return type carries the pack marker | |
| 16 | // takes the pack from the function type its context expects, as | |
| 17 | // a call does. | |
| 18 | set_expected_type(expected_type: Semantic.Types.Type?, error_message: string?) is | |
| 19 | compile_expressions_state.set_expected_type(expected_type, error_message) | |
| 20 | si | |
| 21 | ||
| 22 | accept(visitor: Visitor) is | |
| 23 | visitor.visit(self) | |
| 24 | si | |
| 25 | ||
| 26 | walk(visitor: Visitor) is | |
| 27 | // enter/leave_node wrap the whole visit so the ambient | |
| 28 | // location covers Values built by `pre()` overrides that | |
| 29 | // take control of the walk — `pre_binary` for `/\`/`\/` | |
| 30 | // does its own narrowing-aware walk and returns true, | |
| 31 | // skipping the default recursion below. | |
| 32 | visitor.enter_node(self) | |
| 33 | try | |
| 34 | if !visitor.pre(self) then | |
| 35 | left.walk(visitor) | |
| 36 | right.walk(visitor) | |
| 37 | fi | |
| 38 | accept(visitor) | |
| 39 | finally | |
| 40 | visitor.leave_node(self) | |
| 41 | yrt | |
| 42 | si | |
| 43 | ||
| 44 | replace_child(old: Expression, replacement: Expression) is | |
| 45 | if left == old then | |
| 46 | left = replacement | |
| 47 | elif right == old then | |
| 48 | right = replacement | |
| 49 | fi | |
| 50 | si | |
| 51 | si | |
| 52 | si |