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

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

Issue 574683002: Use ConstExp for storing constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 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 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 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 /// The method returns a [Future] allowing for the loading of additional 1193 /// The method returns a [Future] allowing for the loading of additional
1194 /// libraries. 1194 /// libraries.
1195 Future onLibrariesLoaded(Map<Uri, LibraryElement> loadedLibraries) { 1195 Future onLibrariesLoaded(Map<Uri, LibraryElement> loadedLibraries) {
1196 return new Future.sync(() { 1196 return new Future.sync(() {
1197 if (!loadedLibraries.containsKey(DART_CORE)) return new Future.value(); 1197 if (!loadedLibraries.containsKey(DART_CORE)) return new Future.value();
1198 1198
1199 functionClass.ensureResolved(this); 1199 functionClass.ensureResolved(this);
1200 functionApplyMethod = functionClass.lookupLocalMember('apply'); 1200 functionApplyMethod = functionClass.lookupLocalMember('apply');
1201 1201
1202 proxyConstant = 1202 proxyConstant =
1203 resolver.constantCompiler.compileConstant(coreLibrary.find('proxy')); 1203 resolver.constantCompiler.compileConstant(
1204 coreLibrary.find('proxy')).value;
1204 1205
1205 // TODO(johnniwinther): Move this to the JavaScript backend. 1206 // TODO(johnniwinther): Move this to the JavaScript backend.
1206 LibraryElement jsHelperLibrary = 1207 LibraryElement jsHelperLibrary =
1207 loadedLibraries[js_backend.JavaScriptBackend.DART_JS_HELPER]; 1208 loadedLibraries[js_backend.JavaScriptBackend.DART_JS_HELPER];
1208 if (jsHelperLibrary != null) { 1209 if (jsHelperLibrary != null) {
1209 patchConstant = resolver.constantCompiler.compileConstant( 1210 patchConstant = resolver.constantCompiler.compileConstant(
1210 jsHelperLibrary.find('patch')); 1211 jsHelperLibrary.find('patch')).value;
1211 } 1212 }
1212 1213
1213 if (preserveComments) { 1214 if (preserveComments) {
1214 return libraryLoader.loadLibrary(DART_MIRRORS) 1215 return libraryLoader.loadLibrary(DART_MIRRORS)
1215 .then((LibraryElement libraryElement) { 1216 .then((LibraryElement libraryElement) {
1216 documentClass = libraryElement.find('Comment'); 1217 documentClass = libraryElement.find('Comment');
1217 }); 1218 });
1218 } 1219 }
1219 }).then((_) => backend.onLibrariesLoaded(loadedLibraries)); 1220 }).then((_) => backend.onLibrariesLoaded(loadedLibraries));
1220 } 1221 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 numClass = lookupCoreClass('num'); 1265 numClass = lookupCoreClass('num');
1265 intClass = lookupCoreClass('int'); 1266 intClass = lookupCoreClass('int');
1266 doubleClass = lookupCoreClass('double'); 1267 doubleClass = lookupCoreClass('double');
1267 stringClass = lookupCoreClass('String'); 1268 stringClass = lookupCoreClass('String');
1268 functionClass = lookupCoreClass('Function'); 1269 functionClass = lookupCoreClass('Function');
1269 listClass = lookupCoreClass('List'); 1270 listClass = lookupCoreClass('List');
1270 typeClass = lookupCoreClass('Type'); 1271 typeClass = lookupCoreClass('Type');
1271 mapClass = lookupCoreClass('Map'); 1272 mapClass = lookupCoreClass('Map');
1272 nullClass = lookupCoreClass('Null'); 1273 nullClass = lookupCoreClass('Null');
1273 stackTraceClass = lookupCoreClass('StackTrace'); 1274 stackTraceClass = lookupCoreClass('StackTrace');
1275 symbolClass = lookupCoreClass('Symbol');
1274 if (!missingCoreClasses.isEmpty) { 1276 if (!missingCoreClasses.isEmpty) {
1275 internalError(coreLibrary, 1277 internalError(coreLibrary,
1276 'dart:core library does not contain required classes: ' 1278 'dart:core library does not contain required classes: '
1277 '$missingCoreClasses'); 1279 '$missingCoreClasses');
1278 } 1280 }
1279
1280 // The Symbol class may not exist during unit testing.
1281 // TODO(ahe): It is possible that we have to require the presence
1282 // of Symbol as we change how we implement noSuchMethod.
1283 symbolClass = lookupCoreClass('Symbol');
1284 } 1281 }
1285 1282
1286 Element _unnamedListConstructor; 1283 Element _unnamedListConstructor;
1287 Element get unnamedListConstructor { 1284 Element get unnamedListConstructor {
1288 if (_unnamedListConstructor != null) return _unnamedListConstructor; 1285 if (_unnamedListConstructor != null) return _unnamedListConstructor;
1289 Selector callConstructor = new Selector.callConstructor( 1286 Selector callConstructor = new Selector.callConstructor(
1290 "", listClass.library); 1287 "", listClass.library);
1291 return _unnamedListConstructor = 1288 return _unnamedListConstructor =
1292 listClass.lookupConstructor(callConstructor); 1289 listClass.lookupConstructor(callConstructor);
1293 } 1290 }
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 2057
2061 // [begin] and [end] might be the same for the same empty token. This 2058 // [begin] and [end] might be the same for the same empty token. This
2062 // happens for instance when scanning '$$'. 2059 // happens for instance when scanning '$$'.
2063 assert(endOffset >= beginOffset); 2060 assert(endOffset >= beginOffset);
2064 return f(beginOffset, endOffset); 2061 return f(beginOffset, endOffset);
2065 } 2062 }
2066 2063
2067 String toString() => 'SourceSpan($uri, $begin, $end)'; 2064 String toString() => 'SourceSpan($uri, $begin, $end)';
2068 } 2065 }
2069 2066
2067 /// Flag that can be used in assertions to assert that a code path is only
2068 /// executed as part of development.
2069 ///
2070 /// This flag is automatically set to true if helper methods like, [debugPrint],
2071 /// [debugWrapPrint], [trace], and [reportHere] are called.
2072 bool DEBUG_MODE = false;
2073
2074 /// Assert that [DEBUG_MODE] is `true` and provide [message] as part of the
2075 /// error message.
2076 assertDebugMode(String message) {
2077 assert(invariant(NO_LOCATION_SPANNABLE, DEBUG_MODE,
2078 message: 'Debug mode is not enabled: $message'));
2079 }
2080
2070 /** 2081 /**
2071 * Throws a [SpannableAssertionFailure] if [condition] is 2082 * Throws a [SpannableAssertionFailure] if [condition] is
2072 * [:false:]. [condition] must be either a [:bool:] or a no-arg 2083 * [:false:]. [condition] must be either a [:bool:] or a no-arg
2073 * function returning a [:bool:]. 2084 * function returning a [:bool:].
2074 * 2085 *
2075 * Use this method to provide better information for assertion by calling 2086 * Use this method to provide better information for assertion by calling
2076 * [invariant] as the argument to an [:assert:] statement: 2087 * [invariant] as the argument to an [:assert:] statement:
2077 * 2088 *
2078 * assert(invariant(position, isValid)); 2089 * assert(invariant(position, isValid));
2079 * 2090 *
(...skipping 12 matching lines...) Expand all
2092 } 2103 }
2093 if (!condition) { 2104 if (!condition) {
2094 if (message is Function) { 2105 if (message is Function) {
2095 message = message(); 2106 message = message();
2096 } 2107 }
2097 throw new SpannableAssertionFailure(spannable, message); 2108 throw new SpannableAssertionFailure(spannable, message);
2098 } 2109 }
2099 return true; 2110 return true;
2100 } 2111 }
2101 2112
2102 /** 2113 /// Returns `true` when [s] is private if used as an identifier.
2103 * Global
2104 */
2105 bool isPrivateName(String s) => !s.isEmpty && s.codeUnitAt(0) == $_; 2114 bool isPrivateName(String s) => !s.isEmpty && s.codeUnitAt(0) == $_;
2106 2115
2107 /// A sink that drains into /dev/null. 2116 /// A sink that drains into /dev/null.
2108 class NullSink implements EventSink<String> { 2117 class NullSink implements EventSink<String> {
2109 final String name; 2118 final String name;
2110 2119
2111 NullSink(this.name); 2120 NullSink(this.name);
2112 2121
2113 add(String value) {} 2122 add(String value) {}
2114 2123
(...skipping 14 matching lines...) Expand all
2129 int warnings = 0; 2138 int warnings = 0;
2130 int hints = 0; 2139 int hints = 0;
2131 } 2140 }
2132 2141
2133 class GenericTask extends CompilerTask { 2142 class GenericTask extends CompilerTask {
2134 final String name; 2143 final String name;
2135 2144
2136 GenericTask(this.name, Compiler compiler) 2145 GenericTask(this.name, Compiler compiler)
2137 : super(compiler); 2146 : super(compiler);
2138 } 2147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698