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

Unified Diff: dart/lib/compiler/implementation/scanner/class_element_parser.dart

Issue 10870066: Support unary - operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix unparser to handle that negate is no longer a keyword. 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 side-by-side diff with in-line comments
Download patch
Index: dart/lib/compiler/implementation/scanner/class_element_parser.dart
diff --git a/dart/lib/compiler/implementation/scanner/class_element_parser.dart b/dart/lib/compiler/implementation/scanner/class_element_parser.dart
index bf0c1ddc6f35765723ab3ac02ed8ad523c41da23..545688c29179752ebfd51910d1736b4624e3fba8 100644
--- a/dart/lib/compiler/implementation/scanner/class_element_parser.dart
+++ b/dart/lib/compiler/implementation/scanner/class_element_parser.dart
@@ -32,22 +32,27 @@ class PartialClassElement extends ClassElement {
super.resolutionState = state;
}
- ClassNode parseNode(DiagnosticListener diagnosticListener) {
+ ClassNode parseNode(Compiler compiler) {
if (cachedNode != null) return cachedNode;
- // TODO(ahe): Measure these tasks.
- MemberListener listener = new MemberListener(diagnosticListener, this);
- Parser parser = new ClassElementParser(listener);
- Token token = parser.parseTopLevelDeclaration(beginToken);
- assert(token === endToken.next);
- cachedNode = listener.popNode();
- assert(listener.nodes.isEmpty());
- if (isPatched) {
- // TODO(lrn): Perhaps extract functionality so it doesn't need compiler.
- Compiler compiler = diagnosticListener;
- ClassNode patchNode = compiler.patchParser.parsePatchClassNode(patch);
- Link<Element> patches = patch.localMembers;
- compiler.applyContainerPatch(this, patches);
- }
+ compiler.withCurrentElement(this, () {
+ compiler.parser.measure(() {
+ MemberListener listener = new MemberListener(compiler, this);
+ Parser parser = new ClassElementParser(listener);
+ Token token = parser.parseTopLevelDeclaration(beginToken);
+ assert(token === endToken.next);
+ cachedNode = listener.popNode();
+ assert(listener.nodes.isEmpty());
+ });
+ compiler.patchParser.measure(() {
+ if (isPatched) {
+ // TODO(lrn): Perhaps extract functionality so it doesn't
+ // need compiler.
+ ClassNode patchNode = compiler.patchParser.parsePatchClassNode(patch);
+ Link<Element> patches = patch.localMembers;
+ compiler.applyContainerPatch(this, patches);
+ }
+ });
+ });
return cachedNode;
}
@@ -114,8 +119,13 @@ class MemberListener extends NodeListener {
if (send === null) return methodName.asIdentifier().source;
Identifier receiver = send.receiver.asIdentifier();
Identifier selector = send.selector.asIdentifier();
- if (selector.asOperator() !== null) {
- return Elements.constructOperatorName(receiver.source, selector.source);
+ Operator operator = selector.asOperator();
+ if (operator !== null) {
+ assert(receiver.source.stringValue === 'operator');
+ // TODO(ahe): It is a hack to compare to ')', but it beats
+ // parsing the node.
+ bool isUnary = operator.token.next.next.stringValue === ')';
+ return Elements.constructOperatorName(operator.source, isUnary);
} else {
return Elements.constructConstructorName(receiver.source,
selector.source);
« no previous file with comments | « dart/lib/compiler/implementation/lib/interceptors.dart ('k') | dart/lib/compiler/implementation/scanner/keyword.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698