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

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

Issue 10447088: Add a new magic element type for annotating types that have Javascript array behavior. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 ClassElement dynamicClass; 101 ClassElement dynamicClass;
102 ClassElement boolClass; 102 ClassElement boolClass;
103 ClassElement numClass; 103 ClassElement numClass;
104 ClassElement intClass; 104 ClassElement intClass;
105 ClassElement doubleClass; 105 ClassElement doubleClass;
106 ClassElement stringClass; 106 ClassElement stringClass;
107 ClassElement functionClass; 107 ClassElement functionClass;
108 ClassElement nullClass; 108 ClassElement nullClass;
109 ClassElement listClass; 109 ClassElement listClass;
110 110
111 /**
112 * Interface used to determine if an object has the JavaScript
113 * indexing behavior. The interface is only visible to specific
114 * libraries.
115 */
116 ClassElement javaScriptIndexingBehaviorInterface;
ahe 2012/06/12 18:30:04 How about jsIndexingBehaviorInterface?
ngeoffray 2012/06/13 13:02:42 Done.
117
111 Element get currentElement() => _currentElement; 118 Element get currentElement() => _currentElement;
112 withCurrentElement(Element element, f()) { 119 withCurrentElement(Element element, f()) {
113 Element old = currentElement; 120 Element old = currentElement;
114 _currentElement = element; 121 _currentElement = element;
115 try { 122 try {
116 return f(); 123 return f();
117 } catch (CompilerCancelledException ex) { 124 } catch (CompilerCancelledException ex) {
118 throw; 125 throw;
119 } catch (var ex) { 126 } catch (var ex) {
120 unhandledExceptionOnElement(element); 127 unhandledExceptionOnElement(element);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 scanner.importLibrary(coreImplLibrary, coreLibrary, null); 329 scanner.importLibrary(coreImplLibrary, coreLibrary, null);
323 scanner.importLibrary(jsHelperLibrary, coreLibrary, null); 330 scanner.importLibrary(jsHelperLibrary, coreLibrary, null);
324 scanner.importLibrary(interceptorsLibrary, coreLibrary, null); 331 scanner.importLibrary(interceptorsLibrary, coreLibrary, null);
325 addForeignFunctions(jsHelperLibrary); 332 addForeignFunctions(jsHelperLibrary);
326 addForeignFunctions(interceptorsLibrary); 333 addForeignFunctions(interceptorsLibrary);
327 334
328 libraries['dart:core'] = coreLibrary; 335 libraries['dart:core'] = coreLibrary;
329 libraries['dart:coreimpl'] = coreImplLibrary; 336 libraries['dart:coreimpl'] = coreImplLibrary;
330 337
331 initializeSpecialClasses(); 338 initializeSpecialClasses();
339
340 javaScriptIndexingBehaviorInterface =
341 findHelper(const SourceString('JavaScriptIndexingBehavior'));
332 } 342 }
333 343
334 /** Define the JS helper functions in the given library. */ 344 /** Define the JS helper functions in the given library. */
335 void addForeignFunctions(LibraryElement library) { 345 void addForeignFunctions(LibraryElement library) {
336 library.define(new ForeignElement( 346 library.define(new ForeignElement(
337 const SourceString('JS'), library), this); 347 const SourceString('JS'), library), this);
338 library.define(new ForeignElement( 348 library.define(new ForeignElement(
339 const SourceString('UNINTERCEPTED'), library), this); 349 const SourceString('UNINTERCEPTED'), library), this);
340 library.define(new ForeignElement( 350 library.define(new ForeignElement(
341 const SourceString('JS_HAS_EQUALS'), library), this); 351 const SourceString('JS_HAS_EQUALS'), library), this);
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 // invariant that endOffset > beginOffset, but for EOF the 604 // invariant that endOffset > beginOffset, but for EOF the
595 // charoffset of the next token may be [beginOffset]. This can 605 // charoffset of the next token may be [beginOffset]. This can
596 // also happen for synthetized tokens that are produced during 606 // also happen for synthetized tokens that are produced during
597 // error handling. 607 // error handling.
598 final endOffset = 608 final endOffset =
599 Math.max((end.next !== null) ? end.next.charOffset : 0, beginOffset + 1); 609 Math.max((end.next !== null) ? end.next.charOffset : 0, beginOffset + 1);
600 assert(endOffset > beginOffset); 610 assert(endOffset > beginOffset);
601 return f(beginOffset, endOffset); 611 return f(beginOffset, endOffset);
602 } 612 }
603 } 613 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/lib/js_helper.dart » ('j') | lib/compiler/implementation/lib/js_helper.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698