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

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

Issue 10332196: Start working on unparse validation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | « lib/compiler/implementation/apiimpl.dart ('k') | lib/compiler/implementation/dart2js.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 class WorkItem { 5 class WorkItem {
6 final Element element; 6 final Element element;
7 TreeElements resolutionTree; 7 TreeElements resolutionTree;
8 bool allowSpeculativeOptimization = true; 8 bool allowSpeculativeOptimization = true;
9 List<HTypeGuard> guards = const <HTypeGuard>[]; 9 List<HTypeGuard> guards = const <HTypeGuard>[];
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 class Compiler implements DiagnosticListener { 76 class Compiler implements DiagnosticListener {
77 Queue<WorkItem> codegenQueue; 77 Queue<WorkItem> codegenQueue;
78 Universe universe; 78 Universe universe;
79 World world; 79 World world;
80 String assembledCode; 80 String assembledCode;
81 Namer namer; 81 Namer namer;
82 Types types; 82 Types types;
83 bool enableTypeAssertions = false; 83 bool enableTypeAssertions = false;
84 bool unparseValidation = false;
84 85
85 final Tracer tracer; 86 final Tracer tracer;
86 87
87 CompilerTask measuredTask; 88 CompilerTask measuredTask;
88 Element _currentElement; 89 Element _currentElement;
89 LibraryElement coreLibrary; 90 LibraryElement coreLibrary;
90 LibraryElement coreImplLibrary; 91 LibraryElement coreImplLibrary;
91 LibraryElement isolateLibrary; 92 LibraryElement isolateLibrary;
92 LibraryElement jsHelperLibrary; 93 LibraryElement jsHelperLibrary;
93 LibraryElement interceptorsLibrary; 94 LibraryElement interceptorsLibrary;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 if (!codegenQueue.isEmpty()) { 358 if (!codegenQueue.isEmpty()) {
358 internalErrorOnElement(codegenQueue.first().element, 359 internalErrorOnElement(codegenQueue.first().element,
359 "work list is not empty"); 360 "work list is not empty");
360 } 361 }
361 } 362 }
362 363
363 TreeElements analyzeElement(Element element) { 364 TreeElements analyzeElement(Element element) {
364 assert(parser !== null); 365 assert(parser !== null);
365 Node tree = parser.parse(element); 366 Node tree = parser.parse(element);
366 validator.validate(tree); 367 validator.validate(tree);
368 if (unparseValidation) {
369 checkUnparse(element, this);
Anton Muhin 2012/05/16 16:00:58 I considered several other options, but found this
370 }
367 TreeElements elements = resolver.resolve(element); 371 TreeElements elements = resolver.resolve(element);
368 checker.check(tree, elements); 372 checker.check(tree, elements);
369 return elements; 373 return elements;
370 } 374 }
371 375
372 TreeElements analyze(WorkItem work) { 376 TreeElements analyze(WorkItem work) {
373 work.resolutionTree = analyzeElement(work.element); 377 work.resolutionTree = analyzeElement(work.element);
374 return work.resolutionTree; 378 return work.resolutionTree;
375 } 379 }
376 380
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 } 591 }
588 } 592 }
589 593
590 class SourceSpan { 594 class SourceSpan {
591 final Uri uri; 595 final Uri uri;
592 final int begin; 596 final int begin;
593 final int end; 597 final int end;
594 598
595 const SourceSpan(this.uri, this.begin, this.end); 599 const SourceSpan(this.uri, this.begin, this.end);
596 } 600 }
601
602 void checkUnparse(Element element, Compiler compiler) {
ahe 2012/05/21 16:53:29 I don't like having this method here :-) A task a
Anton Muhin 2012/05/21 19:14:38 Done.
603 if (element is! PartialFunctionElement) {
604 // TODO(antonm): consider supporting other kinds of elements.
605 return;
606 }
607
608 PartialFunctionElement originalFunction = element;
609 String unparsed = compiler.parser.parse(originalFunction).unparse(false);
ahe 2012/05/21 16:53:29 I think this should be originalFunction.parseNode(
Anton Muhin 2012/05/21 19:14:38 Done.
610 Token newTokens = new StringScanner(unparsed).tokenize();
611 Token lastToken = newTokens;
612 while (lastToken.info !== EOF_INFO) {
613 lastToken = lastToken.next;
614 }
615
616 PartialFunctionElement newFunction = new PartialFunctionElement(
617 originalFunction.name,
618 newTokens,
619 originalFunction.getOrSet,
ahe 2012/05/21 16:53:29 Unfortunately, this will not work. Everything aft
Anton Muhin 2012/05/21 19:14:38 Done.
620 lastToken,
621 originalFunction.kind,
622 originalFunction.modifiers,
623 originalFunction.enclosingElement);
624
625 Node originalNode = originalFunction.parseNode(compiler);
626 Node newNode = newFunction.parseNode(compiler);
Anton Muhin 2012/05/16 16:00:58 as of now in some cases we cannot even parse unpar
627 // TODO(antonm): add Node comparison.
628 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/apiimpl.dart ('k') | lib/compiler/implementation/dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698