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

Side by Side Diff: lib/src/js/nodes.dart

Issue 965033002: add source maps support, fixes #50 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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 4
5 part of js_ast; 5 part of js_ast;
6 6
7 abstract class NodeVisitor<T> { 7 abstract class NodeVisitor<T> {
8 T visitProgram(Program node); 8 T visitProgram(Program node);
9 9
10 T visitBlock(Block node); 10 T visitBlock(Block node);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 => visitInterpolatedNode(node); 196 => visitInterpolatedNode(node);
197 197
198 // Ignore comments by default. 198 // Ignore comments by default.
199 T visitComment(Comment node) => null; 199 T visitComment(Comment node) => null;
200 T visitCommentExpression(CommentExpression node) => null; 200 T visitCommentExpression(CommentExpression node) => null;
201 201
202 T visitAwait(Await node) => visitExpression(node); 202 T visitAwait(Await node) => visitExpression(node);
203 T visitDartYield(DartYield node) => visitStatement(node); 203 T visitDartYield(DartYield node) => visitStatement(node);
204 } 204 }
205 205
206 /// This tag interface has no behaviour but must be implemented by any class
207 /// that is to be stored on a [Node] as source information.
208 abstract class JavaScriptNodeSourceInformation {}
209
210 abstract class Node { 206 abstract class Node {
211 JavaScriptNodeSourceInformation get sourceInformation => _sourceInformation; 207 /// Sets the source location of this node. For performance reasons, we allow
212 208 /// setting this after construction.
213 JavaScriptNodeSourceInformation _sourceInformation; 209 Object sourceInformation;
214 210
215 accept(NodeVisitor visitor); 211 accept(NodeVisitor visitor);
216 void visitChildren(NodeVisitor visitor); 212 void visitChildren(NodeVisitor visitor);
217 213
218 // Shallow clone of node. Does not clone positions since the only use of this 214 // Shallow clone of node. Does not clone positions since the only use of this
219 // private method is create a copy with a new position. 215 // private method is create a copy with a new position.
220 Node _clone(); 216 Node _clone();
221 217
222 // Returns a node equivalent to [this], but with new source position and end 218 // Returns a node equivalent to [this], but with new source position and end
223 // source position. 219 // source position.
224 Node withSourceInformation( 220 Node withSourceInformation(sourceInformation) {
225 JavaScriptNodeSourceInformation sourceInformation) { 221 if (sourceInformation == this.sourceInformation) {
226 if (sourceInformation == _sourceInformation) {
227 return this; 222 return this;
228 } 223 }
229 Node clone = _clone(); 224 Node clone = _clone();
230 // TODO(sra): Should existing data be 'sticky' if we try to overwrite with 225 // TODO(sra): Should existing data be 'sticky' if we try to overwrite with
231 // `null`? 226 // `null`?
232 clone._sourceInformation = sourceInformation; 227 clone.sourceInformation = sourceInformation;
233 return clone; 228 return clone;
234 } 229 }
235 230
236 VariableUse asVariableUse() => null; 231 VariableUse asVariableUse() => null;
237 232
238 bool get isCommaOperator => false; 233 bool get isCommaOperator => false;
239 234
240 Statement toStatement() { 235 Statement toStatement() {
241 throw new UnsupportedError('toStatement'); 236 throw new UnsupportedError('toStatement');
242 } 237 }
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 final Expression expression; 1404 final Expression expression;
1410 1405
1411 CommentExpression(this.comment, this.expression); 1406 CommentExpression(this.comment, this.expression);
1412 1407
1413 int get precedenceLevel => PRIMARY; 1408 int get precedenceLevel => PRIMARY;
1414 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this); 1409 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this);
1415 CommentExpression _clone() => new CommentExpression(comment, expression); 1410 CommentExpression _clone() => new CommentExpression(comment, expression);
1416 1411
1417 void visitChildren(NodeVisitor visitor) => expression.accept(visitor); 1412 void visitChildren(NodeVisitor visitor) => expression.accept(visitor);
1418 } 1413 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698