OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 library kernel.clone; | 4 library kernel.clone; |
5 | 5 |
6 import 'ast.dart'; | 6 import 'ast.dart'; |
7 import 'type_algebra.dart'; | 7 import 'type_algebra.dart'; |
8 | 8 |
9 /// Visitor that return a clone of a tree, maintaining references to cloned | 9 /// Visitor that return a clone of a tree, maintaining references to cloned |
10 /// objects. | 10 /// objects. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 visitVariableGet(VariableGet node) { | 61 visitVariableGet(VariableGet node) { |
62 return new VariableGet( | 62 return new VariableGet( |
63 variables[node.variable], visitOptionalType(node.promotedType)); | 63 variables[node.variable], visitOptionalType(node.promotedType)); |
64 } | 64 } |
65 | 65 |
66 visitVariableSet(VariableSet node) { | 66 visitVariableSet(VariableSet node) { |
67 return new VariableSet(variables[node.variable], clone(node.value)); | 67 return new VariableSet(variables[node.variable], clone(node.value)); |
68 } | 68 } |
69 | 69 |
70 visitPropertyGet(PropertyGet node) { | 70 visitPropertyGet(PropertyGet node) { |
71 return new PropertyGet( | 71 return new PropertyGet.byBox( |
72 clone(node.receiver), node.name, node.interfaceTarget); | 72 clone(node.receiver), node.name, node.interfaceTargetBox); |
73 } | 73 } |
74 | 74 |
75 visitPropertySet(PropertySet node) { | 75 visitPropertySet(PropertySet node) { |
76 return new PropertySet(clone(node.receiver), node.name, clone(node.value), | 76 return new PropertySet.byBox(clone(node.receiver), node.name, |
77 node.interfaceTarget); | 77 clone(node.value), node.interfaceTargetBox); |
78 } | 78 } |
79 | 79 |
80 visitDirectPropertyGet(DirectPropertyGet node) { | 80 visitDirectPropertyGet(DirectPropertyGet node) { |
81 return new DirectPropertyGet(clone(node.receiver), node.target); | 81 return new DirectPropertyGet.byBox(clone(node.receiver), node.targetBox); |
82 } | 82 } |
83 | 83 |
84 visitDirectPropertySet(DirectPropertySet node) { | 84 visitDirectPropertySet(DirectPropertySet node) { |
85 return new DirectPropertySet( | 85 return new DirectPropertySet.byBox( |
86 clone(node.receiver), node.target, clone(node.value)); | 86 clone(node.receiver), node.targetBox, clone(node.value)); |
87 } | 87 } |
88 | 88 |
89 visitSuperPropertyGet(SuperPropertyGet node) { | 89 visitSuperPropertyGet(SuperPropertyGet node) { |
90 return new SuperPropertyGet(node.name, node.interfaceTarget); | 90 return new SuperPropertyGet.byBox(node.name, node.interfaceTargetBox); |
91 } | 91 } |
92 | 92 |
93 visitSuperPropertySet(SuperPropertySet node) { | 93 visitSuperPropertySet(SuperPropertySet node) { |
94 return new SuperPropertySet( | 94 return new SuperPropertySet.byBox( |
95 node.name, clone(node.value), node.interfaceTarget); | 95 node.name, clone(node.value), node.interfaceTargetBox); |
96 } | 96 } |
97 | 97 |
98 visitStaticGet(StaticGet node) { | 98 visitStaticGet(StaticGet node) { |
99 return new StaticGet(node.target); | 99 return new StaticGet.byBox(node.targetBox); |
100 } | 100 } |
101 | 101 |
102 visitStaticSet(StaticSet node) { | 102 visitStaticSet(StaticSet node) { |
103 return new StaticSet(node.target, clone(node.value)); | 103 return new StaticSet.byBox(node.targetBox, clone(node.value)); |
104 } | 104 } |
105 | 105 |
106 visitMethodInvocation(MethodInvocation node) { | 106 visitMethodInvocation(MethodInvocation node) { |
107 return new MethodInvocation(clone(node.receiver), node.name, | 107 return new MethodInvocation.byBox(clone(node.receiver), node.name, |
108 clone(node.arguments), node.interfaceTarget); | 108 clone(node.arguments), node.interfaceTargetBox); |
109 } | 109 } |
110 | 110 |
111 visitDirectMethodInvocation(DirectMethodInvocation node) { | 111 visitDirectMethodInvocation(DirectMethodInvocation node) { |
112 return new DirectMethodInvocation( | 112 return new DirectMethodInvocation.byBox( |
113 clone(node.receiver), node.target, clone(node.arguments)); | 113 clone(node.receiver), node.targetBox, clone(node.arguments)); |
114 } | 114 } |
115 | 115 |
116 visitSuperMethodInvocation(SuperMethodInvocation node) { | 116 visitSuperMethodInvocation(SuperMethodInvocation node) { |
117 return new SuperMethodInvocation( | 117 return new SuperMethodInvocation.byBox( |
118 node.name, clone(node.arguments), node.interfaceTarget); | 118 node.name, clone(node.arguments), node.interfaceTargetBox); |
119 } | 119 } |
120 | 120 |
121 visitStaticInvocation(StaticInvocation node) { | 121 visitStaticInvocation(StaticInvocation node) { |
122 return new StaticInvocation(node.target, clone(node.arguments), | 122 return new StaticInvocation.byBox(node.targetBox, clone(node.arguments), |
123 isConst: node.isConst); | 123 isConst: node.isConst); |
124 } | 124 } |
125 | 125 |
126 visitConstructorInvocation(ConstructorInvocation node) { | 126 visitConstructorInvocation(ConstructorInvocation node) { |
127 return new ConstructorInvocation(node.target, clone(node.arguments), | 127 return new ConstructorInvocation.byBox( |
| 128 node.targetBox, clone(node.arguments), |
128 isConst: node.isConst); | 129 isConst: node.isConst); |
129 } | 130 } |
130 | 131 |
131 visitNot(Not node) { | 132 visitNot(Not node) { |
132 return new Not(clone(node.operand)); | 133 return new Not(clone(node.operand)); |
133 } | 134 } |
134 | 135 |
135 visitLogicalExpression(LogicalExpression node) { | 136 visitLogicalExpression(LogicalExpression node) { |
136 return new LogicalExpression( | 137 return new LogicalExpression( |
137 clone(node.left), node.operator, clone(node.right)); | 138 clone(node.left), node.operator, clone(node.right)); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 visitArguments(Arguments node) { | 396 visitArguments(Arguments node) { |
396 return new Arguments(node.positional.map(clone).toList(), | 397 return new Arguments(node.positional.map(clone).toList(), |
397 types: node.types.map(visitType).toList(), | 398 types: node.types.map(visitType).toList(), |
398 named: node.named.map(clone).toList()); | 399 named: node.named.map(clone).toList()); |
399 } | 400 } |
400 | 401 |
401 visitNamedExpression(NamedExpression node) { | 402 visitNamedExpression(NamedExpression node) { |
402 return new NamedExpression(node.name, clone(node.value)); | 403 return new NamedExpression(node.name, clone(node.value)); |
403 } | 404 } |
404 } | 405 } |
OLD | NEW |