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

Unified Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1303503002: Refactor updates of locals. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/members.dart
diff --git a/pkg/compiler/lib/src/resolution/members.dart b/pkg/compiler/lib/src/resolution/members.dart
index c2814fd28db77a5d09ab66accd77f358a1853ad8..84fac7bc5b4fac2d2fa91c50a0a10cb2fce56c9e 100644
--- a/pkg/compiler/lib/src/resolution/members.dart
+++ b/pkg/compiler/lib/src/resolution/members.dart
@@ -2660,6 +2660,56 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
return result;
}
+ /// Handle update of a parameter, local variable or local function.
+ ResolutionResult handleLocalUpdate(Send node, Name name, Element element) {
+ AccessSemantics semantics;
+ ErroneousElement error;
+ if (element.isParameter) {
+ if (element.isFinal) {
+ error = reportAndCreateErroneousElement(
+ node.selector, name.text,
+ MessageKind.CANNOT_RESOLVE_SETTER, const {});
+ semantics = new StaticAccess.finalParameter(element);
+ } else {
+ semantics = new StaticAccess.parameter(element);
+ }
+ } else if (element.isVariable) {
+ if (element.isFinal || element.isConst) {
+ error = reportAndCreateErroneousElement(
+ node.selector, name.text,
+ MessageKind.CANNOT_RESOLVE_SETTER, const {});
+ semantics = new StaticAccess.finalLocalVariable(element);
+ } else {
+ semantics = new StaticAccess.localVariable(element);
+ }
+ } else {
+ assert(invariant(node, element.isFunction,
+ message: "Unexpected local $element."));
+ error = reportAndCreateErroneousElement(
+ node.selector, name.text,
+ MessageKind.ASSIGNING_METHOD, const {});
+ semantics = new StaticAccess.localFunction(element);
+ }
+ if (isPotentiallyMutableTarget(element)) {
+ registry.registerPotentialMutation(element, node);
+ if (enclosingElement != element.enclosingElement) {
+ registry.registerPotentialMutationInClosure(element, node);
+ }
+ for (Node scope in promotionScope) {
+ registry.registerPotentialMutationIn(scope, element, node);
+ }
+ }
+
+ ResolutionResult result = handleUpdate(node, name, semantics);
+ if (error != null) {
+ registry.registerThrowNoSuchMethod();
+ // TODO(23998): Remove this when all information goes through
+ // the [SendStructure].
+ registry.useElement(node, error);
+ }
+ return result;
+ }
+
/// Handle access of a static or top level [element].
ResolutionResult handleStaticOrTopLevelAccess(
Send node, Name name, Element element) {
@@ -2869,6 +2919,8 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
} else if (element.isTypeVariable) {
// `T = b`, `T++`, or 'T += b` where 'T' is a type variable.
return handleTypeVariableTypeLiteralUpdate(node, name, element);
+ } else if (element.isLocal) {
+ return handleLocalUpdate(node, name, element);
}
return oldVisitSendSet(node);
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698