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

Side by Side Diff: frog/leg/resolver.dart

Issue 9502002: Add FunctionDeclaration node. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files. Created 8 years, 9 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 | frog/leg/scanner/listener.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) 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 } 8 }
9 9
10 class TreeElementMapping implements TreeElements { 10 class TreeElementMapping implements TreeElements {
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 } 693 }
694 694
695 visitFor(For node) { 695 visitFor(For node) {
696 Scope scope = new BlockScope(context); 696 Scope scope = new BlockScope(context);
697 visitIn(node.initializer, scope); 697 visitIn(node.initializer, scope);
698 visitIn(node.condition, scope); 698 visitIn(node.condition, scope);
699 visitIn(node.update, scope); 699 visitIn(node.update, scope);
700 visitLoopBodyIn(node, node.body, scope); 700 visitLoopBodyIn(node, node.body, scope);
701 } 701 }
702 702
703 visitFunctionDeclaration(FunctionDeclaration node) {
704 SourceString name = node.function.name;
705 assert(name !== null);
706 visit(node.function);
707 FunctionElement functionElement = mapping[node.function];
708 // TODO(floitsch): this might lead to two errors complaining about
709 // shadowing.
710 defineElement(node, functionElement);
711 }
712
703 visitFunctionExpression(FunctionExpression node) { 713 visitFunctionExpression(FunctionExpression node) {
704 visit(node.returnType); 714 visit(node.returnType);
705 SourceString name; 715 SourceString name;
706 if (node.name === null) { 716 if (node.name === null) {
707 name = const SourceString(""); 717 name = const SourceString("");
708 } else { 718 } else {
709 name = node.name.asIdentifier().source; 719 name = node.name.asIdentifier().source;
710 } 720 }
711 FunctionElement enclosingElement = new FunctionElement.node( 721 FunctionElement enclosingElement = new FunctionElement.node(
712 name, node, ElementKind.FUNCTION, new Modifiers.empty(), 722 name, node, ElementKind.FUNCTION, new Modifiers.empty(),
713 context.element); 723 context.element);
724 setupFunction(node, enclosingElement);
714 defineElement(node, enclosingElement, doAddToScope: node.name !== null); 725 defineElement(node, enclosingElement, doAddToScope: node.name !== null);
715 setupFunction(node, enclosingElement);
716 726
717 // Run the body in a fresh statement scope. 727 // Run the body in a fresh statement scope.
718 StatementScope oldScope = statementScope; 728 StatementScope oldScope = statementScope;
719 statementScope = new StatementScope(); 729 statementScope = new StatementScope();
720 visit(node.body); 730 visit(node.body);
721 statementScope = oldScope; 731 statementScope = oldScope;
722 732
723 context = context.parent; 733 context = context.parent;
724 return enclosingElement; 734 return enclosingElement;
725 } 735 }
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 class TopScope extends Scope { 1445 class TopScope extends Scope {
1436 LibraryElement get library() => element; 1446 LibraryElement get library() => element;
1437 1447
1438 TopScope(LibraryElement library) : super(null, library); 1448 TopScope(LibraryElement library) : super(null, library);
1439 Element lookup(SourceString name) => library.find(name); 1449 Element lookup(SourceString name) => library.find(name);
1440 1450
1441 Element add(Element element) { 1451 Element add(Element element) {
1442 throw "Cannot add an element in the top scope"; 1452 throw "Cannot add an element in the top scope";
1443 } 1453 }
1444 } 1454 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698