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

Side by Side Diff: pkg/kernel/lib/ast.dart

Issue 3000333002: Fix several bugs in closure conversion. (Closed)
Patch Set: Created 3 years, 3 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) 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 4
5 /// ----------------------------------------------------------------------- 5 /// -----------------------------------------------------------------------
6 /// ERROR HANDLING 6 /// ERROR HANDLING
7 /// ----------------------------------------------------------------------- 7 /// -----------------------------------------------------------------------
8 /// 8 ///
9 /// As a rule of thumb, errors that can be detected statically are handled by 9 /// As a rule of thumb, errors that can be detected statically are handled by
10 /// the frontend, typically by translating the erroneous code into a 'throw' or 10 /// the frontend, typically by translating the erroneous code into a 'throw' or
(...skipping 3160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3171 } 3171 }
3172 } 3172 }
3173 3173
3174 // ------------------------------------------------------------------------ 3174 // ------------------------------------------------------------------------
3175 // STATEMENTS 3175 // STATEMENTS
3176 // ------------------------------------------------------------------------ 3176 // ------------------------------------------------------------------------
3177 3177
3178 abstract class Statement extends TreeNode { 3178 abstract class Statement extends TreeNode {
3179 accept(StatementVisitor v); 3179 accept(StatementVisitor v);
3180 accept1(StatementVisitor1 v, arg); 3180 accept1(StatementVisitor1 v, arg);
3181 bool get isLoop => false;
Dmitry Stefantsov 2017/08/24 09:41:13 Personally, I don't like modifying AST definitions
sjindel 2017/08/24 11:11:43 I understand that, but I feel like determining whe
Dmitry Stefantsov 2017/08/24 11:49:57 I agree that it's a general operation and that it
sjindel 2017/08/24 14:50:13 Done.
3181 } 3182 }
3182 3183
3183 /// A statement with a compile-time error. 3184 /// A statement with a compile-time error.
3184 /// 3185 ///
3185 /// Should throw an exception at runtime. 3186 /// Should throw an exception at runtime.
3186 class InvalidStatement extends Statement { 3187 class InvalidStatement extends Statement {
3187 accept(StatementVisitor v) => v.visitInvalidStatement(this); 3188 accept(StatementVisitor v) => v.visitInvalidStatement(this);
3188 accept1(StatementVisitor1 v, arg) => v.visitInvalidStatement(this, arg); 3189 accept1(StatementVisitor1 v, arg) => v.visitInvalidStatement(this, arg);
3189 3190
3190 visitChildren(Visitor v) {} 3191 visitChildren(Visitor v) {}
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
3356 transformChildren(Transformer v) { 3357 transformChildren(Transformer v) {
3357 if (condition != null) { 3358 if (condition != null) {
3358 condition = condition.accept(v); 3359 condition = condition.accept(v);
3359 condition?.parent = this; 3360 condition?.parent = this;
3360 } 3361 }
3361 if (body != null) { 3362 if (body != null) {
3362 body = body.accept(v); 3363 body = body.accept(v);
3363 body?.parent = this; 3364 body?.parent = this;
3364 } 3365 }
3365 } 3366 }
3367
3368 bool get isLoop => true;
3366 } 3369 }
3367 3370
3368 class DoStatement extends Statement { 3371 class DoStatement extends Statement {
3369 Statement body; 3372 Statement body;
3370 Expression condition; 3373 Expression condition;
3371 3374
3372 DoStatement(this.body, this.condition) { 3375 DoStatement(this.body, this.condition) {
3373 body?.parent = this; 3376 body?.parent = this;
3374 condition?.parent = this; 3377 condition?.parent = this;
3375 } 3378 }
3376 3379
3377 accept(StatementVisitor v) => v.visitDoStatement(this); 3380 accept(StatementVisitor v) => v.visitDoStatement(this);
3378 accept1(StatementVisitor1 v, arg) => v.visitDoStatement(this, arg); 3381 accept1(StatementVisitor1 v, arg) => v.visitDoStatement(this, arg);
3379 3382
3380 visitChildren(Visitor v) { 3383 visitChildren(Visitor v) {
3381 body?.accept(v); 3384 body?.accept(v);
3382 condition?.accept(v); 3385 condition?.accept(v);
3383 } 3386 }
3384 3387
3385 transformChildren(Transformer v) { 3388 transformChildren(Transformer v) {
3386 if (body != null) { 3389 if (body != null) {
3387 body = body.accept(v); 3390 body = body.accept(v);
3388 body?.parent = this; 3391 body?.parent = this;
3389 } 3392 }
3390 if (condition != null) { 3393 if (condition != null) {
3391 condition = condition.accept(v); 3394 condition = condition.accept(v);
3392 condition?.parent = this; 3395 condition?.parent = this;
3393 } 3396 }
3394 } 3397 }
3398
3399 bool get isLoop => true;
3395 } 3400 }
3396 3401
3397 class ForStatement extends Statement { 3402 class ForStatement extends Statement {
3398 final List<VariableDeclaration> variables; // May be empty, but not null. 3403 final List<VariableDeclaration> variables; // May be empty, but not null.
3399 Expression condition; // May be null. 3404 Expression condition; // May be null.
3400 final List<Expression> updates; // May be empty, but not null. 3405 final List<Expression> updates; // May be empty, but not null.
3401 Statement body; 3406 Statement body;
3402 3407
3403 ForStatement(this.variables, this.condition, this.updates, this.body) { 3408 ForStatement(this.variables, this.condition, this.updates, this.body) {
3404 setParents(variables, this); 3409 setParents(variables, this);
(...skipping 17 matching lines...) Expand all
3422 if (condition != null) { 3427 if (condition != null) {
3423 condition = condition.accept(v); 3428 condition = condition.accept(v);
3424 condition?.parent = this; 3429 condition?.parent = this;
3425 } 3430 }
3426 transformList(updates, v, this); 3431 transformList(updates, v, this);
3427 if (body != null) { 3432 if (body != null) {
3428 body = body.accept(v); 3433 body = body.accept(v);
3429 body?.parent = this; 3434 body?.parent = this;
3430 } 3435 }
3431 } 3436 }
3437
3438 bool get isLoop => true;
3432 } 3439 }
3433 3440
3434 class ForInStatement extends Statement { 3441 class ForInStatement extends Statement {
3435 /// Offset in the source file it comes from. 3442 /// Offset in the source file it comes from.
3436 /// 3443 ///
3437 /// Valid values are from 0 and up, or -1 ([TreeNode.noOffset]) if the file 3444 /// Valid values are from 0 and up, or -1 ([TreeNode.noOffset]) if the file
3438 /// offset is not available (this is the default if none is specifically set). 3445 /// offset is not available (this is the default if none is specifically set).
3439 int bodyOffset = TreeNode.noOffset; 3446 int bodyOffset = TreeNode.noOffset;
3440 3447
3441 VariableDeclaration variable; // Has no initializer. 3448 VariableDeclaration variable; // Has no initializer.
(...skipping 24 matching lines...) Expand all
3466 } 3473 }
3467 if (iterable != null) { 3474 if (iterable != null) {
3468 iterable = iterable.accept(v); 3475 iterable = iterable.accept(v);
3469 iterable?.parent = this; 3476 iterable?.parent = this;
3470 } 3477 }
3471 if (body != null) { 3478 if (body != null) {
3472 body = body.accept(v); 3479 body = body.accept(v);
3473 body?.parent = this; 3480 body?.parent = this;
3474 } 3481 }
3475 } 3482 }
3483
3484 bool get isLoop => true;
3476 } 3485 }
3477 3486
3478 /// Statement of form `switch (e) { case x: ... }`. 3487 /// Statement of form `switch (e) { case x: ... }`.
3479 /// 3488 ///
3480 /// Adjacent case clauses have been merged into a single [SwitchCase]. A runtime 3489 /// Adjacent case clauses have been merged into a single [SwitchCase]. A runtime
3481 /// exception must be thrown if one [SwitchCase] falls through to another case. 3490 /// exception must be thrown if one [SwitchCase] falls through to another case.
3482 class SwitchStatement extends Statement { 3491 class SwitchStatement extends Statement {
3483 Expression expression; 3492 Expression expression;
3484 final List<SwitchCase> cases; 3493 final List<SwitchCase> cases;
3485 3494
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after
4743 if (typedef_.canonicalName == null) { 4752 if (typedef_.canonicalName == null) {
4744 throw '$typedef_ has no canonical name'; 4753 throw '$typedef_ has no canonical name';
4745 } 4754 }
4746 return typedef_.canonicalName; 4755 return typedef_.canonicalName;
4747 } 4756 }
4748 4757
4749 /// Annotation describing information which is not part of Dart semantics; in 4758 /// Annotation describing information which is not part of Dart semantics; in
4750 /// other words, if this information (or any information it refers to) changes, 4759 /// other words, if this information (or any information it refers to) changes,
4751 /// static analysis and runtime behavior of the library are unaffected. 4760 /// static analysis and runtime behavior of the library are unaffected.
4752 const informative = null; 4761 const informative = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698