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

Side by Side Diff: pkg/compiler/lib/src/compiler.dart

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 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
« no previous file with comments | « pkg/compiler/lib/src/apiimpl.dart ('k') | pkg/compiler/lib/src/dart2js.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 final bool fatalWarnings; 785 final bool fatalWarnings;
786 786
787 /// If `true`, some values are cached for reuse in incremental compilation. 787 /// If `true`, some values are cached for reuse in incremental compilation.
788 /// Incremental compilation is basically calling [run] more than once. 788 /// Incremental compilation is basically calling [run] more than once.
789 final bool hasIncrementalSupport; 789 final bool hasIncrementalSupport;
790 790
791 /// If `true` native extension syntax is supported by the frontend. 791 /// If `true` native extension syntax is supported by the frontend.
792 final bool allowNativeExtensions; 792 final bool allowNativeExtensions;
793 793
794 /// Output provider from user of Compiler API. 794 /// Output provider from user of Compiler API.
795 api.CompilerOutputProvider userOutputProvider; 795 api.CompilerOutput userOutputProvider;
796 796
797 /// Generate output even when there are compile-time errors. 797 /// Generate output even when there are compile-time errors.
798 final bool generateCodeWithCompileTimeErrors; 798 final bool generateCodeWithCompileTimeErrors;
799 799
800 /// The compiler is run from the build bot. 800 /// The compiler is run from the build bot.
801 final bool testMode; 801 final bool testMode;
802 802
803 bool disableInlining = false; 803 bool disableInlining = false;
804 804
805 List<Uri> librariesToAnalyzeWhenRun; 805 List<Uri> librariesToAnalyzeWhenRun;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 this.dumpInfo: false, 1054 this.dumpInfo: false,
1055 this.showPackageWarnings: false, 1055 this.showPackageWarnings: false,
1056 this.useContentSecurityPolicy: false, 1056 this.useContentSecurityPolicy: false,
1057 this.suppressWarnings: false, 1057 this.suppressWarnings: false,
1058 this.fatalWarnings: false, 1058 this.fatalWarnings: false,
1059 bool hasIncrementalSupport: false, 1059 bool hasIncrementalSupport: false,
1060 this.enableExperimentalMirrors: false, 1060 this.enableExperimentalMirrors: false,
1061 this.allowNativeExtensions: false, 1061 this.allowNativeExtensions: false,
1062 this.generateCodeWithCompileTimeErrors: false, 1062 this.generateCodeWithCompileTimeErrors: false,
1063 this.testMode: false, 1063 this.testMode: false,
1064 api.CompilerOutputProvider outputProvider, 1064 api.CompilerOutput outputProvider,
1065 List<String> strips: const []}) 1065 List<String> strips: const []})
1066 : this.disableTypeInferenceFlag = 1066 : this.disableTypeInferenceFlag =
1067 disableTypeInferenceFlag || !emitJavaScript, 1067 disableTypeInferenceFlag || !emitJavaScript,
1068 this.analyzeOnly = 1068 this.analyzeOnly =
1069 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, 1069 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag,
1070 this.analyzeSignaturesOnly = analyzeSignaturesOnly, 1070 this.analyzeSignaturesOnly = analyzeSignaturesOnly,
1071 this.analyzeAllFlag = analyzeAllFlag, 1071 this.analyzeAllFlag = analyzeAllFlag,
1072 this.hasIncrementalSupport = hasIncrementalSupport, 1072 this.hasIncrementalSupport = hasIncrementalSupport,
1073 cacheStrategy = new CacheStrategy(hasIncrementalSupport), 1073 cacheStrategy = new CacheStrategy(hasIncrementalSupport),
1074 this.userOutputProvider = (outputProvider == null) 1074 this.userOutputProvider = outputProvider == null
1075 ? NullSink.outputProvider 1075 ? const NullCompilerOutput() : outputProvider {
1076 : outputProvider {
1077 if (hasIncrementalSupport) { 1076 if (hasIncrementalSupport) {
1078 // TODO(ahe): This is too much. Any method from platform and package 1077 // TODO(ahe): This is too much. Any method from platform and package
1079 // libraries can be inlined. 1078 // libraries can be inlined.
1080 disableInlining = true; 1079 disableInlining = true;
1081 } 1080 }
1082 world = new World(this); 1081 world = new World(this);
1083 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and 1082 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and
1084 // make its field final. 1083 // make its field final.
1085 _coreTypes = new _CompilerCoreTypes(this); 1084 _coreTypes = new _CompilerCoreTypes(this);
1086 types = new Types(this); 1085 types = new Types(this);
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 2162
2164 EventSink<String> outputProvider(String name, String extension) { 2163 EventSink<String> outputProvider(String name, String extension) {
2165 if (compilationFailed) { 2164 if (compilationFailed) {
2166 if (!generateCodeWithCompileTimeErrors || testMode) { 2165 if (!generateCodeWithCompileTimeErrors || testMode) {
2167 // Disable output in test mode: The build bot currently uses the time 2166 // Disable output in test mode: The build bot currently uses the time
2168 // stamp of the generated file to determine whether the output is 2167 // stamp of the generated file to determine whether the output is
2169 // up-to-date. 2168 // up-to-date.
2170 return new NullSink('$name.$extension'); 2169 return new NullSink('$name.$extension');
2171 } 2170 }
2172 } 2171 }
2173 return userOutputProvider(name, extension); 2172 return userOutputProvider.createEventSink(name, extension);
2174 } 2173 }
2175 } 2174 }
2176 2175
2177 class CompilerTask { 2176 class CompilerTask {
2178 final Compiler compiler; 2177 final Compiler compiler;
2179 final Stopwatch watch; 2178 final Stopwatch watch;
2180 UserTag profilerTag; 2179 UserTag profilerTag;
2181 2180
2182 CompilerTask(Compiler compiler) 2181 CompilerTask(Compiler compiler)
2183 : this.compiler = compiler, 2182 : this.compiler = compiler,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2297 } 2296 }
2298 return true; 2297 return true;
2299 } 2298 }
2300 2299
2301 /// Returns `true` when [s] is private if used as an identifier. 2300 /// Returns `true` when [s] is private if used as an identifier.
2302 bool isPrivateName(String s) => !s.isEmpty && s.codeUnitAt(0) == $_; 2301 bool isPrivateName(String s) => !s.isEmpty && s.codeUnitAt(0) == $_;
2303 2302
2304 /// Returns `true` when [s] is public if used as an identifier. 2303 /// Returns `true` when [s] is public if used as an identifier.
2305 bool isPublicName(String s) => !isPrivateName(s); 2304 bool isPublicName(String s) => !isPrivateName(s);
2306 2305
2307 /// A sink that drains into /dev/null.
2308 class NullSink implements EventSink<String> {
2309 final String name;
2310
2311 NullSink(this.name);
2312
2313 add(String value) {}
2314
2315 void addError(Object error, [StackTrace stackTrace]) {}
2316
2317 void close() {}
2318
2319 toString() => name;
2320
2321 /// Convenience method for getting an [api.CompilerOutputProvider].
2322 static NullSink outputProvider(String name, String extension) {
2323 return new NullSink('$name.$extension');
2324 }
2325 }
2326
2327 /// Information about suppressed warnings and hints for a given library. 2306 /// Information about suppressed warnings and hints for a given library.
2328 class SuppressionInfo { 2307 class SuppressionInfo {
2329 int warnings = 0; 2308 int warnings = 0;
2330 int hints = 0; 2309 int hints = 0;
2331 } 2310 }
2332 2311
2333 class GenericTask extends CompilerTask { 2312 class GenericTask extends CompilerTask {
2334 final String name; 2313 final String name;
2335 2314
2336 GenericTask(this.name, Compiler compiler) 2315 GenericTask(this.name, Compiler compiler)
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2517 InterfaceType streamType([DartType elementType]) { 2496 InterfaceType streamType([DartType elementType]) {
2518 InterfaceType type = streamClass.computeType(compiler); 2497 InterfaceType type = streamClass.computeType(compiler);
2519 if (elementType == null) { 2498 if (elementType == null) {
2520 return streamClass.rawType; 2499 return streamClass.rawType;
2521 } 2500 }
2522 return type.createInstantiation([elementType]); 2501 return type.createInstantiation([elementType]);
2523 } 2502 }
2524 } 2503 }
2525 2504
2526 typedef void InternalErrorFunction(Spannable location, String message); 2505 typedef void InternalErrorFunction(Spannable location, String message);
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/apiimpl.dart ('k') | pkg/compiler/lib/src/dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698