Appearance
| 1 | namespace Syntax.Trees.Expressions is | |
| 2 | use Source | |
| 3 | ||
| 4 | class AssignmentLeftExpression: Expression is | |
| 5 | is_simple_expression: bool => false | |
| 6 | expression: Expression? => null | |
| 7 | elements: Collections.List[AssignmentLeftExpression]? => null | |
| 8 | assign_location: LOCATION public | |
| 9 | ||
| 10 | // The assignment's own location is stamped on by compile- | |
| 11 | // bindings, which is where the left expression learns what it | |
| 12 | // is part of. | |
| 13 | @suppress("field-definite-assignment") | |
| 14 | init(location: LOCATION) is | |
| 15 | super.init(location) | |
| 16 | si | |
| 17 | ||
| 18 | get_names_into(into: Collections.MutableList[Expression]) | |
| 19 | ||
| 20 | copy() -> AssignmentLeftExpression | |
| 21 | si | |
| 22 | ||
| 23 | class SIMPLE_LEFT_EXPRESSION: AssignmentLeftExpression is | |
| 24 | expression: Expression | |
| 25 | is_simple_expression: bool => true | |
| 26 | ||
| 27 | elements: Collections.List[AssignmentLeftExpression] => System.Array.empty`[AssignmentLeftExpression]() | |
| 28 | ||
| 29 | init( | |
| 30 | location: LOCATION, | |
| 31 | name: Expression | |
| 32 | ) is | |
| 33 | super.init(location) | |
| 34 | ||
| 35 | self.expression = name | |
| 36 | ||
| 37 | // will be set more accurately in compile expressions | |
| 38 | // but must have some non-null value | |
| 39 | assign_location = location | |
| 40 | si | |
| 41 | ||
| 42 | get_names_into(into: Collections.MutableList[Expression]) is | |
| 43 | into.add(expression) | |
| 44 | si | |
| 45 | ||
| 46 | accept(visitor: Visitor) is | |
| 47 | visitor.visit(self) | |
| 48 | si | |
| 49 | ||
| 50 | walk(visitor: Visitor) is | |
| 51 | if !visitor.pre(self) then | |
| 52 | expression.walk(visitor) | |
| 53 | fi | |
| 54 | ||
| 55 | accept(visitor) | |
| 56 | si | |
| 57 | ||
| 58 | copy() -> AssignmentLeftExpression is | |
| 59 | let result = SIMPLE_LEFT_EXPRESSION(location, expression) | |
| 60 | ||
| 61 | result.assign_location = assign_location | |
| 62 | ||
| 63 | return result | |
| 64 | si | |
| 65 | si | |
| 66 | ||
| 67 | class DESTRUCTURING_LEFT_EXPRESSION: AssignmentLeftExpression is | |
| 68 | elements: Collections.List[AssignmentLeftExpression] | |
| 69 | ||
| 70 | init(location: LOCATION, elements: Collections.List[AssignmentLeftExpression]) is | |
| 71 | super.init(location) | |
| 72 | self.elements = elements | |
| 73 | si | |
| 74 | ||
| 75 | get_names_into(into: Collections.MutableList[Expression]) is | |
| 76 | for e in elements do | |
| 77 | e.get_names_into(into) | |
| 78 | od | |
| 79 | si | |
| 80 | ||
| 81 | accept(visitor: Visitor) is | |
| 82 | visitor.visit(self) | |
| 83 | si | |
| 84 | ||
| 85 | walk(visitor: Visitor) is | |
| 86 | if !visitor.pre(self) then | |
| 87 | for e in elements do | |
| 88 | e.walk(visitor) | |
| 89 | od | |
| 90 | fi | |
| 91 | accept(visitor) | |
| 92 | si | |
| 93 | ||
| 94 | copy() -> AssignmentLeftExpression is | |
| 95 | let new_elements = Collections.LIST[AssignmentLeftExpression](elements.count) | |
| 96 | ||
| 97 | for e in elements do | |
| 98 | new_elements.add(e.copy()) | |
| 99 | od | |
| 100 | ||
| 101 | let result = DESTRUCTURING_LEFT_EXPRESSION(location, new_elements) | |
| 102 | ||
| 103 | result.assign_location = assign_location | |
| 104 | ||
| 105 | return result | |
| 106 | si | |
| 107 | si | |
| 108 | si |