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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 562123002: Support parameter access in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library elements.modelx; 5 library elements.modelx;
6 6
7 import 'elements.dart'; 7 import 'elements.dart';
8 import '../helpers/helpers.dart'; // Included for debug helpers. 8 import '../helpers/helpers.dart'; // Included for debug helpers.
9 import '../tree/tree.dart'; 9 import '../tree/tree.dart';
10 import '../util/util.dart'; 10 import '../util/util.dart';
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 Element get origin { 111 Element get origin {
112 throw new UnsupportedError('origin is not supported on $this'); 112 throw new UnsupportedError('origin is not supported on $this');
113 } 113 }
114 114
115 bool get isSynthesized => false; 115 bool get isSynthesized => false;
116 116
117 bool get isForwardingConstructor => false; 117 bool get isForwardingConstructor => false;
118 118
119 bool get isMixinApplication => false; 119 bool get isMixinApplication => false;
120 120
121 bool get isLocal => false;
122
121 // TODO(johnniwinther): This breaks for libraries (for which enclosing 123 // TODO(johnniwinther): This breaks for libraries (for which enclosing
122 // elements are null) and is invalid for top level variable declarations for 124 // elements are null) and is invalid for top level variable declarations for
123 // which the enclosing element is a VariableDeclarations and not a compilation 125 // which the enclosing element is a VariableDeclarations and not a compilation
124 // unit. 126 // unit.
125 bool get isTopLevel { 127 bool get isTopLevel {
126 return enclosingElement != null && enclosingElement.isCompilationUnit; 128 return enclosingElement != null && enclosingElement.isCompilationUnit;
127 } 129 }
128 130
129 bool get isAssignable { 131 bool get isAssignable {
130 if (isFinal || isConst) return false; 132 if (isFinal || isConst) return false;
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 // TODO(johnniwinther): Remove this when the dart `backend_ast` does not need 1224 // TODO(johnniwinther): Remove this when the dart `backend_ast` does not need
1223 // [Element] for entities. 1225 // [Element] for entities.
1224 LocalVariableElementX.synthetic(String name, 1226 LocalVariableElementX.synthetic(String name,
1225 ExecutableElement enclosingElement, 1227 ExecutableElement enclosingElement,
1226 VariableList variables) 1228 VariableList variables)
1227 : super(name, ElementKind.VARIABLE, enclosingElement, variables, null); 1229 : super(name, ElementKind.VARIABLE, enclosingElement, variables, null);
1228 1230
1229 ExecutableElement get executableContext => enclosingElement; 1231 ExecutableElement get executableContext => enclosingElement;
1230 1232
1231 ExecutableElement get memberContext => executableContext.memberContext; 1233 ExecutableElement get memberContext => executableContext.memberContext;
1234
1235 bool get isLocal => true;
1232 } 1236 }
1233 1237
1234 class FieldElementX extends VariableElementX 1238 class FieldElementX extends VariableElementX
1235 with AnalyzableElementX implements FieldElement { 1239 with AnalyzableElementX implements FieldElement {
1236 List<FunctionElement> nestedClosures = new List<FunctionElement>(); 1240 List<FunctionElement> nestedClosures = new List<FunctionElement>();
1237 1241
1238 FieldElementX(Identifier name, 1242 FieldElementX(Identifier name,
1239 Element enclosingElement, 1243 Element enclosingElement,
1240 VariableList variables) 1244 VariableList variables)
1241 : super(name.source, ElementKind.FIELD, enclosingElement, 1245 : super(name.source, ElementKind.FIELD, enclosingElement,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 this.initializer) 1332 this.initializer)
1329 : super(elementKind, functionDeclaration, definitions, identifier); 1333 : super(elementKind, functionDeclaration, definitions, identifier);
1330 1334
1331 FunctionElement get functionDeclaration => enclosingElement; 1335 FunctionElement get functionDeclaration => enclosingElement;
1332 1336
1333 ExecutableElement get executableContext => enclosingElement; 1337 ExecutableElement get executableContext => enclosingElement;
1334 1338
1335 MemberElement get memberContext => executableContext.memberContext; 1339 MemberElement get memberContext => executableContext.memberContext;
1336 1340
1337 accept(ElementVisitor visitor) => visitor.visitParameterElement(this); 1341 accept(ElementVisitor visitor) => visitor.visitParameterElement(this);
1342
1343 bool get isLocal => true;
1338 } 1344 }
1339 1345
1340 class LocalParameterElementX extends ParameterElementX 1346 class LocalParameterElementX extends ParameterElementX
1341 implements LocalParameterElement { 1347 implements LocalParameterElement {
1342 LocalParameterElementX(FunctionElement functionDeclaration, 1348 LocalParameterElementX(FunctionElement functionDeclaration,
1343 VariableDefinitions definitions, 1349 VariableDefinitions definitions,
1344 Identifier identifier, 1350 Identifier identifier,
1345 Expression initializer) 1351 Expression initializer)
1346 : super(ElementKind.PARAMETER, functionDeclaration, 1352 : super(ElementKind.PARAMETER, functionDeclaration,
1347 definitions, identifier, initializer); 1353 definitions, identifier, initializer);
1348 } 1354 }
1349 1355
1350 /// Parameters in constructors that directly initialize fields. For example: 1356 /// Parameters in constructors that directly initialize fields. For example:
1351 /// `A(this.field)`. 1357 /// `A(this.field)`.
1352 class InitializingFormalElementX extends ParameterElementX 1358 class InitializingFormalElementX extends ParameterElementX
1353 implements InitializingFormalElement { 1359 implements InitializingFormalElement {
1354 FieldElement fieldElement; 1360 FieldElement fieldElement;
1355 1361
1356 InitializingFormalElementX(ConstructorElement constructorDeclaration, 1362 InitializingFormalElementX(ConstructorElement constructorDeclaration,
1357 VariableDefinitions variables, 1363 VariableDefinitions variables,
1358 Identifier identifier, 1364 Identifier identifier,
1359 Expression initializer, 1365 Expression initializer,
1360 this.fieldElement) 1366 this.fieldElement)
1361 : super(ElementKind.INITIALIZING_FORMAL, constructorDeclaration, 1367 : super(ElementKind.INITIALIZING_FORMAL, constructorDeclaration,
1362 variables, identifier, initializer); 1368 variables, identifier, initializer);
1363 1369
1364 accept(ElementVisitor visitor) => visitor.visitFieldParameterElement(this); 1370 accept(ElementVisitor visitor) => visitor.visitFieldParameterElement(this);
1365 1371
1366 MemberElement get memberContext => enclosingElement; 1372 MemberElement get memberContext => enclosingElement;
1373
1374 bool get isLocal => false;
1367 } 1375 }
1368 1376
1369 1377
1370 class AbstractFieldElementX extends ElementX implements AbstractFieldElement { 1378 class AbstractFieldElementX extends ElementX implements AbstractFieldElement {
1371 FunctionElementX getter; 1379 FunctionElementX getter;
1372 FunctionElementX setter; 1380 FunctionElementX setter;
1373 1381
1374 AbstractFieldElementX(String name, Element enclosing) 1382 AbstractFieldElementX(String name, Element enclosing)
1375 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); 1383 : super(name, ElementKind.ABSTRACT_FIELD, enclosing);
1376 1384
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 FunctionExpression parseNode(DiagnosticListener listener) => node; 1640 FunctionExpression parseNode(DiagnosticListener listener) => node;
1633 1641
1634 Token get position { 1642 Token get position {
1635 // Use the name as position if this is not an unnamed closure. 1643 // Use the name as position if this is not an unnamed closure.
1636 if (node.name != null) { 1644 if (node.name != null) {
1637 return node.name.getBeginToken(); 1645 return node.name.getBeginToken();
1638 } else { 1646 } else {
1639 return node.getBeginToken(); 1647 return node.getBeginToken();
1640 } 1648 }
1641 } 1649 }
1650
1651 bool get isLocal => true;
1642 } 1652 }
1643 1653
1644 abstract class ConstructorElementX extends FunctionElementX 1654 abstract class ConstructorElementX extends FunctionElementX
1645 implements ConstructorElement { 1655 implements ConstructorElement {
1646 1656
1647 ConstructorElementX(String name, 1657 ConstructorElementX(String name,
1648 ElementKind kind, 1658 ElementKind kind,
1649 Modifiers modifiers, 1659 Modifiers modifiers,
1650 Element enclosing) 1660 Element enclosing)
1651 : super(name, kind, modifiers, enclosing, false); 1661 : super(name, kind, modifiers, enclosing, false);
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
2684 AstElement get definingElement; 2694 AstElement get definingElement;
2685 2695
2686 bool get hasResolvedAst => definingElement.hasTreeElements; 2696 bool get hasResolvedAst => definingElement.hasTreeElements;
2687 2697
2688 ResolvedAst get resolvedAst { 2698 ResolvedAst get resolvedAst {
2689 return new ResolvedAst(declaration, 2699 return new ResolvedAst(declaration,
2690 definingElement.node, definingElement.treeElements); 2700 definingElement.node, definingElement.treeElements);
2691 } 2701 }
2692 2702
2693 } 2703 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698