Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/dart_backend/utils.dart

Issue 184503002: Remove support for --force-strip=asserts from dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_backend/dart_backend.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 part of dart_backend;
6
7 class CloningVisitor implements Visitor<Node> {
8 final TreeElements originalTreeElements;
9 final TreeElementMapping cloneTreeElements;
10
11 CloningVisitor(originalTreeElements)
12 : cloneTreeElements =
13 new TreeElementMapping(originalTreeElements.currentElement),
14 this.originalTreeElements = originalTreeElements;
15
16 visit(Node node) {
17 if (node == null) return null;
18 final clone = node.accept(this);
19
20 final originalElement = originalTreeElements[node];
21 if (originalElement != null) cloneTreeElements[clone] = originalElement;
22
23 final originalType = originalTreeElements.getType(node);
24 if (originalType != null) cloneTreeElements.setType(clone, originalType);
25 return clone;
26 }
27
28 Node visitBlock(Block node) => new Block(visit(node.statements));
29
30 Node visitBreakStatement(BreakStatement node) => new BreakStatement(
31 visit(node.target), node.keywordToken, node.semicolonToken);
32
33 Node visitCascade(Cascade node) => new Cascade(visit(node.expression));
34
35 Node visitCascadeReceiver(CascadeReceiver node) => new CascadeReceiver(
36 visit(node.expression), node.cascadeOperator);
37
38 Node visitCaseMatch(CaseMatch node) => new CaseMatch(
39 node.caseKeyword, visit(node.expression), node.colonToken);
40
41 Node visitCatchBlock(CatchBlock node) => new CatchBlock(
42 visit(node.type), visit(node.formals), visit(node.block),
43 node.onKeyword, node.catchKeyword);
44
45 Node visitClassNode(ClassNode node) => new ClassNode(
46 visit(node.modifiers), visit(node.name), visit(node.typeParameters),
47 visit(node.superclass), visit(node.interfaces),
48 node.beginToken, node.extendsKeyword, visit(node.body), node.endToken);
49
50 Node visitConditional(Conditional node) => new Conditional(
51 visit(node.condition), visit(node.thenExpression),
52 visit(node.elseExpression), node.questionToken, node.colonToken);
53
54 Node visitContinueStatement(ContinueStatement node) => new ContinueStatement(
55 visit(node.target), node.keywordToken, node.semicolonToken);
56
57 Node visitDoWhile(DoWhile node) => new DoWhile(
58 visit(node.body), visit(node.condition),
59 node.doKeyword, node.whileKeyword, node.endToken);
60
61 Node visitEmptyStatement(EmptyStatement node) => new EmptyStatement(
62 node.semicolonToken);
63
64 Node visitExpressionStatement(ExpressionStatement node) => new ExpressionState ment(
65 visit(node.expression), node.endToken);
66
67 Node visitFor(For node) => new For(
68 visit(node.initializer), visit(node.conditionStatement),
69 visit(node.update), visit(node.body), node.forToken);
70
71 Node visitForIn(ForIn node) => new ForIn(
72 visit(node.declaredIdentifier), visit(node.expression), visit(node.body),
73 node.forToken, node.inToken);
74
75 Node visitFunctionDeclaration(FunctionDeclaration node) => new FunctionDeclara tion(
76 visit(node.function));
77
78 Node rewriteFunctionExpression(FunctionExpression node, Statement body) =>
79 new FunctionExpression(
80 visit(node.name), visit(node.parameters), body,
81 visit(node.returnType), visit(node.modifiers),
82 visit(node.initializers), node.getOrSet);
83
84 Node visitFunctionExpression(FunctionExpression node) =>
85 rewriteFunctionExpression(node, visit(node.body));
86
87 Node visitIdentifier(Identifier node) => new Identifier(node.token);
88
89 Node visitIf(If node) => new If(
90 visit(node.condition), visit(node.thenPart), visit(node.elsePart),
91 node.ifToken, node.elseToken);
92
93 Node visitLabel(Label node) =>
94 new Label(visit(node.identifier), node.colonToken);
95
96 Node visitLabeledStatement(LabeledStatement node) => new LabeledStatement(
97 visit(node.labels), visit(node.statement));
98
99 Node visitLiteralBool(LiteralBool node) => new LiteralBool(
100 node.token, node.handler);
101
102 Node visitLiteralDouble(LiteralDouble node) => new LiteralDouble(
103 node.token, node.handler);
104
105 Node visitLiteralInt(LiteralInt node) =>
106 new LiteralInt(node.token, node.handler);
107
108 Node visitLiteralList(LiteralList node) => new LiteralList(
109 visit(node.typeArguments), visit(node.elements), node.constKeyword);
110
111 Node visitLiteralMap(LiteralMap node) => new LiteralMap(
112 visit(node.typeArguments), visit(node.entries), node.constKeyword);
113
114 Node visitLiteralMapEntry(LiteralMapEntry node) => new LiteralMapEntry(
115 visit(node.key), node.colonToken, visit(node.value));
116
117 Node visitLiteralNull(LiteralNull node) => new LiteralNull(node.token);
118
119 Node visitLiteralString(LiteralString node) => new LiteralString(
120 node.token, node.dartString);
121
122 Node visitMetadata(Metadata node) => new Metadata(
123 node.token, visit(node.expression));
124
125 Node visitMixinApplication(MixinApplication node) => new MixinApplication(
126 visit(node.superclass), visit(node.mixins));
127
128 Node visitNamedMixinApplication(NamedMixinApplication node) =>
129 new NamedMixinApplication(visit(node.name),
130 visit(node.typeParameters),
131 visit(node.modifiers),
132 visit(node.mixinApplication),
133 visit(node.interfaces),
134 node.classKeyword,
135 node.endToken);
136
137 Node visitModifiers(Modifiers node) => new Modifiers(visit(node.nodes));
138
139 Node visitNamedArgument(NamedArgument node) => new NamedArgument(
140 visit(node.name), node.colonToken, visit(node.expression));
141
142 Node visitNewExpression(NewExpression node) => new NewExpression(
143 node.newToken, visit(node.send));
144
145 Node rewriteNodeList(NodeList node, Link link) =>
146 new NodeList(node.beginToken, link, node.endToken, node.delimiter);
147
148 Node visitNodeList(NodeList node) {
149 // Special case for classes which exist in hierarchy, but not
150 // in the visitor.
151 if (node is Prefix) {
152 return node.nodes.isEmpty ?
153 new Prefix() : new Prefix.singleton(visit(node.nodes.head));
154 }
155 if (node is Postfix) {
156 return node.nodes.isEmpty ?
157 new Postfix() : new Postfix.singleton(visit(node.nodes.head));
158 }
159 LinkBuilder<Node> builder = new LinkBuilder<Node>();
160 for (Node n in node.nodes) {
161 builder.addLast(visit(n));
162 }
163 return rewriteNodeList(node, builder.toLink());
164 }
165
166 Node visitOperator(Operator node) => new Operator(node.token);
167
168 Node visitParenthesizedExpression(ParenthesizedExpression node) =>
169 new ParenthesizedExpression(visit(node.expression), node.beginToken);
170
171 Node visitRethrow(Rethrow node) => new Rethrow(
172 node.throwToken, node.endToken);
173
174 Node visitReturn(Return node) => new Return(
175 node.beginToken, node.endToken, visit(node.expression));
176
177 Node visitSend(Send node) => new Send(
178 visit(node.receiver), visit(node.selector), visit(node.argumentsNode));
179
180 Node visitSendSet(SendSet node) => new SendSet(
181 visit(node.receiver), visit(node.selector),
182 visit(node.assignmentOperator), visit(node.argumentsNode));
183
184 Node visitStringInterpolation(StringInterpolation node) =>
185 new StringInterpolation(visit(node.string), visit(node.parts));
186
187 Node visitStringInterpolationPart(StringInterpolationPart node) =>
188 new StringInterpolationPart(visit(node.expression), visit(node.string));
189
190 Node visitStringJuxtaposition(StringJuxtaposition node) =>
191 new StringJuxtaposition(visit(node.first), visit(node.second));
192
193 Node visitSwitchCase(SwitchCase node) => new SwitchCase(
194 visit(node.labelsAndCases), node.defaultKeyword, visit(node.statements),
195 node.startToken);
196
197 Node visitSwitchStatement(SwitchStatement node) => new SwitchStatement(
198 visit(node.parenthesizedExpression), visit(node.cases),
199 node.switchKeyword);
200
201 Node visitLiteralSymbol(LiteralSymbol node) => new LiteralSymbol(
202 node.hashToken, visit(node.identifiers));
203
204 Node visitThrow(Throw node) => new Throw(
205 visit(node.expression), node.throwToken, node.endToken);
206
207 Node visitTryStatement(TryStatement node) => new TryStatement(
208 visit(node.tryBlock), visit(node.catchBlocks), visit(node.finallyBlock),
209 node.tryKeyword, node.finallyKeyword);
210
211 Node visitTypeAnnotation(TypeAnnotation node) => new TypeAnnotation(
212 visit(node.typeName), visit(node.typeArguments));
213
214 Node visitTypedef(Typedef node) => new Typedef(
215 visit(node.returnType), visit(node.name), visit(node.typeParameters),
216 visit(node.formals), node.typedefKeyword, node.endToken);
217
218 Node visitTypeVariable(TypeVariable node) => new TypeVariable(
219 visit(node.name), visit(node.bound));
220
221 Node visitVariableDefinitions(VariableDefinitions node) =>
222 new VariableDefinitions.forParameter(
223 visit(node.metadata), visit(node.type),
224 visit(node.modifiers), visit(node.definitions));
225
226 Node visitWhile(While node) => new While(
227 visit(node.condition), visit(node.body), node.whileKeyword);
228
229 Node visitNode(Node node) {
230 unimplemented('visitNode', node: node);
231 return null;
232 }
233
234 Node visitCombinator(Combinator node) {
235 unimplemented('visitNode', node: node);
236 return null;
237 }
238
239 Node visitExport(Export node) {
240 unimplemented('visitNode', node: node);
241 return null;
242 }
243
244 Node visitExpression(Expression node) {
245 unimplemented('visitNode', node: node);
246 return null;
247 }
248
249 Node visitGotoStatement(GotoStatement node) {
250 unimplemented('visitNode', node: node);
251 return null;
252 }
253
254 Node visitImport(Import node) {
255 unimplemented('visitNode', node: node);
256 return null;
257 }
258
259 Node visitLibraryDependency(LibraryTag node) {
260 unimplemented('visitNode', node: node);
261 return null;
262 }
263
264 Node visitLibraryName(LibraryName node) {
265 unimplemented('visitNode', node: node);
266 return null;
267 }
268
269 Node visitLibraryTag(LibraryTag node) {
270 unimplemented('visitNode', node: node);
271 return null;
272 }
273
274 Node visitLiteral(Literal node) {
275 unimplemented('visitNode', node: node);
276 return null;
277 }
278
279 Node visitLoop(Loop node) {
280 unimplemented('visitNode', node: node);
281 return null;
282 }
283
284 Node visitPart(Part node) {
285 unimplemented('visitNode', node: node);
286 return null;
287 }
288
289 Node visitPartOf(PartOf node) {
290 unimplemented('visitNode', node: node);
291 return null;
292 }
293
294 Node visitPostfix(Postfix node) {
295 unimplemented('visitNode', node: node);
296 return null;
297 }
298
299 Node visitPrefix(Prefix node) {
300 unimplemented('visitNode', node: node);
301 return null;
302 }
303
304 Node visitStatement(Statement node) {
305 unimplemented('visitNode', node: node);
306 return null;
307 }
308
309 Node visitStringNode(StringNode node) {
310 unimplemented('visitNode', node: node);
311 return null;
312 }
313
314 unimplemented(String message, {Node node}) {
315 throw message;
316 }
317 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_backend/dart_backend.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698