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

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

Issue 10905305: Patch refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased. Created 8 years, 2 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 5
6 /** 6 /**
7 * If true, print a warning for each method that was resolved, but not 7 * If true, print a warning for each method that was resolved, but not
8 * compiled. 8 * compiled.
9 */ 9 */
10 const bool REPORT_EXCESS_RESOLUTION = false; 10 const bool REPORT_EXCESS_RESOLUTION = false;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 return; 302 return;
303 } 303 }
304 enabledNoSuchMethod = true; 304 enabledNoSuchMethod = true;
305 Selector selector = new Selector.noSuchMethod(); 305 Selector selector = new Selector.noSuchMethod();
306 enqueuer.resolution.registerInvocation(NO_SUCH_METHOD, selector); 306 enqueuer.resolution.registerInvocation(NO_SUCH_METHOD, selector);
307 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, selector); 307 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, selector);
308 } 308 }
309 309
310 void enableIsolateSupport(LibraryElement element) { 310 void enableIsolateSupport(LibraryElement element) {
311 // TODO(ahe): Move this method to Enqueuer. 311 // TODO(ahe): Move this method to Enqueuer.
312 isolateLibrary = element; 312 isolateLibrary = element.patch;
313 enqueuer.resolution.addToWorkList(element.find(START_ROOT_ISOLATE)); 313 enqueuer.resolution.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE));
314 enqueuer.resolution.addToWorkList( 314 enqueuer.resolution.addToWorkList(
315 element.find(const SourceString('_currentIsolate'))); 315 isolateLibrary.find(const SourceString('_currentIsolate')));
316 enqueuer.resolution.addToWorkList( 316 enqueuer.resolution.addToWorkList(
317 element.find(const SourceString('_callInIsolate'))); 317 isolateLibrary.find(const SourceString('_callInIsolate')));
318 enqueuer.codegen.addToWorkList(element.find(START_ROOT_ISOLATE)); 318 enqueuer.codegen.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE));
319 } 319 }
320 320
321 bool hasIsolateSupport() => isolateLibrary !== null; 321 bool hasIsolateSupport() => isolateLibrary !== null;
322 322
323 void onLibraryLoaded(LibraryElement library, Uri uri) { 323 void onLibraryLoaded(LibraryElement library, Uri uri) {
324 if (dynamicClass !== null) { 324 if (dynamicClass !== null) {
325 // When loading the built-in libraries, dynamicClass is null. We 325 // When loading the built-in libraries, dynamicClass is null. We
326 // take advantage of this as core and coreimpl import js_helper 326 // take advantage of this as core and coreimpl import js_helper
327 // and see Dynamic this way. 327 // and see Dynamic this way.
328 withCurrentElement(dynamicClass, () { 328 withCurrentElement(dynamicClass, () {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 originalElement = originalField.getter; 411 originalElement = originalField.getter;
412 } else { 412 } else {
413 originalElement = originalField.setter; 413 originalElement = originalField.setter;
414 } 414 }
415 } 415 }
416 if (originalElement === null) { 416 if (originalElement === null) {
417 if (isPatchElement(patchElement)) { 417 if (isPatchElement(patchElement)) {
418 internalError("Cannot patch non-existing member '" 418 internalError("Cannot patch non-existing member '"
419 "${patchElement.name.slowToString()}'."); 419 "${patchElement.name.slowToString()}'.");
420 } 420 }
421 original.addMember(clonePatch(patchElement, original), this);
422 } else { 421 } else {
423 patchMember(originalElement, patchElement); 422 patchMember(originalElement, patchElement);
424 } 423 }
425 patches = patches.tail; 424 patches = patches.tail;
426 } 425 }
427 } 426 }
428 427
429 bool isPatchElement(Element element) { 428 bool isPatchElement(Element element) {
430 // TODO(lrn): More checks needed if we introduce metadata for real. 429 // TODO(lrn): More checks needed if we introduce metadata for real.
431 // In that case, it must have the identifier "native" as metadata. 430 // In that case, it must have the identifier "native" as metadata.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 if (element.isPatched) { 485 if (element.isPatched) {
487 internalError("Trying to patch a function more than once.", 486 internalError("Trying to patch a function more than once.",
488 element: element); 487 element: element);
489 } 488 }
490 if (element.cachedNode !== null) { 489 if (element.cachedNode !== null) {
491 internalError("Trying to patch an already compiled function.", 490 internalError("Trying to patch an already compiled function.",
492 element: element); 491 element: element);
493 } 492 }
494 // Don't just assign the patch field. This also updates the cachedNode. 493 // Don't just assign the patch field. This also updates the cachedNode.
495 element.setPatch(patchElement); 494 element.setPatch(patchElement);
495 patchElement.origin = element;
496 } 496 }
497 497
498 /** 498 /**
499 * Get an [Uri] pointing to a patch for the dart: library with 499 * Get an [Uri] pointing to a patch for the dart: library with
500 * the given path. Returns null if there is no patch. 500 * the given path. Returns null if there is no patch.
501 */ 501 */
502 abstract Uri resolvePatchUri(String dartLibraryPath); 502 abstract Uri resolvePatchUri(String dartLibraryPath);
503 503
504 /** Define the JS helper functions in the given library. */ 504 /** Define the JS helper functions in the given library. */
505 void addForeignFunctions(LibraryElement library) { 505 void addForeignFunctions(LibraryElement library) {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 // error" or "not implemented yet", so the vicinity is good 830 // error" or "not implemented yet", so the vicinity is good
831 // enough for now. 831 // enough for now.
832 element = element.enclosingElement; 832 element = element.enclosingElement;
833 // TODO(ahe): I plan to overhaul this infrastructure anyways. 833 // TODO(ahe): I plan to overhaul this infrastructure anyways.
834 } 834 }
835 if (element === null) { 835 if (element === null) {
836 element = currentElement; 836 element = currentElement;
837 } 837 }
838 Token position = element.position(); 838 Token position = element.position();
839 Uri uri = element.getCompilationUnit().script.uri; 839 Uri uri = element.getCompilationUnit().script.uri;
840
841 // TODO(ager,johnniwinther): The patch support should be
842 // reworked to allow us to get rid of this.
843 if (element.isPatched) {
844 // TODO(johnniwinther,karlklose): create a subtype of Element for
845 // patchable elements or move the patch field to Element.
846 var patched = element;
847 position = patched.patch.position();
848 uri = patched.patch.getCompilationUnit().script.uri;
849 }
850
851 return (position === null) 840 return (position === null)
852 ? new SourceSpan(uri, 0, 0) 841 ? new SourceSpan(uri, 0, 0)
853 : spanFromTokens(position, position, uri); 842 : spanFromTokens(position, position, uri);
854 } 843 }
855 844
856 Script readScript(Uri uri, [ScriptTag node]) { 845 Script readScript(Uri uri, [ScriptTag node]) {
857 unimplemented('Compiler.readScript'); 846 unimplemented('Compiler.readScript');
858 } 847 }
859 848
860 String get legDirectory { 849 String get legDirectory {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 * information in the generated error message. 940 * information in the generated error message.
952 */ 941 */
953 bool invariant(Spannable spannable, var condition, {String message: null}) { 942 bool invariant(Spannable spannable, var condition, {String message: null}) {
954 // TODO(johnniwinther): Use [spannable] and [message] to provide better 943 // TODO(johnniwinther): Use [spannable] and [message] to provide better
955 // information on assertion errors. 944 // information on assertion errors.
956 if (condition is Function){ 945 if (condition is Function){
957 condition = condition(); 946 condition = condition();
958 } 947 }
959 return spannable != null && condition; 948 return spannable != null && condition;
960 } 949 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698