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

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: Replaced includeInjectedMembers by implementation 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 return; 306 return;
307 } 307 }
308 enabledNoSuchMethod = true; 308 enabledNoSuchMethod = true;
309 Selector selector = new Selector.noSuchMethod(); 309 Selector selector = new Selector.noSuchMethod();
310 enqueuer.resolution.registerInvocation(NO_SUCH_METHOD, selector); 310 enqueuer.resolution.registerInvocation(NO_SUCH_METHOD, selector);
311 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, selector); 311 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, selector);
312 } 312 }
313 313
314 void enableIsolateSupport(LibraryElement element) { 314 void enableIsolateSupport(LibraryElement element) {
315 // TODO(ahe): Move this method to Enqueuer. 315 // TODO(ahe): Move this method to Enqueuer.
316 isolateLibrary = element; 316 isolateLibrary = element.patch;
317 enqueuer.resolution.addToWorkList(element.find(START_ROOT_ISOLATE)); 317 enqueuer.resolution.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE));
318 enqueuer.resolution.addToWorkList( 318 enqueuer.resolution.addToWorkList(
319 element.find(const SourceString('_currentIsolate'))); 319 isolateLibrary.find(const SourceString('_currentIsolate')));
320 enqueuer.resolution.addToWorkList( 320 enqueuer.resolution.addToWorkList(
321 element.find(const SourceString('_callInIsolate'))); 321 isolateLibrary.find(const SourceString('_callInIsolate')));
322 enqueuer.codegen.addToWorkList(element.find(START_ROOT_ISOLATE)); 322 enqueuer.codegen.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE));
323 } 323 }
324 324
325 bool hasIsolateSupport() => isolateLibrary !== null; 325 bool hasIsolateSupport() => isolateLibrary !== null;
326 326
327 void onLibraryLoaded(LibraryElement library, Uri uri) { 327 void onLibraryLoaded(LibraryElement library, Uri uri) {
328 if (dynamicClass !== null) { 328 if (dynamicClass !== null) {
329 // When loading the built-in libraries, dynamicClass is null. We 329 // When loading the built-in libraries, dynamicClass is null. We
330 // take advantage of this as core and coreimpl import js_helper 330 // take advantage of this as core and coreimpl import js_helper
331 // and see Dynamic this way. 331 // and see Dynamic this way.
332 withCurrentElement(dynamicClass, () { 332 withCurrentElement(dynamicClass, () {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 originalElement = originalField.getter; 415 originalElement = originalField.getter;
416 } else { 416 } else {
417 originalElement = originalField.setter; 417 originalElement = originalField.setter;
418 } 418 }
419 } 419 }
420 if (originalElement === null) { 420 if (originalElement === null) {
421 if (isPatchElement(patchElement)) { 421 if (isPatchElement(patchElement)) {
422 internalError("Cannot patch non-existing member '" 422 internalError("Cannot patch non-existing member '"
423 "${patchElement.name.slowToString()}'."); 423 "${patchElement.name.slowToString()}'.");
424 } 424 }
425 original.addMember(clonePatch(patchElement, original), this);
426 } else { 425 } else {
427 patchMember(originalElement, patchElement); 426 patchMember(originalElement, patchElement);
428 } 427 }
429 patches = patches.tail; 428 patches = patches.tail;
430 } 429 }
431 } 430 }
432 431
433 bool isPatchElement(Element element) { 432 bool isPatchElement(Element element) {
434 // TODO(lrn): More checks needed if we introduce metadata for real. 433 // TODO(lrn): More checks needed if we introduce metadata for real.
435 // In that case, it must have the identifier "native" as metadata. 434 // In that case, it must have the identifier "native" as metadata.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 if (element.isPatched) { 489 if (element.isPatched) {
491 internalError("Trying to patch a function more than once.", 490 internalError("Trying to patch a function more than once.",
492 element: element); 491 element: element);
493 } 492 }
494 if (element.cachedNode !== null) { 493 if (element.cachedNode !== null) {
495 internalError("Trying to patch an already compiled function.", 494 internalError("Trying to patch an already compiled function.",
496 element: element); 495 element: element);
497 } 496 }
498 // Don't just assign the patch field. This also updates the cachedNode. 497 // Don't just assign the patch field. This also updates the cachedNode.
499 element.setPatch(patchElement); 498 element.setPatch(patchElement);
499 patchElement.origin = element;
500 } 500 }
501 501
502 /** 502 /**
503 * Get an [Uri] pointing to a patch for the dart: library with 503 * Get an [Uri] pointing to a patch for the dart: library with
504 * the given path. Returns null if there is no patch. 504 * the given path. Returns null if there is no patch.
505 */ 505 */
506 abstract Uri resolvePatchUri(String dartLibraryPath); 506 abstract Uri resolvePatchUri(String dartLibraryPath);
507 507
508 /** Define the JS helper functions in the given library. */ 508 /** Define the JS helper functions in the given library. */
509 void addForeignFunctions(LibraryElement library) { 509 void addForeignFunctions(LibraryElement library) {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 // error" or "not implemented yet", so the vicinity is good 855 // error" or "not implemented yet", so the vicinity is good
856 // enough for now. 856 // enough for now.
857 element = element.enclosingElement; 857 element = element.enclosingElement;
858 // TODO(ahe): I plan to overhaul this infrastructure anyways. 858 // TODO(ahe): I plan to overhaul this infrastructure anyways.
859 } 859 }
860 if (element === null) { 860 if (element === null) {
861 element = currentElement; 861 element = currentElement;
862 } 862 }
863 Token position = element.position(); 863 Token position = element.position();
864 Uri uri = element.getCompilationUnit().script.uri; 864 Uri uri = element.getCompilationUnit().script.uri;
865
866 // TODO(ager,johnniwinther): The patch support should be
867 // reworked to allow us to get rid of this.
868 if (element.isPatched) {
869 position = element.patch.position();
870 uri = element.patch.getCompilationUnit().script.uri;
871 }
872
873 return (position === null) 865 return (position === null)
874 ? new SourceSpan(uri, 0, 0) 866 ? new SourceSpan(uri, 0, 0)
875 : spanFromTokens(position, position, uri); 867 : spanFromTokens(position, position, uri);
876 } 868 }
877 869
878 Script readScript(Uri uri, [ScriptTag node]) { 870 Script readScript(Uri uri, [ScriptTag node]) {
879 unimplemented('Compiler.readScript'); 871 unimplemented('Compiler.readScript');
880 } 872 }
881 873
882 String get legDirectory { 874 String get legDirectory {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 * information in the generated error message. 965 * information in the generated error message.
974 */ 966 */
975 bool invariant(Spannable spannable, var condition, {String message: null}) { 967 bool invariant(Spannable spannable, var condition, {String message: null}) {
976 // TODO(johnniwinther): Use [spannable] and [message] to provide better 968 // TODO(johnniwinther): Use [spannable] and [message] to provide better
977 // information on assertion errors. 969 // information on assertion errors.
978 if (condition is Function){ 970 if (condition is Function){
979 condition = condition(); 971 condition = condition();
980 } 972 }
981 return spannable != null && condition; 973 return spannable != null && condition;
982 } 974 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698