| OLD | NEW |
| 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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 visitLiteralNull(LiteralNull node) { | 715 visitLiteralNull(LiteralNull node) { |
| 716 } | 716 } |
| 717 | 717 |
| 718 visitNodeList(NodeList node) { | 718 visitNodeList(NodeList node) { |
| 719 for (Link<Node> link = node.nodes; !link.isEmpty(); link = link.tail) { | 719 for (Link<Node> link = node.nodes; !link.isEmpty(); link = link.tail) { |
| 720 visit(link.head); | 720 visit(link.head); |
| 721 } | 721 } |
| 722 } | 722 } |
| 723 | 723 |
| 724 visitOperator(Operator node) { | 724 visitOperator(Operator node) { |
| 725 cancel(node, "Unimplemented"); | 725 compiler.unimplemented('operator', node: node); |
| 726 } | 726 } |
| 727 | 727 |
| 728 visitReturn(Return node) { | 728 visitReturn(Return node) { |
| 729 visit(node.expression); | 729 visit(node.expression); |
| 730 } | 730 } |
| 731 | 731 |
| 732 visitThrow(Throw node) { | 732 visitThrow(Throw node) { |
| 733 visit(node.expression); | 733 visit(node.expression); |
| 734 } | 734 } |
| 735 | 735 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 ClassElement resolveTypeRequired(Node node) { | 799 ClassElement resolveTypeRequired(Node node) { |
| 800 bool old = typeRequired; | 800 bool old = typeRequired; |
| 801 typeRequired = true; | 801 typeRequired = true; |
| 802 ClassElement cls = visit(node); | 802 ClassElement cls = visit(node); |
| 803 typeRequired = old; | 803 typeRequired = old; |
| 804 return cls; | 804 return cls; |
| 805 } | 805 } |
| 806 | 806 |
| 807 visitModifiers(Modifiers node) { | 807 visitModifiers(Modifiers node) { |
| 808 // TODO(ngeoffray): Implement this. | 808 // TODO(ngeoffray): Implement this. |
| 809 cancel(node, 'unimplemented'); | 809 compiler.unimplemented('modifiers', node: node); |
| 810 } | 810 } |
| 811 | 811 |
| 812 visitLiteralList(LiteralList node) { | 812 visitLiteralList(LiteralList node) { |
| 813 if (node.isConst()) cancel(node, 'const literal lists are not implemented'); | 813 if (node.isConst()) cancel(node, 'const literal lists are not implemented'); |
| 814 visit(node.elements); | 814 visit(node.elements); |
| 815 } | 815 } |
| 816 | 816 |
| 817 visitConditional(Conditional node) { | 817 visitConditional(Conditional node) { |
| 818 node.visitChildren(this); | 818 node.visitChildren(this); |
| 819 } | 819 } |
| 820 | 820 |
| 821 visitStringInterpolation(StringInterpolation node) { | 821 visitStringInterpolation(StringInterpolation node) { |
| 822 node.visitChildren(this); | 822 node.visitChildren(this); |
| 823 } | 823 } |
| 824 | 824 |
| 825 visitStringInterpolationPart(StringInterpolationPart node) { | 825 visitStringInterpolationPart(StringInterpolationPart node) { |
| 826 node.visitChildren(this); | 826 node.visitChildren(this); |
| 827 } | 827 } |
| 828 | 828 |
| 829 visitBreakStatement(BreakStatement node) { | 829 visitBreakStatement(BreakStatement node) { |
| 830 cancel(node, 'unimplemented'); | 830 compiler.unimplemented('break', node: node); |
| 831 } | 831 } |
| 832 | 832 |
| 833 visitContinueStatement(ContinueStatement node) { | 833 visitContinueStatement(ContinueStatement node) { |
| 834 cancel(node, 'unimplemented'); | 834 compiler.unimplemented('continue', node: node); |
| 835 } | 835 } |
| 836 | 836 |
| 837 visitForInStatement(ForInStatement node) { | 837 visitForInStatement(ForInStatement node) { |
| 838 visit(node.expression); | 838 visit(node.expression); |
| 839 Scope scope = new BlockScope(context); | 839 Scope scope = new BlockScope(context); |
| 840 Node declaration = node.declaredIdentifier; | 840 Node declaration = node.declaredIdentifier; |
| 841 visitIn(declaration, scope); | 841 visitIn(declaration, scope); |
| 842 visitIn(node.body, scope); | 842 visitIn(node.body, scope); |
| 843 // TODO(lrn): Also allow a single identifier. | 843 // TODO(lrn): Also allow a single identifier. |
| 844 if ((declaration is !Send || declaration.asSend().selector is !Identifier) | 844 if ((declaration is !Send || declaration.asSend().selector is !Identifier) |
| 845 && (declaration is !VariableDefinitions || | 845 && (declaration is !VariableDefinitions || |
| 846 !declaration.asVariableDefinitions().definitions.nodes.tail.isEmpty())) | 846 !declaration.asVariableDefinitions().definitions.nodes.tail.isEmpty())) |
| 847 { | 847 { |
| 848 // The variable declaration is either not an identifier, not a | 848 // The variable declaration is either not an identifier, not a |
| 849 // declaration, or it's declaring more than one variable. | 849 // declaration, or it's declaring more than one variable. |
| 850 error(node.declaredIdentifier, MessageKind.INVALID_FOR_IN, []); | 850 error(node.declaredIdentifier, MessageKind.INVALID_FOR_IN, []); |
| 851 } | 851 } |
| 852 } | 852 } |
| 853 | 853 |
| 854 visitLabelledStatement(LabelledStatement node) { | 854 visitLabelledStatement(LabelledStatement node) { |
| 855 cancel(node, 'unimplemented'); | 855 compiler.unimplemented('label', node: node); |
| 856 } | 856 } |
| 857 | 857 |
| 858 visitLiteralMap(LiteralMap node) { | 858 visitLiteralMap(LiteralMap node) { |
| 859 cancel(node, 'unimplemented'); | 859 compiler.unimplemented('map', node: node); |
| 860 } | 860 } |
| 861 | 861 |
| 862 visitLiteralMapEntry(LiteralMapEntry node) { | 862 visitLiteralMapEntry(LiteralMapEntry node) { |
| 863 cancel(node, 'unimplemented'); | 863 compiler.unimplemented('map entry', node: node); |
| 864 } | 864 } |
| 865 | 865 |
| 866 visitNamedArgument(NamedArgument node) { | 866 visitNamedArgument(NamedArgument node) { |
| 867 visit(node.expression); | 867 visit(node.expression); |
| 868 } | 868 } |
| 869 | 869 |
| 870 visitSwitchStatement(SwitchStatement node) { | 870 visitSwitchStatement(SwitchStatement node) { |
| 871 cancel(node, 'unimplemented'); | 871 compiler.unimplemented('switch', node: node); |
| 872 } | 872 } |
| 873 | 873 |
| 874 visitTryStatement(TryStatement node) { | 874 visitTryStatement(TryStatement node) { |
| 875 cancel(node, 'unimplemented'); | 875 compiler.unimplemented('try', node: node); |
| 876 } | |
| 877 | |
| 878 visitScriptTag(ScriptTag node) { | |
| 879 cancel(node, 'unimplemented'); | |
| 880 } | 876 } |
| 881 | 877 |
| 882 visitCatchBlock(CatchBlock node) { | 878 visitCatchBlock(CatchBlock node) { |
| 883 cancel(node, 'unimplemented'); | 879 compiler.unimplemented('catch', node: node); |
| 884 } | 880 } |
| 885 | 881 |
| 886 visitTypedef(Typedef node) { | 882 visitTypedef(Typedef node) { |
| 887 cancel(node, 'unimplemented'); | 883 compiler.unimplemented('typedef', node: node); |
| 888 } | 884 } |
| 889 } | 885 } |
| 890 | 886 |
| 891 // TODO(ahe): Frog cannot handle generic types. | 887 // TODO(ahe): Frog cannot handle generic types. |
| 892 class ClassResolverVisitor extends AbstractVisitor/* <Type> */ { | 888 class ClassResolverVisitor extends AbstractVisitor/* <Type> */ { |
| 893 Compiler compiler; | 889 Compiler compiler; |
| 894 Scope context; | 890 Scope context; |
| 895 | 891 |
| 896 ClassResolverVisitor(Compiler compiler, LibraryElement library) | 892 ClassResolverVisitor(Compiler compiler, LibraryElement library) |
| 897 : this.compiler = compiler, context = new TopScope(library); | 893 : this.compiler = compiler, context = new TopScope(library); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 class TopScope extends Scope { | 1170 class TopScope extends Scope { |
| 1175 LibraryElement get library() => element; | 1171 LibraryElement get library() => element; |
| 1176 | 1172 |
| 1177 TopScope(LibraryElement library) : super(null, library); | 1173 TopScope(LibraryElement library) : super(null, library); |
| 1178 Element lookup(SourceString name) => library.find(name); | 1174 Element lookup(SourceString name) => library.find(name); |
| 1179 | 1175 |
| 1180 Element add(Element element) { | 1176 Element add(Element element) { |
| 1181 throw "Cannot add an element in the top scope"; | 1177 throw "Cannot add an element in the top scope"; |
| 1182 } | 1178 } |
| 1183 } | 1179 } |
| OLD | NEW |