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

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

Issue 11416280: Decouple the constant handler from the compiler so we can have more than one. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge from master.' Created 8 years 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 ParserTask parser; 188 ParserTask parser;
189 PatchParserTask patchParser; 189 PatchParserTask patchParser;
190 LibraryLoader libraryLoader; 190 LibraryLoader libraryLoader;
191 TreeValidatorTask validator; 191 TreeValidatorTask validator;
192 ResolverTask resolver; 192 ResolverTask resolver;
193 closureMapping.ClosureTask closureToClassMapper; 193 closureMapping.ClosureTask closureToClassMapper;
194 TypeCheckerTask checker; 194 TypeCheckerTask checker;
195 ti.TypesTask typesTask; 195 ti.TypesTask typesTask;
196 Backend backend; 196 Backend backend;
197 ConstantHandler constantHandler; 197 ConstantHandler constantHandler;
198 ConstantHandler metadataHandler;
198 EnqueueTask enqueuer; 199 EnqueueTask enqueuer;
199 CompilerTask fileReadingTask; 200 CompilerTask fileReadingTask;
200 201
201 static const SourceString MAIN = const SourceString('main'); 202 static const SourceString MAIN = const SourceString('main');
202 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); 203 static const SourceString CALL_OPERATOR_NAME = const SourceString('call');
203 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); 204 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod');
204 static const int NO_SUCH_METHOD_ARG_COUNT = 1; 205 static const int NO_SUCH_METHOD_ARG_COUNT = 1;
205 static const SourceString INVOKE_ON = const SourceString('invokeOn'); 206 static const SourceString INVOKE_ON = const SourceString('invokeOn');
206 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); 207 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType');
207 static const SourceString START_ROOT_ISOLATE = 208 static const SourceString START_ROOT_ISOLATE =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 parser = new ParserTask(this), 257 parser = new ParserTask(this),
257 patchParser = new PatchParserTask(this), 258 patchParser = new PatchParserTask(this),
258 resolver = new ResolverTask(this), 259 resolver = new ResolverTask(this),
259 closureToClassMapper = new closureMapping.ClosureTask(this), 260 closureToClassMapper = new closureMapping.ClosureTask(this),
260 checker = new TypeCheckerTask(this), 261 checker = new TypeCheckerTask(this),
261 typesTask = new ti.TypesTask(this, enableConcreteTypeInference), 262 typesTask = new ti.TypesTask(this, enableConcreteTypeInference),
262 constantHandler = new ConstantHandler(this, backend.constantSystem), 263 constantHandler = new ConstantHandler(this, backend.constantSystem),
263 enqueuer = new EnqueueTask(this)]; 264 enqueuer = new EnqueueTask(this)];
264 265
265 tasks.addAll(backend.tasks); 266 tasks.addAll(backend.tasks);
267 metadataHandler = new ConstantHandler(this, backend.constantSystem);
266 } 268 }
267 269
268 Universe get resolverWorld => enqueuer.resolution.universe; 270 Universe get resolverWorld => enqueuer.resolution.universe;
269 Universe get codegenWorld => enqueuer.codegen.universe; 271 Universe get codegenWorld => enqueuer.codegen.universe;
270 272
271 int getNextFreeClassId() => nextFreeClassId++; 273 int getNextFreeClassId() => nextFreeClassId++;
272 274
273 void ensure(bool condition) { 275 void ensure(bool condition) {
274 if (!condition) cancel('failed assertion in leg'); 276 if (!condition) cancel('failed assertion in leg');
275 } 277 }
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 withCurrentElement(element, 732 withCurrentElement(element,
731 () => resolver.resolveTypedef(element)); 733 () => resolver.resolveTypedef(element));
732 } 734 }
733 735
734 FunctionType computeFunctionType(Element element, 736 FunctionType computeFunctionType(Element element,
735 FunctionSignature signature) { 737 FunctionSignature signature) {
736 return withCurrentElement(element, 738 return withCurrentElement(element,
737 () => resolver.computeFunctionType(element, signature)); 739 () => resolver.computeFunctionType(element, signature));
738 } 740 }
739 741
740 bool isLazilyInitialized(VariableElement element) {
741 Constant initialValue = compileVariable(element);
742 return initialValue == null;
743 }
744
745 /**
746 * Compiles compile-time constants. Never returns [:null:].
747 * If the initial value is not a compile-time constants reports an error.
748 */
749 Constant compileConstant(VariableElement element) {
750 return withCurrentElement(element, () {
751 return constantHandler.compileConstant(element);
752 });
753 }
754
755 Constant compileVariable(VariableElement element) {
756 return withCurrentElement(element, () {
757 return constantHandler.compileVariable(element);
758 });
759 }
760
761 reportWarning(Node node, var message) { 742 reportWarning(Node node, var message) {
762 if (message is TypeWarning) { 743 if (message is TypeWarning) {
763 // TODO(ahe): Don't supress these warning when the type checker 744 // TODO(ahe): Don't supress these warning when the type checker
764 // is more complete. 745 // is more complete.
765 if (identical(message.message.kind, MessageKind.NOT_ASSIGNABLE)) return; 746 if (identical(message.message.kind, MessageKind.NOT_ASSIGNABLE)) return;
766 if (identical(message.message.kind, MessageKind.MISSING_RETURN)) return; 747 if (identical(message.message.kind, MessageKind.MISSING_RETURN)) return;
767 if (identical(message.message.kind, MessageKind.MAYBE_MISSING_RETURN)) ret urn; 748 if (identical(message.message.kind, MessageKind.MAYBE_MISSING_RETURN)) ret urn;
768 if (identical(message.message.kind, MessageKind.ADDITIONAL_ARGUMENT)) retu rn; 749 if (identical(message.message.kind, MessageKind.ADDITIONAL_ARGUMENT)) retu rn;
769 if (identical(message.message.kind, MessageKind.METHOD_NOT_FOUND)) return; 750 if (identical(message.message.kind, MessageKind.METHOD_NOT_FOUND)) return;
770 } 751 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 // TODO(johnniwinther): Use [spannable] and [message] to provide better 940 // TODO(johnniwinther): Use [spannable] and [message] to provide better
960 // information on assertion errors. 941 // information on assertion errors.
961 if (condition is Function){ 942 if (condition is Function){
962 condition = condition(); 943 condition = condition();
963 } 944 }
964 if (spannable == null || !condition) { 945 if (spannable == null || !condition) {
965 throw new SpannableAssertionFailure(spannable, message); 946 throw new SpannableAssertionFailure(spannable, message);
966 } 947 }
967 return true; 948 return true;
968 } 949 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698