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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart

Issue 2768533002: Fasta type inference prototype #2
Patch Set: Merge origin/master Created 3 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) 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 // Note: copied from package:kernel at revision 7346348. 5 // Note: copied from package:kernel at revision 7346348.
6 6
7 /// A library to help transform compounds and null-aware accessors into 7 /// A library to help transform compounds and null-aware accessors into
8 /// let expressions. 8 /// let expressions.
9 library kernel.frontend.accessors; 9 library kernel.frontend.accessors;
10 10
11 import 'package:kernel/ast.dart'; 11 import 'package:kernel/ast.dart';
12 import 'shadow_ast.dart' as shadow;
12 13
13 /// An [Accessor] represents a subexpression for which we can't yet build a 14 /// An [Accessor] represents a subexpression for which we can't yet build a
14 /// kernel [Expression] because we don't yet know the context in which it is 15 /// kernel [Expression] because we don't yet know the context in which it is
15 /// used. 16 /// used.
16 /// 17 ///
17 /// Once the context is known, an [Accessor] can be converted into an 18 /// Once the context is known, an [Accessor] can be converted into an
18 /// [Expression] by calling a "build" method. 19 /// [Expression] by calling a "build" method.
19 /// 20 ///
20 /// For example, when building a kernel representation for `a[x] = b`, after 21 /// For example, when building a kernel representation for `a[x] = b`, after
21 /// parsing `a[x]` but before parsing `= b`, we don't yet know whether to 22 /// parsing `a[x]` but before parsing `= b`, we don't yet know whether to
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 class VariableAccessor extends Accessor { 122 class VariableAccessor extends Accessor {
122 VariableDeclaration variable; 123 VariableDeclaration variable;
123 int charOffset; 124 int charOffset;
124 DartType promotedType; 125 DartType promotedType;
125 126
126 VariableAccessor(this.variable, [this.promotedType]); 127 VariableAccessor(this.variable, [this.promotedType]);
127 128
128 VariableAccessor.internal(this.variable, this.charOffset, this.promotedType); 129 VariableAccessor.internal(this.variable, this.charOffset, this.promotedType);
129 130
130 _makeRead() => 131 _makeRead() =>
131 new VariableGet(variable, promotedType)..fileOffset = charOffset; 132 new shadow.VariableGet(variable, promotedType)..fileOffset = charOffset;
132 133
133 _makeWrite(Expression value, bool voidContext) { 134 _makeWrite(Expression value, bool voidContext) {
134 return variable.isFinal || variable.isConst 135 return variable.isFinal || variable.isConst
135 ? makeInvalidWrite(value) 136 ? makeInvalidWrite(value)
136 : new VariableSet(variable, value)..fileOffset = charOffset; 137 : new VariableSet(variable, value)..fileOffset = charOffset;
137 } 138 }
138 } 139 }
139 140
140 class PropertyAccessor extends Accessor { 141 class PropertyAccessor extends Accessor {
141 VariableDeclaration _receiverVariable; 142 VariableDeclaration _receiverVariable;
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 486
486 VariableDeclaration makeOrReuseVariable(Expression value) { 487 VariableDeclaration makeOrReuseVariable(Expression value) {
487 // TODO: Devise a way to remember if a variable declaration was reused 488 // TODO: Devise a way to remember if a variable declaration was reused
488 // or is fresh (hence needs a let binding). 489 // or is fresh (hence needs a let binding).
489 return new VariableDeclaration.forValue(value); 490 return new VariableDeclaration.forValue(value);
490 } 491 }
491 492
492 Expression wrapInvalid(Expression e) { 493 Expression wrapInvalid(Expression e) {
493 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); 494 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression());
494 } 495 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698