Skip to content

Commit

Permalink
Repeats and fixes the changes landed & reverted as CL 1789553003.
Browse files Browse the repository at this point in the history
When landed, CL 1789553003 turned out to cause bot failures because
some libraries outside the compiler are importing compiler libraries
which have been updated. For instance, the tests in 'compiler/dart2js'
depend on several internal elements of the 'dart2js' compiler.

This CL updates these external dependents to work with the modified
library structure and class APIs of the compiler. A small adjustment
was applied to 'dart2js_incremental' as well.

No further dependents are believed to exist: Grepping in sdk for
relevant imports does not reveal any further imports of any of the
libraries in the compiler where the "interface" has changed, and
external clients are not supported (that is, imports in arbitrary
github repositories may or may not break if they use the compiler
internals, but we do not support this type of dependency so we won't
do anything to protect them against that type of breakage).

R=johnniwinther@google.com

Review URL: https://codereview.chromium.org/1864433004 .
  • Loading branch information
eernstg committed Apr 5, 2016
1 parent e914716 commit 586c43a
Show file tree
Hide file tree
Showing 33 changed files with 757 additions and 673 deletions.
3 changes: 2 additions & 1 deletion pkg/compiler/lib/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ library compiler;
import 'dart:async';
import 'package:package_config/packages.dart';
import 'compiler_new.dart' as new_api;
import 'src/options.dart' show CompilerOptions;
import 'src/old_to_new_api.dart';

