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

Side by Side Diff: dart/lib/compiler/implementation/resolver.dart

Issue 10870010: Evaluate compile-time constants of metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review commens Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 interface TreeElements { 5 interface TreeElements {
6 Element operator[](Node node); 6 Element operator[](Node node);
7 Selector getSelector(Send send); 7 Selector getSelector(Send send);
8 Type getType(TypeAnnotation annotation); 8 Type getType(TypeAnnotation annotation);
9 } 9 }
10 10
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 * 250 *
251 * Before calling this method, [element] was constructed by the 251 * Before calling this method, [element] was constructed by the
252 * scanner and most fields are null or empty. This method fills in 252 * scanner and most fields are null or empty. This method fills in
253 * these fields and also ensure that the supertypes of [element] are 253 * these fields and also ensure that the supertypes of [element] are
254 * resolved. 254 * resolved.
255 * 255 *
256 * Warning: Do not call this method directly. Instead use 256 * Warning: Do not call this method directly. Instead use
257 * [:element.ensureResolved(compiler):]. 257 * [:element.ensureResolved(compiler):].
258 */ 258 */
259 void resolveClass(ClassElement element) { 259 void resolveClass(ClassElement element) {
260 assert(element.resolutionState == ClassElement.STATE_NOT_STARTED);
261 element.resolutionState = ClassElement.STATE_STARTED;
262 compiler.withCurrentElement(element, () => measure(() { 260 compiler.withCurrentElement(element, () => measure(() {
261 assert(element.resolutionState == ClassElement.STATE_NOT_STARTED);
262 element.resolutionState = ClassElement.STATE_STARTED;
263 ClassNode tree = element.parseNode(compiler); 263 ClassNode tree = element.parseNode(compiler);
264 loadSupertypes(element, tree); 264 loadSupertypes(element, tree);
265 265
266 ClassResolverVisitor visitor = 266 ClassResolverVisitor visitor =
267 new ClassResolverVisitor(compiler, element); 267 new ClassResolverVisitor(compiler, element);
268 visitor.visit(tree); 268 visitor.visit(tree);
269 element.resolutionState = ClassElement.STATE_DONE; 269 element.resolutionState = ClassElement.STATE_DONE;
270 })); 270 }));
271 } 271 }
272 272
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 !link.isEmpty(); 392 !link.isEmpty();
393 link = link.tail) { 393 link = link.tail) {
394 parameterTypes.addLast(link.head.computeType(compiler)); 394 parameterTypes.addLast(link.head.computeType(compiler));
395 // TODO(karlklose): optional parameters. 395 // TODO(karlklose): optional parameters.
396 } 396 }
397 return new FunctionType(signature.returnType, 397 return new FunctionType(signature.returnType,
398 parameterTypes.toLink(), 398 parameterTypes.toLink(),
399 element); 399 element);
400 } 400 }
401 401
402 void resolveMetadataAnnotation(MetadataAnnotation annotation) {
403 compiler.withCurrentElement(annotation.annotatedElement, () => measure(() {
404 assert(annotation.resolutionState == ClassElement.STATE_NOT_STARTED);
405 annotation.resolutionState = ClassElement.STATE_STARTED;
406
407 Node node = annotation.parseNode(compiler);
408 ResolverVisitor visitor =
409 new ResolverVisitor(compiler, annotation.annotatedElement);
410 node.accept(visitor);
411 annotation.value = compiler.constantHandler.compileNodeWithDefinitions(
412 node, visitor.mapping);
413
414 annotation.resolutionState = ClassElement.STATE_DONE;
415 }));
416 }
417
402 error(Node node, MessageKind kind, [arguments = const []]) { 418 error(Node node, MessageKind kind, [arguments = const []]) {
403 ResolutionError message = new ResolutionError(kind, arguments); 419 ResolutionError message = new ResolutionError(kind, arguments);
404 compiler.reportError(node, message); 420 compiler.reportError(node, message);
405 } 421 }
406 } 422 }
407 423
408 class InitializerResolver { 424 class InitializerResolver {
409 final ResolverVisitor visitor; 425 final ResolverVisitor visitor;
410 final Map<SourceString, Node> initialized; 426 final Map<SourceString, Node> initialized;
411 Link<Node> initializers; 427 Link<Node> initializers;
(...skipping 2114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2526 TopScope(LibraryElement library) : super(null, library); 2542 TopScope(LibraryElement library) : super(null, library);
2527 Element lookup(SourceString name) { 2543 Element lookup(SourceString name) {
2528 return library.find(name); 2544 return library.find(name);
2529 } 2545 }
2530 2546
2531 Element add(Element newElement) { 2547 Element add(Element newElement) {
2532 throw "Cannot add an element in the top scope"; 2548 throw "Cannot add an element in the top scope";
2533 } 2549 }
2534 String toString() => '$element'; 2550 String toString() => '$element';
2535 } 2551 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698