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

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

Issue 10911062: Codegen support for the argument definition test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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) 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 DartType getType(TypeAnnotation annotation); 8 DartType getType(TypeAnnotation annotation);
9 bool isParameterChecked(Element element);
9 } 10 }
10 11
11 class TreeElementMapping implements TreeElements { 12 class TreeElementMapping implements TreeElements {
12 Map<Node, Element> map; 13 final Map<Node, Element> map;
13 Map<Node, Selector> selectors; 14 final Map<Node, Selector> selectors;
14 Map<TypeAnnotation, DartType> types; 15 final Map<TypeAnnotation, DartType> types;
16 final Set<Element> checkedParameters;
15 17
16 TreeElementMapping() 18 TreeElementMapping()
17 : map = new LinkedHashMap<Node, Element>(), 19 : map = new LinkedHashMap<Node, Element>(),
18 selectors = new LinkedHashMap<Node, Selector>(), 20 selectors = new LinkedHashMap<Node, Selector>(),
19 types = new LinkedHashMap<TypeAnnotation, DartType>(); 21 types = new LinkedHashMap<TypeAnnotation, DartType>(),
22 checkedParameters = new Set<Element>();
20 23
21 operator []=(Node node, Element element) => map[node] = element; 24 operator []=(Node node, Element element) => map[node] = element;
22 operator [](Node node) => map[node]; 25 operator [](Node node) => map[node];
23 void remove(Node node) { map.remove(node); } 26 void remove(Node node) { map.remove(node); }
24 27
25 void setType(TypeAnnotation annotation, DartType type) { 28 void setType(TypeAnnotation annotation, DartType type) {
26 types[annotation] = type; 29 types[annotation] = type;
27 } 30 }
28 31
29 DartType getType(TypeAnnotation annotation) => types[annotation]; 32 DartType getType(TypeAnnotation annotation) => types[annotation];
30 33
31 void setSelector(Node node, Selector selector) { 34 void setSelector(Node node, Selector selector) {
32 selectors[node] = selector; 35 selectors[node] = selector;
33 } 36 }
34 37
35 Selector getSelector(Node node) => selectors[node]; 38 Selector getSelector(Node node) => selectors[node];
39
40 bool isParameterChecked(Element element) {
41 return checkedParameters.contains(element);
42 }
36 } 43 }
37 44
38 class ResolverTask extends CompilerTask { 45 class ResolverTask extends CompilerTask {
39 ResolverTask(Compiler compiler) : super(compiler); 46 ResolverTask(Compiler compiler) : super(compiler);
40 47
41 String get name => 'Resolver'; 48 String get name => 'Resolver';
42 49
43 TreeElements resolve(Element element) { 50 TreeElements resolve(Element element) {
44 return measure(() { 51 return measure(() {
45 ElementKind kind = element.kind; 52 ElementKind kind = element.kind;
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 String operatorString = node.selector.asOperator().source.stringValue; 1347 String operatorString = node.selector.asOperator().source.stringValue;
1341 if (operatorString === 'is' || operatorString === 'as') { 1348 if (operatorString === 'is' || operatorString === 'as') {
1342 assert(node.arguments.tail.isEmpty()); 1349 assert(node.arguments.tail.isEmpty());
1343 resolveTypeTest(node.arguments.head); 1350 resolveTypeTest(node.arguments.head);
1344 resolvedArguments = true; 1351 resolvedArguments = true;
1345 } else if (operatorString === '?') { 1352 } else if (operatorString === '?') {
1346 Element parameter = mapping[node.receiver]; 1353 Element parameter = mapping[node.receiver];
1347 if (parameter === null || parameter.kind !== ElementKind.PARAMETER) { 1354 if (parameter === null || parameter.kind !== ElementKind.PARAMETER) {
1348 error(node.receiver, MessageKind.PARAMETER_NAME_EXPECTED); 1355 error(node.receiver, MessageKind.PARAMETER_NAME_EXPECTED);
1349 } else { 1356 } else {
1350 warning(node, MessageKind.GENERIC, 1357 mapping.checkedParameters.add(parameter);
1351 ['argument definition test operator is not implemented.']);
1352 } 1358 }
1353 } 1359 }
1354 } 1360 }
1355 1361
1356 if (!resolvedArguments) { 1362 if (!resolvedArguments) {
1357 resolveArguments(node.argumentsNode); 1363 resolveArguments(node.argumentsNode);
1358 } 1364 }
1359 1365
1360 // If the selector is null, it means that we will not be generating 1366 // If the selector is null, it means that we will not be generating
1361 // code for this as a send. 1367 // code for this as a send.
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 TopScope(LibraryElement library) : super(null, library); 2666 TopScope(LibraryElement library) : super(null, library);
2661 Element lookup(SourceString name) { 2667 Element lookup(SourceString name) {
2662 return library.find(name); 2668 return library.find(name);
2663 } 2669 }
2664 2670
2665 Element add(Element newElement) { 2671 Element add(Element newElement) {
2666 throw "Cannot add an element in the top scope"; 2672 throw "Cannot add an element in the top scope";
2667 } 2673 }
2668 String toString() => '$element'; 2674 String toString() => '$element';
2669 } 2675 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/js_backend/emitter.dart ('k') | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698