Small cleanup

Change-Id: I368fbaa3bac5a5a47c374f26998cce8ad8b265a6
Reviewed-on: https://dart-review.googlesource.com/55890
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Johnni Winther 2018-05-18 19:33:48 +00:00 committed by commit-bot@chromium.org
parent 9f6e8a3a96
commit f1f660fe1e
6 changed files with 1 additions and 559 deletions

View file

@ -1412,8 +1412,6 @@ abstract class ElementEnvironment {
ClassEntity cls, List<DartType> typeArguments);
/// Returns the `dynamic` type.
// TODO(johnniwinther): Remove this when `ResolutionDynamicType` is no longer
// needed.
DartType get dynamicType;
/// Returns the 'raw type' of [cls]. That is, the instantiation of [cls]

View file

@ -32,7 +32,7 @@ import 'library_loader.dart' show LibraryLoaderTask, LoadedLibraries;
import 'null_compiler_output.dart' show NullCompilerOutput, NullSink;
import 'options.dart' show CompilerOptions, DiagnosticOptions;
import 'ssa/nodes.dart' show HInstruction;
import 'package:front_end/src/fasta/scanner.dart' show StringToken, Token;
import 'package:front_end/src/fasta/scanner.dart' show StringToken;
import 'types/types.dart' show GlobalTypeInferenceTask;
import 'universe/selector.dart' show Selector;
import 'universe/world_builder.dart'
@ -861,12 +861,6 @@ class CompilerDiagnosticReporter extends DiagnosticReporter {
}
}
// TODO(johnniwinther): Move this to the parser listeners.
@override
SourceSpan spanFromToken(Token token) {
throw 'No error location.';
}
internalError(Spannable spannable, reason) {
String message = tryToString(reason);
reportDiagnosticInternal(

View file

@ -4,7 +4,6 @@
library dart2js.diagnostic_listener;
import 'package:front_end/src/fasta/scanner.dart' show Token;
import '../elements/entities.dart';
import '../options.dart' show DiagnosticOptions;
import 'messages.dart';
@ -26,12 +25,6 @@ abstract class DiagnosticReporter {
/// tokens can be found within the tokens of the current element.
SourceSpan spanFromSpannable(Spannable node);
/// Creates a [SourceSpan] for [token] in scope of the current element.
///
/// In checked mode we assert that the token can be found within the tokens
/// of the current element.
SourceSpan spanFromToken(Token token);
void reportErrorMessage(Spannable spannable, MessageKind messageKind,
[Map arguments = const {}]) {
reportError(createMessage(spannable, messageKind, arguments));

View file

@ -322,197 +322,3 @@ class _IfNullOperator extends BinaryOperator {
String get selectorName => '??';
}
enum AssignmentOperatorKind {
ASSIGN,
IF_NULL,
ADD,
SUB,
MUL,
DIV,
IDIV,
MOD,
SHL,
SHR,
AND,
OR,
XOR,
}
class AssignmentOperator {
final AssignmentOperatorKind kind;
final BinaryOperator binaryOperator;
final String name;
final bool isUserDefinable;
const AssignmentOperator._(this.kind, this.name, this.binaryOperator,
{this.isUserDefinable: true});
String get selectorName {
return binaryOperator != null ? binaryOperator.selectorName : null;
}
String toString() => name;
/// The = operator.
static const AssignmentOperator ASSIGN = const AssignmentOperator._(
AssignmentOperatorKind.ASSIGN, '=', null,
isUserDefinable: false);
/// The ??= operator.
static const AssignmentOperator IF_NULL = const AssignmentOperator._(
AssignmentOperatorKind.IF_NULL, '??=', BinaryOperator.IF_NULL,
isUserDefinable: false);
/// The += assignment operator.
static const AssignmentOperator ADD = const AssignmentOperator._(
AssignmentOperatorKind.ADD, '+=', BinaryOperator.ADD);
/// The -= assignment operator.
static const AssignmentOperator SUB = const AssignmentOperator._(
AssignmentOperatorKind.SUB, '-=', BinaryOperator.SUB);
/// The *= assignment operator.
static const AssignmentOperator MUL = const AssignmentOperator._(
AssignmentOperatorKind.MUL, '*=', BinaryOperator.MUL);
/// The /= assignment operator.
static const AssignmentOperator DIV = const AssignmentOperator._(
AssignmentOperatorKind.DIV, '/=', BinaryOperator.DIV);
/// The ~/= assignment operator.
static const AssignmentOperator IDIV = const AssignmentOperator._(
AssignmentOperatorKind.IDIV, '~/=', BinaryOperator.IDIV);
/// The %= assignment operator.
static const AssignmentOperator MOD = const AssignmentOperator._(
AssignmentOperatorKind.MOD, '%=', BinaryOperator.MOD);
/// The <<= assignment operator.
static const AssignmentOperator SHL = const AssignmentOperator._(
AssignmentOperatorKind.SHL, '<<=', BinaryOperator.SHL);
/// The >>= assignment operator.
static const AssignmentOperator SHR = const AssignmentOperator._(
AssignmentOperatorKind.SHR, '>>=', BinaryOperator.SHR);
/// The &= assignment operator.
static const AssignmentOperator AND = const AssignmentOperator._(
AssignmentOperatorKind.AND, '&=', BinaryOperator.AND);
/// The |= assignment operator.
static const AssignmentOperator OR = const AssignmentOperator._(
AssignmentOperatorKind.OR, '|=', BinaryOperator.OR);
/// The ^= assignment operator.
static const AssignmentOperator XOR = const AssignmentOperator._(
AssignmentOperatorKind.XOR, '^=', BinaryOperator.XOR);
static AssignmentOperator parse(String value) {
switch (value) {
case '=':
return ASSIGN;
case '??=':
return IF_NULL;
case '*=':
return MUL;
case '/=':
return DIV;
case '%=':
return MOD;
case '~/=':
return IDIV;
case '+=':
return ADD;
case '-=':
return SUB;
case '<<=':
return SHL;
case '>>=':
return SHR;
case '&=':
return AND;
case '^=':
return XOR;
case '|=':
return OR;
default:
return null;
}
}
// ignore: MISSING_RETURN
static AssignmentOperator fromKind(AssignmentOperatorKind kind) {
switch (kind) {
case AssignmentOperatorKind.ASSIGN:
return ASSIGN;
case AssignmentOperatorKind.IF_NULL:
return IF_NULL;
case AssignmentOperatorKind.ADD:
return ADD;
case AssignmentOperatorKind.SUB:
return SUB;
case AssignmentOperatorKind.MUL:
return MUL;
case AssignmentOperatorKind.DIV:
return DIV;
case AssignmentOperatorKind.IDIV:
return IDIV;
case AssignmentOperatorKind.MOD:
return MOD;
case AssignmentOperatorKind.SHL:
return SHL;
case AssignmentOperatorKind.SHR:
return SHR;
case AssignmentOperatorKind.AND:
return AND;
case AssignmentOperatorKind.OR:
return OR;
case AssignmentOperatorKind.XOR:
return XOR;
}
}
}
enum IncDecOperatorKind { INC, DEC }
class IncDecOperator {
final IncDecOperatorKind kind;
final String name;
final BinaryOperator binaryOperator;
const IncDecOperator._(this.kind, this.name, this.binaryOperator);
String get selectorName => binaryOperator.selectorName;
String toString() => name;
/// The prefix/postfix ++ operator.
static const IncDecOperator INC =
const IncDecOperator._(IncDecOperatorKind.INC, '++', BinaryOperator.ADD);
/// The prefix/postfix -- operator.
static const IncDecOperator DEC =
const IncDecOperator._(IncDecOperatorKind.DEC, '--', BinaryOperator.SUB);
static IncDecOperator parse(String value) {
switch (value) {
case '++':
return INC;
case '--':
return DEC;
default:
return null;
}
}
// ignore: MISSING_RETURN
static IncDecOperator fromKind(IncDecOperatorKind kind) {
switch (kind) {
case IncDecOperatorKind.INC:
return INC;
case IncDecOperatorKind.DEC:
return DEC;
}
}
}

View file

@ -1,345 +0,0 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// Source information strategy that concurrently builds sourcemaps for each of
/// child strategies.
library dart2js.dual_source_information;
import '../common.dart';
import '../elements/entities.dart';
import '../js/js_source_mapping.dart';
import '../js/js.dart' as js;
import '../universe/call_structure.dart';
import 'code_output.dart' show BufferedCodeOutput;
import 'source_information.dart';
class MultiSourceInformationStrategy<T>
implements JavaScriptSourceInformationStrategy<T> {
final List<JavaScriptSourceInformationStrategy<T>> strategies;
const MultiSourceInformationStrategy(this.strategies);
@override
SourceInformationBuilder<T> createBuilderForContext(MemberEntity member) {
return new MultiSourceInformationBuilder<T>(
strategies.map((s) => s.createBuilderForContext(member)).toList());
}
@override
void onComplete() {
strategies.forEach((s) => s.onComplete());
}
@override
SourceInformation buildSourceMappedMarker() {
return new MultiSourceInformation(
strategies.map((s) => s.buildSourceMappedMarker()).toList());
}
@override
SourceInformationProcessor createProcessor(
SourceMapperProvider sourceMapperProvider,
SourceInformationReader reader) {
return new MultiSourceInformationProcessor(
new List<SourceInformationProcessor>.generate(strategies.length,
(int index) {
return strategies[index].createProcessor(sourceMapperProvider,
new MultiSourceInformationReader(reader, index));
}));
}
}
class MultiSourceInformationProcessor implements SourceInformationProcessor {
final List<SourceInformationProcessor> processors;
MultiSourceInformationProcessor(this.processors);
@override
void onStartPosition(js.Node node, int startPosition) {
processors.forEach((p) => p.onStartPosition(node, startPosition));
}
@override
void onPositions(
js.Node node, int startPosition, int endPosition, int closingPosition) {
processors.forEach((p) =>
p.onPositions(node, startPosition, endPosition, closingPosition));
}
@override
void process(js.Node node, BufferedCodeOutput code) {
processors.forEach((p) => p.process(node, code));
}
}
class MultiSourceInformationBuilder<T> implements SourceInformationBuilder<T> {
final List<SourceInformationBuilder<T>> builders;
MultiSourceInformationBuilder(this.builders);
@override
SourceInformationBuilder forContext(MemberEntity member) {
return new MultiSourceInformationBuilder(
builders.map((b) => b.forContext(member)).toList());
}
@override
SourceInformation buildSwitchCase(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildSwitchCase(node)).toList());
}
@override
SourceInformation buildSwitch(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildSwitch(node)).toList());
}
@override
SourceInformation buildAs(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildAs(node)).toList());
}
@override
SourceInformation buildIs(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildIs(node)).toList());
}
@override
SourceInformation buildTry(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildTry(node)).toList());
}
@override
SourceInformation buildCatch(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildCatch(node)).toList());
}
@override
SourceInformation buildBinary(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildBinary(node)).toList());
}
@override
SourceInformation buildUnary(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildUnary(node)).toList());
}
@override
SourceInformation buildIndexSet(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildIndexSet(node)).toList());
}
@override
SourceInformation buildIndex(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildIndex(node)).toList());
}
@override
SourceInformation buildForInSet(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildForInSet(node)).toList());
}
@override
SourceInformation buildForInCurrent(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildForInCurrent(node)).toList());
}
@override
SourceInformation buildForInMoveNext(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildForInMoveNext(node)).toList());
}
@override
SourceInformation buildForInIterator(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildForInIterator(node)).toList());
}
@override
SourceInformation buildStringInterpolation(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildStringInterpolation(node)).toList());
}
@override
SourceInformation buildForeignCode(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildForeignCode(node)).toList());
}
@override
SourceInformation buildVariableDeclaration() {
return new MultiSourceInformation(
builders.map((b) => b.buildVariableDeclaration()).toList());
}
@override
SourceInformation buildAwait(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildAwait(node)).toList());
}
@override
SourceInformation buildYield(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildYield(node)).toList());
}
@override
SourceInformation buildAsyncBody() {
return new MultiSourceInformation(
builders.map((b) => b.buildAsyncBody()).toList());
}
@override
SourceInformation buildAsyncExit() {
return new MultiSourceInformation(
builders.map((b) => b.buildAsyncExit()).toList());
}
@override
SourceInformation buildAssignment(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildAssignment(node)).toList());
}
@override
SourceInformation buildThrow(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildThrow(node)).toList());
}
@override
SourceInformation buildNew(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildNew(node)).toList());
}
@override
SourceInformation buildIf(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildIf(node)).toList());
}
@override
SourceInformation buildCall(T receiver, T call) {
return new MultiSourceInformation(
builders.map((b) => b.buildCall(receiver, call)).toList());
}
@override
SourceInformation buildGet(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildGet(node)).toList());
}
@override
SourceInformation buildLoop(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildLoop(node)).toList());
}
@override
SourceInformation buildImplicitReturn(MemberEntity element) {
return new MultiSourceInformation(
builders.map((b) => b.buildImplicitReturn(element)).toList());
}
@override
SourceInformation buildReturn(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildReturn(node)).toList());
}
@override
SourceInformation buildCreate(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildCreate(node)).toList());
}
@override
SourceInformation buildListLiteral(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildListLiteral(node)).toList());
}
@override
SourceInformation buildGeneric(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildGeneric(node)).toList());
}
@override
SourceInformation buildDeclaration(MemberEntity member) {
return new MultiSourceInformation(
builders.map((b) => b.buildDeclaration(member)).toList());
}
@override
SourceInformation buildStub(
FunctionEntity function, CallStructure callStructure) {
return new MultiSourceInformation(
builders.map((b) => b.buildStub(function, callStructure)).toList());
}
@override
SourceInformation buildGoto(T node) {
return new MultiSourceInformation(
builders.map((b) => b.buildGoto(node)).toList());
}
}
class MultiSourceInformation implements SourceInformation {
final List<SourceInformation> infos;
MultiSourceInformation(this.infos);
@override
String get shortText => infos.first?.shortText;
@override
List<SourceLocation> get sourceLocations => infos.first?.sourceLocations;
@override
SourceLocation get endPosition => infos.first?.endPosition;
@override
SourceLocation get innerPosition => infos.first?.innerPosition;
@override
SourceLocation get startPosition => infos.first?.startPosition;
@override
SourceSpan get sourceSpan => infos.first?.sourceSpan;
String toString() => '$infos';
}
class MultiSourceInformationReader implements SourceInformationReader {
final SourceInformationReader reader;
final int index;
MultiSourceInformationReader(this.reader, this.index);
@override
SourceInformation getSourceInformation(js.Node node) {
MultiSourceInformation sourceInformation =
reader.getSourceInformation(node);
if (sourceInformation == null) return null;
return sourceInformation.infos[index];
}
}

View file

@ -10,7 +10,6 @@ import 'package:compiler/src/diagnostics/source_span.dart';
import 'package:compiler/src/diagnostics/spannable.dart';
import 'package:compiler/src/elements/entities.dart';
import 'package:compiler/src/options.dart';
import 'package:front_end/src/fasta/scanner.dart';
abstract class DiagnosticReporterWrapper extends DiagnosticReporter {
DiagnosticReporter get reporter;
@ -63,9 +62,6 @@ abstract class DiagnosticReporterWrapper extends DiagnosticReporter {
return reporter.spanFromSpannable(node);
}
@override
SourceSpan spanFromToken(Token token) => reporter.spanFromToken(token);
@override
withCurrentElement(Entity element, f()) {
return reporter.withCurrentElement(element, f);