OLD | NEW |
---|---|
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 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 /** | 7 /** |
8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
9 * compiled. | 9 * compiled. |
10 */ | 10 */ |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 ClassElement nullClass; | 128 ClassElement nullClass; |
129 ClassElement listClass; | 129 ClassElement listClass; |
130 ClassElement typeClass; | 130 ClassElement typeClass; |
131 ClassElement mapClass; | 131 ClassElement mapClass; |
132 ClassElement jsInvocationMirrorClass; | 132 ClassElement jsInvocationMirrorClass; |
133 Element assertMethod; | 133 Element assertMethod; |
134 Element identicalFunction; | 134 Element identicalFunction; |
135 Element functionApplyMethod; | 135 Element functionApplyMethod; |
136 Element invokeOnMethod; | 136 Element invokeOnMethod; |
137 | 137 |
138 ClassElement jsStringClass; | |
ahe
2012/11/09 13:45:29
Backend specific?
ngeoffray
2012/11/13 11:45:16
Done.
| |
139 ClassElement objectInterceptorClass; | |
ahe
2012/11/09 13:45:29
Ditto.
ngeoffray
2012/11/13 11:45:16
Done.
| |
140 Element getInterceptorMethod; | |
ahe
2012/11/09 13:45:29
Ditto.
ngeoffray
2012/11/13 11:45:16
Done.
| |
141 | |
142 bool isForeignClass(Element element) { | |
ahe
2012/11/09 13:45:29
Ditto.
ngeoffray
2012/11/13 11:45:16
Done.
| |
143 return element == jsStringClass; | |
144 } | |
145 | |
138 Element get currentElement => _currentElement; | 146 Element get currentElement => _currentElement; |
139 withCurrentElement(Element element, f()) { | 147 withCurrentElement(Element element, f()) { |
140 Element old = currentElement; | 148 Element old = currentElement; |
141 _currentElement = element; | 149 _currentElement = element; |
142 try { | 150 try { |
143 return f(); | 151 return f(); |
144 } on SpannableAssertionFailure catch (ex) { | 152 } on SpannableAssertionFailure catch (ex) { |
145 if (!hasCrashed) { | 153 if (!hasCrashed) { |
146 SourceSpan span = spanFromSpannable(ex.node); | 154 SourceSpan span = spanFromSpannable(ex.node); |
147 reportDiagnostic(span, ex.message, api.Diagnostic.ERROR); | 155 reportDiagnostic(span, ex.message, api.Diagnostic.ERROR); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 identicalFunction = coreLibrary.find(const SourceString('identical')); | 444 identicalFunction = coreLibrary.find(const SourceString('identical')); |
437 | 445 |
438 initializeSpecialClasses(); | 446 initializeSpecialClasses(); |
439 | 447 |
440 functionClass.ensureResolved(this); | 448 functionClass.ensureResolved(this); |
441 functionApplyMethod = | 449 functionApplyMethod = |
442 functionClass.lookupLocalMember(const SourceString('apply')); | 450 functionClass.lookupLocalMember(const SourceString('apply')); |
443 jsInvocationMirrorClass.ensureResolved(this); | 451 jsInvocationMirrorClass.ensureResolved(this); |
444 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember( | 452 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember( |
445 const SourceString('invokeOn')); | 453 const SourceString('invokeOn')); |
454 | |
455 jsStringClass = interceptorsLibrary.find(const SourceString('JSString')); | |
456 objectInterceptorClass = | |
457 interceptorsLibrary.find(const SourceString('ObjectInterceptor')); | |
458 getInterceptorMethod = | |
459 interceptorsLibrary.find(const SourceString('getInterceptor')); | |
446 } | 460 } |
447 | 461 |
448 void loadCoreImplLibrary() { | 462 void loadCoreImplLibrary() { |
449 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); | 463 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); |
450 coreImplLibrary = libraryLoader.loadLibrary(coreImplUri, null, coreImplUri); | 464 coreImplLibrary = libraryLoader.loadLibrary(coreImplUri, null, coreImplUri); |
451 } | 465 } |
452 | 466 |
453 void importHelperLibrary(LibraryElement library) { | 467 void importHelperLibrary(LibraryElement library) { |
454 if (jsHelperLibrary != null) { | 468 if (jsHelperLibrary != null) { |
455 libraryLoader.importLibrary(library, jsHelperLibrary, null); | 469 libraryLoader.importLibrary(library, jsHelperLibrary, null); |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
909 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 923 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
910 // information on assertion errors. | 924 // information on assertion errors. |
911 if (condition is Function){ | 925 if (condition is Function){ |
912 condition = condition(); | 926 condition = condition(); |
913 } | 927 } |
914 if (spannable == null || !condition) { | 928 if (spannable == null || !condition) { |
915 throw new SpannableAssertionFailure(spannable, message); | 929 throw new SpannableAssertionFailure(spannable, message); |
916 } | 930 } |
917 return true; | 931 return true; |
918 } | 932 } |
OLD | NEW |