Skip to content

Commit

Permalink
step 3 of ??: ignore old options from old FE
Browse files Browse the repository at this point in the history
* preserve-comments: unused, only used for source-mirrors & dartdoc long long ago
* preserve-uris: ignored, mirrors-only flag
* allow-native-extensions: error, was only used for analyze-only with the old FE

Change-Id: Ic93c31edf188cdab3aa658c13018a432baf14742
Reviewed-on: https://dart-review.googlesource.com/48457
Reviewed-by: Johnni Winther <[email protected]>
  • Loading branch information
sigmundch committed Mar 27, 2018
1 parent c0fa4e2 commit f9e12f1
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 256 deletions.
8 changes: 3 additions & 5 deletions pkg/compiler/lib/src/apiimpl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ class CompilerImpl extends Compiler {
Uri resourceUri = translateUri(node, readableUri);
if (resourceUri == null) return _synthesizeScript(readableUri);
if (resourceUri.scheme == 'dart-ext') {
if (!options.allowNativeExtensions) {
reporter.withCurrentElement(element, () {
reporter.reportErrorMessage(node, MessageKind.DART_EXT_NOT_SUPPORTED);
});
}
reporter.withCurrentElement(element, () {
reporter.reportErrorMessage(node, MessageKind.DART_EXT_NOT_SUPPORTED);
});
return _synthesizeScript(readableUri);
}

Expand Down
1 change: 0 additions & 1 deletion pkg/compiler/lib/src/commandline_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class Flags {
static const String noFrequencyBasedMinification =
'--no-frequency-based-minification';
static const String noSourceMaps = '--no-source-maps';
static const String preserveComments = '--preserve-comments';
static const String preserveUris = '--preserve-uris';
static const String showPackageWarnings = '--show-package-warnings';
static const String suppressHints = '--suppress-hints';
Expand Down
6 changes: 0 additions & 6 deletions pkg/compiler/lib/src/common_elements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,6 @@ class CommonElements {
FunctionEntity get preserveMetadataMarker =>
_preserveMetadataMarker ??= _findMirrorsFunction('preserveMetadata');

/// Holds the method "preserveUris" in js_mirrors when
/// dart:mirrors has been loaded.
FunctionEntity _preserveUrisMarker;
FunctionEntity get preserveUrisMarker =>
_preserveUrisMarker ??= _findMirrorsFunction('preserveUris');

/// Holds the method "preserveLibraryNames" in js_mirrors when
/// dart:mirrors has been loaded.
FunctionEntity _preserveLibraryNamesMarker;
Expand Down
9 changes: 1 addition & 8 deletions pkg/compiler/lib/src/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ import 'script.dart' show Script;
import 'serialization/task.dart' show SerializationTask;
import 'ssa/nodes.dart' show HInstruction;
import 'package:front_end/src/fasta/scanner.dart' show StringToken, Token;
import 'tokens/token_map.dart' show TokenMap;
import 'tree/tree.dart' show Node, TypeAnnotation;
import 'typechecker.dart' show TypeCheckerTask;
import 'types/types.dart' show GlobalTypeInferenceTask;
Expand Down Expand Up @@ -95,11 +94,6 @@ abstract class Compiler {

ImpactStrategy impactStrategy = const ImpactStrategy();

/**
* Map from token to the first preceding comment token.
*/
final TokenMap commentMap = new TokenMap();

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

Expand Down Expand Up @@ -273,8 +267,7 @@ abstract class Compiler {
///
/// Override this to mock the scanner for testing.
ScannerTask createScannerTask() =>
new ScannerTask(dietParser, reporter, measurer,
preserveComments: options.preserveComments, commentMap: commentMap);
new ScannerTask(dietParser, reporter, measurer);

/// Creates the resolution object.
///
Expand Down
17 changes: 2 additions & 15 deletions pkg/compiler/lib/src/dart2js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ Future<api.CompilationResult> compile(List<String> argv,
bool wantHelp = false;
bool wantVersion = false;
bool analyzeOnly = false;
bool allowNativeExtensions = false;
bool trustTypeAnnotations = false;
bool checkedMode = false;
List<String> hints = <String>[];
Expand Down Expand Up @@ -205,8 +204,7 @@ Future<api.CompilationResult> compile(List<String> argv,
}

void setAllowNativeExtensions(String argument) {
allowNativeExtensions = true;
passThrough(argument);
helpAndFail("Option '${Flags.allowNativeExtensions}' is not supported.");
}

void setVerbose(_) {
Expand Down Expand Up @@ -319,7 +317,7 @@ Future<api.CompilationResult> compile(List<String> argv,
new OptionHandler(Flags.syncAsync, passThrough),
new OptionHandler(Flags.initializingFormalAccess, ignoreOption),
new OptionHandler(Flags.minify, passThrough),
new OptionHandler(Flags.preserveUris, passThrough),
new OptionHandler(Flags.preserveUris, ignoreOption),
new OptionHandler('--force-strip=.*', setStrip),
new OptionHandler(Flags.disableDiagnosticColors, (_) {
enableColors = false;
Expand Down Expand Up @@ -444,13 +442,6 @@ Future<api.CompilationResult> compile(List<String> argv,
helpAndFail("Cannot specify both '--package-root' and '--packages.");
}

if (!analyzeOnly) {
if (allowNativeExtensions) {
helpAndFail("Option '${Flags.allowNativeExtensions}' is only supported "
"in combination with the '${Flags.analyzeOnly}' option.");
}
}

options.add('--out=$out');
options.add('--source-map=$sourceMapOut');

Expand Down Expand Up @@ -653,10 +644,6 @@ Supported options:
--show-package-warnings
Show warnings and hints generated from packages.
--preserve-uris
Preserve the source URIs in the reflection data. Without this flag the
`uri` getter for `LibraryMirror`s is mangled in minified mode.
--csp
Disable dynamic generation of code in the generated output. This is
necessary to satisfy CSP restrictions (see http://www.w3.org/TR/CSP/).
Expand Down
6 changes: 2 additions & 4 deletions pkg/compiler/lib/src/js_backend/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1024,10 +1024,8 @@ class JavaScriptBackend {
bool shouldOutput(Element element) => true;

/// Returns `true` if the `native` pseudo keyword is supported for [library].
bool canLibraryUseNative(LibraryEntity library) {
return native.maybeEnableNative(library.canonicalUri,
allowNativeExtensions: compiler.options.allowNativeExtensions);
}
bool canLibraryUseNative(LibraryEntity library) =>
native.maybeEnableNative(library.canonicalUri);

bool isTargetSpecificLibrary(LibraryElement library) {
Uri canonicalUri = library.canonicalUri;
Expand Down
17 changes: 2 additions & 15 deletions pkg/compiler/lib/src/js_backend/mirrors_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import '../elements/elements.dart' show AbstractFieldElement, Element;
import '../elements/entities.dart';
import '../elements/names.dart';
import '../elements/types.dart';
import '../options.dart';
import '../world.dart';
import '../universe/world_builder.dart';
import '../util/emptyset.dart';
Expand Down Expand Up @@ -39,10 +38,6 @@ abstract class MirrorsData {
/// True if a call to disableTreeShaking has been seen.
bool get isTreeShakingDisabled;

/// True if a call to preserveUris has been seen and the preserve-uris flag
/// is set.
bool get mustPreserveUris;

/// Set of symbols that the user has requested for reflection.
Iterable<String> get symbolsUsed;

Expand Down Expand Up @@ -175,10 +170,6 @@ abstract class MirrorsDataImpl implements MirrorsData, MirrorsDataBuilder {
/// True if there isn't sufficient @MirrorsUsed data.
bool hasInsufficientMirrorsUsed = false;

/// True if a call to preserveUris has been seen and the preserve-uris flag
/// is set.
bool mustPreserveUris = false;

/// Set of symbols that the user has requested for reflection.
final Set<String> symbolsUsed = new Set<String>();

Expand All @@ -197,13 +188,11 @@ abstract class MirrorsDataImpl implements MirrorsData, MirrorsDataBuilder {
// TODO(johnniwinther): Avoid the need for this.
final Compiler _compiler;

final CompilerOptions _options;

final ElementEnvironment _elementEnvironment;
final CommonElements _commonElements;

MirrorsDataImpl(this._compiler, this._options, this._elementEnvironment,
this._commonElements);
MirrorsDataImpl(
this._compiler, this._elementEnvironment, this._commonElements);

void registerUsedMember(MemberEntity member) {
if (member == _commonElements.disableTreeShakingMarker) {
Expand All @@ -212,8 +201,6 @@ abstract class MirrorsDataImpl implements MirrorsData, MirrorsDataBuilder {
mustPreserveNames = true;
} else if (member == _commonElements.preserveMetadataMarker) {
mustRetainMetadata = true;
} else if (member == _commonElements.preserveUrisMarker) {
if (_options.preserveUris) mustPreserveUris = true;
} else if (member == _commonElements.preserveLibraryNamesMarker) {
mustRetainLibraryNames = true;
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,7 @@ class Emitter extends js_emitter.EmitterBase {
jsAst.Expression generateLibraryDescriptor(
LibraryEntity library, Fragment fragment) {
dynamic uri = "";
if (!compiler.options.enableMinification ||
backend.mirrorsData.mustPreserveUris) {
if (!compiler.options.enableMinification) {
uri = library.canonicalUri;
if (uri.scheme == 'file' && compiler.options.outputUri != null) {
uri =
Expand Down
2 changes: 1 addition & 1 deletion pkg/compiler/lib/src/kernel/kernel_strategy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class KernelWorkItem implements ResolutionWorkItem {
class MirrorsDataBuilderImpl extends MirrorsDataImpl {
MirrorsDataBuilderImpl(
ElementEnvironment elementEnvironment, CommonElements commonElements)
: super(null, null, elementEnvironment, commonElements);
: super(null, elementEnvironment, commonElements);

@override
void registerUsedMember(MemberEntity member) {}
Expand Down
4 changes: 2 additions & 2 deletions pkg/compiler/lib/src/native/native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Iterable<String> _allowedDartSchemePaths = const <String>[
'web_sql'
];

bool maybeEnableNative(Uri uri, {bool allowNativeExtensions: false}) {
bool maybeEnableNative(Uri uri) {
bool allowedTestLibrary() {
String scriptName = uri.path;
return scriptName.contains('tests/compiler/dart2js_native') ||
Expand All @@ -36,5 +36,5 @@ bool maybeEnableNative(Uri uri, {bool allowNativeExtensions: false}) {
return _allowedDartSchemePaths.contains(uri.path);
}

return allowedTestLibrary() || allowedDartLibary() || allowNativeExtensions;
return allowedTestLibrary() || allowedDartLibary();
}
23 changes: 0 additions & 23 deletions pkg/compiler/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ class CompilerOptions implements DiagnosticOptions {
/// dart:html for unit testing purposes.
bool allowMockCompilation = false;

/// Whether the native extension syntax is supported by the frontend.
bool allowNativeExtensions = false;

/// Whether to resolve all functions in the program, not just those reachable
/// from main. This implies [analyzeOnly] is true as well.
bool analyzeAll = false;
Expand Down Expand Up @@ -190,9 +187,6 @@ class CompilerOptions implements DiagnosticOptions {
/// Location of the kernel platform `.dill` files.
Uri platformBinaries;

/// Whether to emit URIs in the reflection metadata.
bool preserveUris = false;

/// The locations of serialized data used for resolution.
List<Uri> resolutionInputs;

Expand Down Expand Up @@ -277,12 +271,6 @@ class CompilerOptions implements DiagnosticOptions {
// -------------------------------------------------
// TODO(sigmund): delete these as we delete the underlying features

/// Whether to preserve comments while scanning (only use for dart:mirrors).
bool preserveComments = false;

/// Strip option used by dart2dart.
List<String> strips = const [];

/// Whether to start `async` functions synchronously.
bool startAsyncSynchronously = false;

Expand All @@ -292,7 +280,6 @@ class CompilerOptions implements DiagnosticOptions {
return new CompilerOptions()
..libraryRoot = libraryRoot
..allowMockCompilation = _hasOption(options, Flags.allowMockCompilation)
..allowNativeExtensions = _hasOption(options, Flags.allowNativeExtensions)
..analyzeAll = _hasOption(options, Flags.analyzeAll)
..analyzeMain = _hasOption(options, Flags.analyzeMain)
..analyzeOnly = _hasOption(options, Flags.analyzeOnly)
Expand Down Expand Up @@ -334,11 +321,8 @@ class CompilerOptions implements DiagnosticOptions {
..librariesSpecificationUri = _resolveLibrariesSpecification(libraryRoot)
..platformBinaries =
platformBinaries ?? _extractUriOption(options, '--platform-binaries=')
..preserveComments = _hasOption(options, Flags.preserveComments)
..preserveUris = _hasOption(options, Flags.preserveUris)
..resolveOnly = _hasOption(options, Flags.resolveOnly)
..sourceMapUri = _extractUriOption(options, '--source-map=')
..strips = _extractCsvOption(options, '--force-strip=')
..strongMode = _hasOption(options, Flags.strongMode)
..testMode = _hasOption(options, Flags.testMode)
..trustJSInteropTypeAnnotations =
Expand Down Expand Up @@ -374,13 +358,6 @@ class CompilerOptions implements DiagnosticOptions {
if (packageRoot != null && !packageRoot.path.endsWith("/")) {
throw new ArgumentError("[packageRoot] must end with a /");
}
if (!analyzeOnly) {
if (allowNativeExtensions) {
throw new ArgumentError(
"${Flags.allowNativeExtensions} is only supported in combination "
"with ${Flags.analyzeOnly}");
}
}
if (useKernel && platformBinaries == null) {
throw new ArgumentError("Missing required ${Flags.platformBinaries}");
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/compiler/lib/src/resolution/resolution_strategy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import '../js_backend/runtime_types.dart';
import '../library_loader.dart';
import '../native/enqueue.dart' show NativeResolutionEnqueuer;
import '../native/resolver.dart';
import '../options.dart';
import '../patch_parser.dart';
import '../resolved_uri_translator.dart';
import '../serialization/task.dart';
Expand Down Expand Up @@ -121,7 +120,7 @@ class ResolutionFrontEndStrategy extends FrontendStrategyBase

MirrorsDataBuilder createMirrorsDataBuilder() {
return new ResolutionMirrorsData(
_compiler, _compiler.options, elementEnvironment, commonElements);
_compiler, elementEnvironment, commonElements);
}

MirrorsResolutionAnalysis createMirrorsResolutionAnalysis(
Expand Down Expand Up @@ -1038,9 +1037,9 @@ class ResolutionWorkItemBuilder extends WorkItemBuilder {
}

class ResolutionMirrorsData extends MirrorsDataImpl {
ResolutionMirrorsData(Compiler compiler, CompilerOptions options,
ResolutionMirrorsData(Compiler compiler,
ElementEnvironment elementEnvironment, CommonElements commonElements)
: super(compiler, options, elementEnvironment, commonElements);
: super(compiler, elementEnvironment, commonElements);

@override
bool isClassInjected(covariant ClassElement cls) => cls.isInjected;
Expand Down
44 changes: 3 additions & 41 deletions pkg/compiler/lib/src/scanner/scanner_task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,14 @@ import '../parser/diet_parser_task.dart' show DietParserTask;
import '../script.dart' show Script;
import 'package:front_end/src/fasta/scanner.dart'
show Scanner, StringScanner, Token, Utf8BytesScanner;
import 'package:front_end/src/fasta/scanner/token_constants.dart' as Tokens
show COMMENT_TOKEN, EOF_TOKEN;
import '../tokens/token_map.dart' show TokenMap;
import '../io/source_file.dart';

class ScannerTask extends CompilerTask {
final DietParserTask _dietParser;
final bool _preserveComments;
final TokenMap _commentMap;
final DiagnosticReporter reporter;

ScannerTask(this._dietParser, this.reporter, Measurer measurer,
{bool preserveComments: false, TokenMap commentMap})
: _preserveComments = preserveComments,
_commentMap = commentMap,
super(measurer) {
if (_preserveComments && _commentMap == null) {
throw new ArgumentError(
"commentMap must be provided if preserveComments is true");
}
}
ScannerTask(this._dietParser, this.reporter, Measurer measurer)
: super(measurer);

String get name => 'Scanner';

Expand Down Expand Up @@ -63,10 +50,7 @@ class ScannerTask extends CompilerTask {

void scanElements(CompilationUnitElement compilationUnit) {
Script script = compilationUnit.script;
Token tokens = scanFile(script.file, includeComments: _preserveComments);
if (_preserveComments) {
tokens = processAndStripComments(tokens);
}
Token tokens = scanFile(script.file);
_dietParser.dietParse(compilationUnit, tokens);
}

Expand All @@ -82,26 +66,4 @@ class ScannerTask extends CompilerTask {
return new StringScanner(source, includeComments: false).tokenize();
});
}

Token processAndStripComments(Token currentToken) {
Token firstToken = currentToken;
Token prevToken;
while (currentToken.kind != Tokens.EOF_TOKEN) {
if (identical(currentToken.kind, Tokens.COMMENT_TOKEN)) {
Token firstCommentToken = currentToken;
while (identical(currentToken.kind, Tokens.COMMENT_TOKEN)) {
currentToken = currentToken.next;
}
_commentMap[currentToken] = firstCommentToken;
if (prevToken == null) {
firstToken = currentToken;
} else {
prevToken.next = currentToken;
}
}
prevToken = currentToken;
currentToken = currentToken.next;
}
return firstToken;
}
}
Loading

0 comments on commit f9e12f1

Please sign in to comment.