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

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

Issue 2928033005: Add type inference for assignment to local variables. (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
index 5c93f1db71adb6eb86b15ea45a634d680075cab0..a81aa4f5ad596d65e752bf9d003eb278030a119b 100644
--- a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
@@ -96,8 +96,10 @@ abstract class Accessor {
Expression buildCompoundAssignment(Name binaryOperator, Expression value,
{int offset: TreeNode.noOffset,
bool voidContext: false,
- Procedure interfaceTarget}) {
+ Procedure interfaceTarget,
+ bool isPreIncDec: false}) {
var complexAssignment = startComplexAssignment(value);
+ complexAssignment?.isPreIncDec = isPreIncDec;
var combiner = makeBinary(
_makeRead(complexAssignment), binaryOperator, interfaceTarget, value,
offset: offset);
@@ -115,7 +117,8 @@ abstract class Accessor {
return buildCompoundAssignment(binaryOperator, new IntLiteral(1),
offset: offset,
voidContext: voidContext,
- interfaceTarget: interfaceTarget);
+ interfaceTarget: interfaceTarget,
+ isPreIncDec: true);
}
/// Returns an [Expression] representing a post-increment or post-decrement
@@ -157,8 +160,14 @@ abstract class Accessor {
KernelComplexAssignment complexAssignment);
Expression _finish(
- Expression body, KernelComplexAssignment complexAssignment) =>
- body;
+ Expression body, KernelComplexAssignment complexAssignment) {
+ if (complexAssignment != null) {
+ complexAssignment.desugared = body;
+ return complexAssignment;
+ } else {
+ return body;
+ }
+ }
/// Returns an [Expression] representing a compile-time error.
///
@@ -195,17 +204,21 @@ abstract class VariableAccessor extends Accessor {
var fact = helper.typePromoter
.getFactForAccess(variable, helper.functionNestingLevel);
var scope = helper.typePromoter.currentScope;
- return new KernelVariableGet(variable, fact, scope)
+ var read = new KernelVariableGet(variable, fact, scope)
..fileOffset = offsetForToken(token);
+ complexAssignment?.read = read;
+ return read;
}
Expression _makeWrite(Expression value, bool voidContext,
KernelComplexAssignment complexAssignment) {
helper.typePromoter.mutateVariable(variable, helper.functionNestingLevel);
- return variable.isFinal || variable.isConst
+ var write = variable.isFinal || variable.isConst
? makeInvalidWrite(value)
: new KernelVariableSet(variable, value)
..fileOffset = offsetForToken(token);
+ complexAssignment?.write = write;
+ return write;
}
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart ('k') | pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698