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

Side by Side Diff: dart/pkg/compiler/lib/src/elements/modelx.dart

Issue 821593004: Create erroneous element when resolution of initializer fails. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Tests passing locally. Created 5 years, 11 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
« no previous file with comments | « no previous file | dart/pkg/compiler/lib/src/enqueue.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../helpers/helpers.dart'; // Included for debug helpers. 9 import '../helpers/helpers.dart'; // Included for debug helpers.
10 import '../tree/tree.dart'; 10 import '../tree/tree.dart';
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 super.reuseElement(); 1265 super.reuseElement();
1266 nestedClosures.clear(); 1266 nestedClosures.clear();
1267 } 1267 }
1268 1268
1269 FieldElementX copyWithEnclosing(Element enclosingElement) { 1269 FieldElementX copyWithEnclosing(Element enclosingElement) {
1270 return new FieldElementX( 1270 return new FieldElementX(
1271 new Identifier(token), enclosingElement, variables); 1271 new Identifier(token), enclosingElement, variables);
1272 } 1272 }
1273 } 1273 }
1274 1274
1275 /// A field that was synthesized to recover from a compile-time error.
1276 class ErroneousFieldElementX extends ElementX implements FieldElementX {
1277 final VariableList variables;
1278
1279 ErroneousFieldElementX(Identifier name, Element enclosingElement)
1280 : variables = new VariableList(Modifiers.EMPTY)
1281 ..definitions = new VariableDefinitions(
1282 null, Modifiers.EMPTY, new NodeList.singleton(name))
1283 ..type = const DynamicType(),
1284 super(name.source, ElementKind.FIELD, enclosingElement);
1285
1286 VariableDefinitions get definitionsCache => variables.definitions;
1287
1288 set definitionsCache(VariableDefinitions _) {
1289 throw new UnsupportedError("definitionsCache=");
1290 }
1291
1292 bool get hasNode => true;
1293
1294 VariableDefinitions get node => definitionsCache;
1295
1296 bool get hasResolvedAst => false;
1297
1298 ResolvedAst get resolvedAst {
1299 throw new UnsupportedError("resolvedAst");
1300 }
1301
1302 DynamicType get type => const DynamicType();
1303
1304 Token get token => node.getBeginToken();
1305
1306 get initializerCache {
1307 throw new UnsupportedError("initializerCache");
1308 }
1309
1310 set initializerCache(_) {
1311 throw new UnsupportedError("initializerCache=");
1312 }
1313
1314 void createDefinitions(VariableDefinitions definitions) {
1315 throw new UnsupportedError("createDefinitions");
1316 }
1317
1318 get initializer => null;
1319
1320 bool get isErroneous => true;
1321
1322 get nestedClosures {
1323 throw new UnsupportedError("nestedClosures");
1324 }
1325
1326 set nestedClosures(_) {
1327 throw new UnsupportedError("nestedClosures=");
1328 }
1329
1330 // TODO(ahe): Should this throw or do nothing?
1331 accept(ElementVisitor visitor) => visitor.visitFieldElement(this);
1332
1333 // TODO(ahe): Should return the context of the error site?
1334 MemberElement get memberContext => this;
1335
1336 // TODO(ahe): Should return the definingElement of the error site?
1337 AstElement get definingElement => this;
1338
1339 void reuseElement() {
1340 throw new UnsupportedError("reuseElement");
1341 }
1342
1343 FieldElementX copyWithEnclosing(Element enclosingElement) {
1344 throw new UnsupportedError("copyWithEnclosing");
1345 }
1346 }
1347
1275 /// [Element] for a parameter-like element. 1348 /// [Element] for a parameter-like element.
1276 class FormalElementX extends ElementX 1349 class FormalElementX extends ElementX
1277 with AstElementMixin 1350 with AstElementMixin
1278 implements FormalElement { 1351 implements FormalElement {
1279 final VariableDefinitions definitions; 1352 final VariableDefinitions definitions;
1280 final Identifier identifier; 1353 final Identifier identifier;
1281 DartType typeCache; 1354 DartType typeCache;
1282 1355
1283 /** 1356 /**
1284 * Function signature for a variable with a function type. The signature is 1357 * Function signature for a variable with a function type. The signature is
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 AstElement get definingElement; 2903 AstElement get definingElement;
2831 2904
2832 bool get hasResolvedAst => definingElement.hasTreeElements; 2905 bool get hasResolvedAst => definingElement.hasTreeElements;
2833 2906
2834 ResolvedAst get resolvedAst { 2907 ResolvedAst get resolvedAst {
2835 return new ResolvedAst(declaration, 2908 return new ResolvedAst(declaration,
2836 definingElement.node, definingElement.treeElements); 2909 definingElement.node, definingElement.treeElements);
2837 } 2910 }
2838 2911
2839 } 2912 }
OLDNEW
« no previous file with comments | « no previous file | dart/pkg/compiler/lib/src/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698