// Unless explicitly allowed, passing [:null:] for any argument to the
Expand Down Expand Up @@ -115,7 +116,7 @@ Future<CompilationResult> compile(
Uri packageConfig,
PackagesDiscoveryProvider packagesDiscoveryProvider]) {

new_api.CompilerOptions compilerOptions = new new_api.CompilerOptions.parse(
CompilerOptions compilerOptions = new CompilerOptions.parse(
entryPoint: script,
libraryRoot: libraryRoot,
packageRoot: packageRoot,
Expand Down
508 changes: 2 additions & 506 deletions pkg/compiler/lib/compiler_new.dart

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions pkg/compiler/lib/src/apiimpl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ import 'package:package_config/src/util.dart' show
checkValidPackageUri;

import '../compiler_new.dart' as api;
import 'commandline_options.dart';
import 'common.dart';
import 'common/tasks.dart' show
GenericTask;
import 'compiler.dart';
import 'diagnostics/diagnostic_listener.dart' show
DiagnosticOptions;
import 'diagnostics/messages.dart' show
Message;
import 'elements/elements.dart' as elements;
import 'environment.dart';
import 'io/source_file.dart';
import 'options.dart' show
CompilerOptions;
import 'platform_configuration.dart' as platform_configuration;
import 'script.dart';

Expand All @@ -52,7 +51,7 @@ class CompilerImpl extends Compiler {
Uri get libraryRoot => options.platformConfigUri.resolve(".");

CompilerImpl(this.provider, api.CompilerOutput outputProvider,
this.handler, api.CompilerOptions options)
this.handler, CompilerOptions options)
: super(options: options, outputProvider: outputProvider,
environment: new _Environment(options.environment)) {
_Environment env = environment;
Expand Down
3 changes: 3 additions & 0 deletions pkg/compiler/lib/src/common/resolution.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import '../elements/elements.dart' show
TypeVariableElement;
import '../enqueue.dart' show
ResolutionEnqueuer;
import '../options.dart' show
ParserOptions;
import '../parser/element_listener.dart' show
ScannerOptions;
import '../tree/tree.dart' show
Expand Down Expand Up @@ -228,4 +230,5 @@ abstract class Parsing {
void parsePatchClass(ClassElement cls);
measure(f());
ScannerOptions getScannerOptionsFor(Element element);
ParserOptions get parserOptions;
}
31 changes: 15 additions & 16 deletions pkg/compiler/lib/src/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import 'dart_types.dart' show
import 'deferred_load.dart' show DeferredLoadTask, OutputUnit;
import 'diagnostics/code_location.dart';
import 'diagnostics/diagnostic_listener.dart' show
DiagnosticOptions;
DiagnosticReporter;
import 'diagnostics/invariant.dart' show
REPORT_EXCESS_RESOLUTION;
import 'diagnostics/messages.dart' show
Expand Down Expand Up @@ -95,6 +95,10 @@ import 'common/names.dart' show
import 'null_compiler_output.dart' show
NullCompilerOutput,
NullSink;
import 'options.dart' show
CompilerOptions,
DiagnosticOptions,
ParserOptions;
import 'parser/diet_parser_task.dart' show
DietParserTask;
import 'parser/element_listener.dart' show
Expand Down Expand Up @@ -191,7 +195,7 @@ abstract class Compiler implements LibraryLoaderListener {
new ResolutionRegistry(null, new TreeElementMapping(null));

/// Options provided from command-line arguments.
final api.CompilerOptions options;
final CompilerOptions options;

/**
* If true, stop compilation after type inference is complete. Used for
Expand Down Expand Up @@ -356,19 +360,17 @@ abstract class Compiler implements LibraryLoaderListener {
compilationFailedInternal = value;
}

Compiler({api.CompilerOptions options,
Compiler({CompilerOptions options,
api.CompilerOutput outputProvider,
this.environment: const _EmptyEnvironment()})
: this.options = options,
this.cacheStrategy = new CacheStrategy(options.hasIncrementalSupport),
this.userOutputProvider = outputProvider == null
? const NullCompilerOutput() : outputProvider {

world = new World(this);
// TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and
// make its field final.
_reporter = new _CompilerDiagnosticReporter(
this, options.diagnosticOptions);
_reporter = new _CompilerDiagnosticReporter(this, options);
_parsing = new _CompilerParsing(this);
_resolution = new _CompilerResolution(this);
_coreTypes = new _CompilerCoreTypes(_resolution);
Expand Down Expand Up @@ -399,8 +401,7 @@ abstract class Compiler implements LibraryLoaderListener {
}

tasks = [
dietParser = new DietParserTask(
this, enableConditionalDirectives: options.enableConditionalDirectives),
dietParser = new DietParserTask(this, parsing.parserOptions),
scanner = createScannerTask(),
serialization = new SerializationTask(this),
libraryLoader = new LibraryLoaderTask(this,
Expand All @@ -410,10 +411,8 @@ abstract class Compiler implements LibraryLoaderListener {
this.serialization,
this,
environment),
parser = new ParserTask(this,
enableConditionalDirectives: options.enableConditionalDirectives),
patchParser = new PatchParserTask(
this, enableConditionalDirectives: options.enableConditionalDirectives),
parser = new ParserTask(this, parsing.parserOptions),
patchParser = new PatchParserTask(this, parsing.parserOptions),
resolver = createResolverTask(),
closureToClassMapper = new closureMapping.ClosureTask(this),
checker = new TypeCheckerTask(this),
Expand Down Expand Up @@ -2111,10 +2110,10 @@ class _CompilerParsing implements Parsing {
});
}

ScannerOptions getScannerOptionsFor(Element element) {
return new ScannerOptions(
canUseNative: compiler.backend.canLibraryUseNative(element.library));
}
ScannerOptions getScannerOptionsFor(Element element) =>
new ScannerOptions.from(compiler, element.library);

ParserOptions get parserOptions => compiler.options;
}

class GlobalDependencyRegistry extends EagerRegistry {
Expand Down
52 changes: 3 additions & 49 deletions pkg/compiler/lib/src/diagnostics/diagnostic_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

library dart2js.diagnostic_listener;

import '../options.dart' show
DiagnosticOptions;
import 'source_span.dart' show
SourceSpan;
import 'spannable.dart' show
Expand All @@ -12,57 +14,9 @@ import '../elements/elements.dart' show
Element;
import 'messages.dart';

class DiagnosticOptions {
/// Emit terse diagnostics without howToFix.
final bool terseDiagnostics;

/// List of packages for which warnings and hints are reported. If `null`,
/// no package warnings or hints are reported. If empty, all warnings and
/// hints are reported.
final List<String> _shownPackageWarnings;

/// If `true`, warnings are not reported.
final bool suppressWarnings;

/// If `true`, warnings cause the compilation to fail.
final bool fatalWarnings;

/// If `true`, hints are not reported.
final bool suppressHints;

const DiagnosticOptions({
this.suppressWarnings: false,
this.fatalWarnings: false,
this.suppressHints: false,
this.terseDiagnostics: false,
List<String> shownPackageWarnings: null})
: _shownPackageWarnings = shownPackageWarnings;


/// Returns `true` if warnings and hints are shown for all packages.
bool get showAllPackageWarnings {
return _shownPackageWarnings != null && _shownPackageWarnings.isEmpty;
}

/// Returns `true` if warnings and hints are hidden for all packages.
bool get hidePackageWarnings => _shownPackageWarnings == null;

/// Returns `true` if warnings should be should for [uri].
bool showPackageWarningsFor(Uri uri) {
if (showAllPackageWarnings) {
return true;
}
if (_shownPackageWarnings != null) {
return uri.scheme == 'package' &&
_shownPackageWarnings.contains(uri.pathSegments.first);
}
return false;
}
}

// TODO(johnniwinther): Rename and cleanup this interface. Add severity enum.
abstract class DiagnosticReporter {
DiagnosticOptions get options => const DiagnosticOptions();
DiagnosticOptions get options;

// TODO(karlklose): rename log to something like reportInfo.
void log(message);
Expand Down
4 changes: 2 additions & 2 deletions pkg/compiler/lib/src/mirrors/analyze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'dart:async';
import 'source_mirrors.dart';
import 'dart2js_mirrors.dart' show Dart2JsMirrorSystem;
import '../../compiler.dart' as api;
import '../../compiler_new.dart' as new_api;
import '../options.dart' show CompilerOptions;
import '../apiimpl.dart' as apiimpl;
import '../compiler.dart' show Compiler;
import '../old_to_new_api.dart';
Expand Down Expand Up @@ -59,7 +59,7 @@ Future<MirrorSystem> analyze(List<Uri> libraries,
new LegacyCompilerInput(inputProvider),
new LegacyCompilerOutput(),
new LegacyCompilerDiagnostics(internalDiagnosticHandler),
new new_api.CompilerOptions.parse(
new CompilerOptions.parse(
libraryRoot: libraryRoot,
packageRoot: packageRoot,
options: options,
Expand Down
Loading

0 comments on commit 586c43a

Please sign in to comment.