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 | init(location: LOCATION) is | |
| 11 | super.init(location); | |
| 12 | si | |
| 13 | ||
| 14 | get_names_into(into: Collections.MutableList[Expression]); | |
| 15 | ||
| 16 | copy() -> AssignmentLeftExpression; | |
| 17 | si | |
| 18 | ||
| 19 | class SIMPLE_LEFT_EXPRESSION: AssignmentLeftExpression is | |
| 20 | expression: Expression; | |
| 21 | is_simple_expression: bool => true; | |
| 22 | ||
| 23 | elements: Collections.List[AssignmentLeftExpression] => System.Array.empty`[AssignmentLeftExpression](); | |
| 24 | ||
| 25 | init( | |
| 26 | location: LOCATION, | |
| 27 | name: Expression | |
| 28 | ) is | |
| 29 | super.init(location); | |
| 30 | ||
| 31 | self.expression = name; | |
| 32 | ||
| 33 | // will be set more accurately in compile expressions | |
| 34 | // but must have some non-null value | |
| 35 | assign_location = location; | |
| 36 | si | |
| 37 | ||
| 38 | get_names_into(into: Collections.MutableList[Expression]) is | |
| 39 | into.add(expression); | |
| 40 | si | |
| 41 | ||
| 42 | accept(visitor: Visitor) is | |
| 43 | visitor.visit(self); | |
| 44 | si | |
| 45 | ||
| 46 | walk(visitor: Visitor) is | |
| 47 | if !visitor.pre(self) then | |
| 48 | expression.walk(visitor); | |
| 49 | fi | |
| 50 | ||
| 51 | accept(visitor); | |
| 52 | si | |
| 53 | ||
| 54 | copy() -> AssignmentLeftExpression is | |
| 55 | let result = SIMPLE_LEFT_EXPRESSION(location, expression); | |
| 56 | ||
| 57 | result.assign_location = assign_location; | |
| 58 | ||
| 59 | return result; | |
| 60 | si | |
| 61 | si | |
| 62 | ||
| 63 | class DESTRUCTURING_LEFT_EXPRESSION: AssignmentLeftExpression is | |
| 64 | elements: Collections.List[AssignmentLeftExpression]; | |
| 65 | ||
| 66 | init(location: LOCATION, elements: Collections.List[AssignmentLeftExpression]) is | |
| 67 | super.init(location); | |
| 68 | self.elements = elements; | |
| 69 | si | |
| 70 | ||
| 71 | get_names_into(into: Collections.MutableList[Expression]) is | |
| 72 | for e in elements do | |
| 73 | e.get_names_into(into); | |
| 74 | od | |
| 75 | si | |
| 76 | ||
| 77 | accept(visitor: Visitor) is | |
| 78 | visitor.visit(self); | |
| 79 | si | |
| 80 | ||
| 81 | walk(visitor: Visitor) is | |
| 82 | if !visitor.pre(self) then | |
| 83 | for e in elements do | |
| 84 | e.walk(visitor); | |
| 85 | od | |
| 86 | fi | |
| 87 | accept(visitor); | |
| 88 | si | |
| 89 | ||
| 90 | copy() -> AssignmentLeftExpression is | |
| 91 | let new_elements = Collections.LIST[AssignmentLeftExpression](elements.count); | |
| 92 | ||
| 93 | for e in elements do | |
| 94 | new_elements.add(e.copy()); | |
| 95 | od | |
| 96 | ||
| 97 | let result = DESTRUCTURING_LEFT_EXPRESSION(location, new_elements); | |
| 98 | ||
| 99 | result.assign_location = assign_location; | |
| 100 | ||
| 101 | return result; | |
| 102 | si | |
| 103 | si | |
| 104 | si |