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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 10701091: Dartdoc and Apidoc updated to use dart2js through the mirror system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed cf. rnystrom's comments. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 284387ffcc078d670f8a98e353c2c67fb0dd3c89..b811b8a4dff3ccd92b08d2d51a07bb6af365c785 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -139,7 +139,7 @@ class ResolverTask extends CompilerTask {
} else if (tree.initializers != null) {
error(tree, MessageKind.FUNCTION_WITH_INITIALIZER);
}
- visitor.visit(tree.body);
+ visitBody(visitor, tree.body);
// Resolve the type annotations encountered in the method.
while (!toResolve.isEmpty()) {
@@ -153,6 +153,10 @@ class ResolverTask extends CompilerTask {
});
}
+ void visitBody(ResolverVisitor visitor, Statement body) {
ahe 2012/08/02 19:56:23 What is the purpose of this method?
+ visitor.visit(body);
+ }
+
void resolveConstructorImplementation(FunctionElement constructor,
FunctionExpression node) {
if (constructor.defaultImplementation !== constructor) return;
@@ -1937,6 +1941,24 @@ class SignatureResolver extends CommonResolverVisitor<Element> {
ElementKind.PARAMETER, enclosingElement, node: node);
}
+ SourceString getParameterName(Send node) {
+ var identifier = node.selector.asIdentifier();
+ if (identifier !== null) {
+ // Normal parameter: [:Type name:].
+ return identifier.source;
+ } else {
+ // Function type parameter: [:void name(Type arg):].
+ var functionExpression = node.selector.asFunctionExpression();
+ if (functionExpression !== null &&
+ functionExpression.name.asIdentifier() !== null) {
+ return functionExpression.name.asIdentifier().source;
+ } else {
+ cancel(node,
+ 'internal error: unimplemented receiver on parameter send');
+ }
+ }
+ }
+
// The only valid [Send] can be in constructors and must be of the form
// [:this.x:] (where [:x:] represents an instance field).
FieldParameterElement visitSend(Send node) {
@@ -1947,11 +1969,7 @@ class SignatureResolver extends CommonResolverVisitor<Element> {
} else if (enclosingElement.kind !== ElementKind.GENERATIVE_CONSTRUCTOR) {
error(node, MessageKind.FIELD_PARAMETER_NOT_ALLOWED, []);
} else {
- if (node.selector.asIdentifier() == null) {
- cancel(node,
- 'internal error: unimplemented receiver on parameter send');
- }
- SourceString name = node.selector.asIdentifier().source;
+ SourceString name = getParameterName(node);
Element fieldElement = currentClass.lookupLocalMember(name);
if (fieldElement === null || fieldElement.kind !== ElementKind.FIELD) {
error(node, MessageKind.NOT_A_FIELD, [name]);
@@ -1960,7 +1978,7 @@ class SignatureResolver extends CommonResolverVisitor<Element> {
}
Element variables = new VariableListElement.node(currentDefinitions,
ElementKind.VARIABLE_LIST, enclosingElement);
- element = new FieldParameterElement(node.selector.asIdentifier().source,
+ element = new FieldParameterElement(name,
fieldElement, variables, enclosingElement, node);
}
return element;

Powered by Google App Engine
This is Rietveld 408576698