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

Unified Diff: pkg/fletchc/lib/src/fletch_backend.dart

Issue 1450393002: Roll sdk dependency to 34357cdad108dcba734949bd13bd28c76ea285e0 (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Update status files Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: pkg/fletchc/lib/src/fletch_backend.dart
diff --git a/pkg/fletchc/lib/src/fletch_backend.dart b/pkg/fletchc/lib/src/fletch_backend.dart
index 2d40f40347eb99a7a1d49000bb9057b65838fdd0..60b5163eb3ebf8f50187ff2ec62efa1a75452b94 100644
--- a/pkg/fletchc/lib/src/fletch_backend.dart
+++ b/pkg/fletchc/lib/src/fletch_backend.dart
@@ -10,18 +10,22 @@ import 'dart:async' show
import 'dart:collection' show
Queue;
-import 'package:compiler/src/dart2jslib.dart' show
+import 'package:compiler/src/common/backend_api.dart' show
Backend,
- BackendConstantEnvironment,
- Compiler,
- CompilerTask,
- ConstantCompilerTask,
+ ImpactTransformer;
+
+import 'package:compiler/src/common/tasks.dart' show
+ CompilerTask;
+
+import 'package:compiler/src/enqueue.dart' show
Enqueuer,
- MessageKind,
- Registry,
- ResolutionCallbacks,
- ResolutionEnqueuer,
- isPrivateName;
+ ResolutionEnqueuer;
+
+import 'package:compiler/src/diagnostics/messages.dart' show
+ MessageKind;
+
+import 'package:compiler/src/common/registry.dart' show
+ Registry;
import 'package:compiler/src/dart_types.dart' show
DartType,
@@ -47,14 +51,22 @@ import 'package:compiler/src/elements/elements.dart' show
LibraryElement,
MemberElement,
Name,
- ParameterElement;
+ ParameterElement,
+ PublicName;
-import 'package:compiler/src/universe/universe.dart' show
- CallStructure,
- Selector,
- UniverseSelector;
+import 'package:compiler/src/universe/selector.dart' show
+ Selector;
-import 'package:compiler/src/util/util.dart' show
+import 'package:compiler/src/universe/use.dart' show
+ DynamicUse,
+ StaticUse,
+ TypeUse,
+ TypeUseKind;
+
+import 'package:compiler/src/universe/call_structure.dart' show
+ CallStructure;
+
+import 'package:compiler/src/common.dart' show
Spannable;
import 'package:compiler/src/elements/modelx.dart' show
@@ -80,7 +92,7 @@ import 'package:compiler/src/constants/values.dart' show
import 'package:compiler/src/constants/expressions.dart' show
ConstantExpression;
-import 'package:compiler/src/resolution/resolution.dart' show
+import 'package:compiler/src/resolution/tree_elements.dart' show
TreeElements;
import 'package:compiler/src/library_loader.dart' show
@@ -90,9 +102,7 @@ import 'package:persistent/persistent.dart' show
PersistentMap;
import 'fletch_function_builder.dart' show
- FletchFunctionKind,
- FletchFunctionBuilder,
- DebugInfo;
+ FletchFunctionBuilder;
import 'fletch_class_builder.dart' show
FletchClassBuilder;
@@ -114,6 +124,15 @@ import 'fletch_registry.dart' show
import 'diagnostic.dart' show
throwInternalError;
+import 'package:compiler/src/common/names.dart' show
+ Identifiers,
+ Names;
+
+import 'package:compiler/src/universe/world_impact.dart' show
+ TransformedWorldImpact,
+ WorldImpact,
+ WorldImpactBuilder;
+
import 'class_debug_info.dart';
import 'codegen_visitor.dart';
import 'debug_info.dart';
@@ -130,6 +149,7 @@ import 'closure_environment.dart';
import '../bytecodes.dart';
import '../commands.dart';
import '../fletch_system.dart';
+import 'package:compiler/src/common/resolution.dart';
const FletchSystem BASE_FLETCH_SYSTEM = const FletchSystem(
const PersistentMap<int, FletchFunction>(),
@@ -143,7 +163,7 @@ const FletchSystem BASE_FLETCH_SYSTEM = const FletchSystem(
const PersistentMap<int, int>(),
const PersistentMap<int, int>());
-class FletchBackend extends Backend with ResolutionCallbacks
+class FletchBackend extends Backend
implements IncrementalFletchBackend {
static const String growableListName = '_GrowableList';
static const String constantListName = '_ConstantList';
@@ -224,11 +244,15 @@ class FletchBackend extends Backend with ResolutionCallbacks
final Set<FunctionElement> alwaysEnqueue = new Set<FunctionElement>();
+ FletchImpactTransformer impactTransformer;
+
FletchBackend(FletchCompilerImplementation compiler)
: this.context = compiler.context,
this.constantCompilerTask = new DartConstantTask(compiler),
this.systemBuilder = new FletchSystemBuilder(BASE_FLETCH_SYSTEM),
- super(compiler);
+ super(compiler) {
+ this.impactTransformer = new FletchImpactTransformer(this);
+ }
void newSystemBuilder(FletchSystem predecessorSystem) {
systemBuilder = new FletchSystemBuilder(predecessorSystem);
@@ -255,8 +279,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
// This is a workaround, where we basically add getters for all fields.
classBuilder.updateImplicitAccessors(this);
- Element callMember = element.lookupLocalMember(
- Compiler.CALL_OPERATOR_NAME);
+ Element callMember = element.lookupLocalMember(Identifiers.call);
if (callMember != null && callMember.isFunction) {
FunctionElement function = callMember;
classBuilder.createIsFunctionEntry(
@@ -273,8 +296,6 @@ class FletchBackend extends Backend with ResolutionCallbacks
return classBuilder;
}
- ResolutionCallbacks get resolutionCallbacks => this;
-
List<CompilerTask> get tasks => <CompilerTask>[];
ConstantSystem get constantSystem {
@@ -287,8 +308,8 @@ class FletchBackend extends Backend with ResolutionCallbacks
bool methodNeedsRti(FunctionElement function) => false;
- void enqueueHelpers(ResolutionEnqueuer world, incomingRegistry) {
- FletchRegistry registry = incomingRegistry;
+ void enqueueHelpers(ResolutionEnqueuer world, Registry incomingRegistry) {
+ FletchRegistry registry = new FletchRegistry(compiler);
compiler.patchAnnotationClass = patchAnnotationClass;
bool hasMissingHelpers = false;
@@ -302,7 +323,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
}
if (helper == null) {
hasMissingHelpers = true;
- compiler.reportError(
+ compiler.reporter.reportErrorMessage(
library, MessageKind.GENERIC,
{'text': "Required implementation method '$name' not found."});
}
@@ -312,9 +333,12 @@ class FletchBackend extends Backend with ResolutionCallbacks
throwInternalError(
"Some implementation methods are missing, see details above");
}
- world.registerStaticUse(fletchCompileError);
- world.registerStaticUse(fletchSystemEntry);
- world.registerStaticUse(fletchUnresolved);
+ world.registerStaticUse(
+ new StaticUse.staticInvoke(fletchCompileError, CallStructure.NO_ARGS));
+ world.registerStaticUse(
+ new StaticUse.staticInvoke(fletchSystemEntry, CallStructure.ONE_ARG));
+ world.registerStaticUse(
+ new StaticUse.staticInvoke(fletchUnresolved, CallStructure.ONE_ARG));
loadHelperClasses((
String name,
@@ -323,7 +347,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
var classImpl = library.findLocal(name);
if (classImpl == null) classImpl = library.implementation.find(name);
if (classImpl == null) {
- compiler.reportError(
+ compiler.reporter.reportErrorMessage(
library, MessageKind.GENERIC,
{'text': "Required implementation class '$name' not found."});
hasMissingHelpers = true;
@@ -334,8 +358,8 @@ class FletchBackend extends Backend with ResolutionCallbacks
{
// TODO(ahe): Register in ResolutionCallbacks. The lines in this block
// should not happen at this point in time.
- classImpl.ensureResolved(compiler);
- world.registerInstantiatedType(classImpl.rawType, registry.asRegistry);
+ classImpl.ensureResolved(compiler.resolution);
+ world.registerInstantiatedType(classImpl.rawType);
// TODO(ahe): This is a hack to let both the world and the codegen know
// about the instantiated type.
registry.registerInstantiatedType(classImpl.rawType);
@@ -349,21 +373,25 @@ class FletchBackend extends Backend with ResolutionCallbacks
// Register list constructors to world.
// TODO(ahe): Register growableListClass through ResolutionCallbacks.
- growableListClass.constructors.forEach(world.registerStaticUse);
+ growableListClass.constructors.forEach((Element element) {
+ world.registerStaticUse(new StaticUse.constructorInvoke(element, null));
+ });
// TODO(ajohnsen): Remove? String interpolation does not enqueue '+'.
// Investigate what else it may enqueue, could be StringBuilder, and then
// consider using that instead.
- var selector = new UniverseSelector(new Selector.binaryOperator('+'), null);
- world.registerDynamicInvocation(selector);
+ world.registerDynamicUse(
+ new DynamicUse(new Selector.binaryOperator('+'), null));
- selector = new UniverseSelector(new Selector.call('add', null, 1), null);
- world.registerDynamicInvocation(selector);
+ world.registerDynamicUse(new DynamicUse(
+ new Selector.call(new PublicName('add'), CallStructure.ONE_ARG), null));
- alwaysEnqueue.add(compiler.objectClass.implementation.lookupLocalMember(
- noSuchMethodTrampolineName));
- alwaysEnqueue.add(compiler.objectClass.implementation.lookupLocalMember(
- noSuchMethodName));
+ alwaysEnqueue.add(
+ compiler.coreClasses.objectClass.implementation.lookupLocalMember(
+ noSuchMethodTrampolineName));
+ alwaysEnqueue.add(
+ compiler.coreClasses.objectClass.implementation.lookupLocalMember(
+ noSuchMethodName));
if (coroutineClass != null) {
builtinClasses.add(coroutineClass);
@@ -371,7 +399,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
}
for (FunctionElement element in alwaysEnqueue) {
- world.registerStaticUse(element);
+ world.registerStaticUse(new StaticUse.foreignUse(element));
}
}
@@ -431,24 +459,21 @@ class FletchBackend extends Backend with ResolutionCallbacks
// This class is optional.
coroutineClass = fletchSystemLibrary.implementation.find("Coroutine");
if (coroutineClass != null) {
- coroutineClass.ensureResolved(compiler);
+ coroutineClass.ensureResolved(compiler.resolution);
}
}
void onElementResolved(Element element, TreeElements elements) {
if (alwaysEnqueue.contains(element)) {
- var registry = new FletchRegistry(compiler, elements);
- registry.registerStaticInvocation(element);
+ var registry = new FletchRegistry(compiler);
+ if (element.isStatic || element.isTopLevel) {
+ registry.registerStaticUse(new StaticUse.foreignUse(element));
+ } else {
+ registry.registerDynamicUse(new Selector.fromElement(element));
ahe 2015/12/01 10:12:12 This isn't a dynamic use, and it is a problem for
sigurdm 2015/12/03 14:48:09 Done.
+ }
}
}
- void onMapLiteral(Registry registry, DartType type, bool isConstant) {
- if (isConstant) return;
- ClassElement classImpl = mapImplementation;
- registry.registerInstantiation(classImpl.rawType);
- registry.registerStaticInvocation(classImpl.lookupDefaultConstructor());
- }
-
ClassElement get intImplementation => smiClass;
/// Class of annotations to mark patches in patch files.
@@ -458,8 +483,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
/// compile-time constant instance of [patchAnnotationClass].
ClassElement get patchAnnotationClass {
// TODO(ahe): Introduce a proper constant class to identify constants. For
- // now, we simply put "const patch = "patch";" in the beginning of patch
- // files.
+ // now, we simply put "const patch = "patch";" in fletch._system.
return super.stringImplementation;
}
@@ -696,7 +720,6 @@ class FletchBackend extends Backend with ResolutionCallbacks
builder,
context,
elements,
- null,
closureEnvironment,
element,
compiler);
@@ -710,7 +733,6 @@ class FletchBackend extends Backend with ResolutionCallbacks
builder,
context,
elements,
- null,
closureEnvironment,
element,
classBuilder,
@@ -721,21 +743,20 @@ class FletchBackend extends Backend with ResolutionCallbacks
builder,
context,
elements,
- null,
closureEnvironment,
element,
compiler);
}
if (isNative(element)) {
- compiler.withCurrentElement(element, () {
+ compiler.reporter.withCurrentElement(element, () {
codegenNativeFunction(element, codegen);
});
} else if (isExternal(element)) {
- compiler.withCurrentElement(element, () {
+ compiler.reporter.withCurrentElement(element, () {
codegenExternalFunction(element, codegen);
});
} else {
- compiler.withCurrentElement(element, () { codegen.compile(); });
+ compiler.reporter.withCurrentElement(element, () { codegen.compile(); });
}
// The debug codegen should generate the same bytecodes as the original
// codegen. If that is not the case debug information will be useless.
@@ -757,13 +778,14 @@ class FletchBackend extends Backend with ResolutionCallbacks
TreeElements treeElements,
FletchRegistry registry) {
AstElement element = declaration.implementation;
- compiler.withCurrentElement(element, () {
+ compiler.reporter.withCurrentElement(element, () {
assert(declaration.isDeclaration);
context.compiler.reportVerboseInfo(element, 'Compiling $element');
if (element.isFunction ||
element.isGetter ||
element.isSetter ||
- element.isGenerativeConstructor) {
+ element.isGenerativeConstructor ||
+ element.isFactoryConstructor) {
// For a generative constructor, this means compile the constructor
// body. See [compilePendingConstructorInitializers] for an overview of
// how constructor initializers and constructor bodies are compiled.
@@ -772,7 +794,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
context.compiler.reportVerboseInfo(
element, "Asked to compile a field, but don't know how");
} else {
- compiler.internalError(
+ compiler.reporter.internalError(
element, "Uninimplemented element kind: ${element.kind}");
}
});
@@ -788,7 +810,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
TreeElements treeElements,
FletchRegistry registry) {
AstElement element = declaration.implementation;
- compiler.withCurrentElement(element, () {
+ compiler.reporter.withCurrentElement(element, () {
assert(declaration.isDeclaration);
context.compiler.reportVerboseInfo(element, 'Compiling $element');
if (!element.isInstanceMember && !isLocalFunction(element)) {
@@ -835,7 +857,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
FletchRegistry registry,
ClosureKind kind) {
AstElement element = declaration.implementation;
- compiler.withCurrentElement(element, () {
+ compiler.reporter.withCurrentElement(element, () {
assert(declaration.isDeclaration);
if (shouldReportEnqueuingOfElement(compiler, element)) {
context.compiler.reportVerboseInfo(
@@ -844,7 +866,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
FletchFunctionBase function =
systemBuilder.lookupFunctionByElement(element.declaration);
if (function == null) {
- compiler.internalError(
+ compiler.reporter.internalError(
element, "Has no fletch function, but used as tear-off");
}
if (selector.isGetter) {
@@ -853,16 +875,16 @@ class FletchBackend extends Backend with ResolutionCallbacks
// TODO(ahe): This code should probably use [kind] to detect the
// various cases instead of [isLocalFunction] and looking at names.
- assert(selector.memberName == Selector.CALL_NAME);
+ assert(selector.memberName == Names.CALL_NAME);
if (isLocalFunction(element) ||
- memberName(element) == Selector.CALL_NAME) {
+ memberName(element) == Names.CALL_NAME) {
createTearoffGetterForFunction(
function, isSpecialCallMethod: true);
return;
}
int stub = systemBuilder.lookupTearOffById(function.functionId);
if (stub == null) {
- compiler.internalError(
+ compiler.reporter.internalError(
element, "No tear-off stub to compile `call` tear-off");
} else {
function = systemBuilder.lookupFunction(stub);
@@ -873,7 +895,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
switch (kind) {
case ClosureKind.tearOff:
case ClosureKind.superTearOff:
- if (memberName(element) == Selector.CALL_NAME) {
+ if (memberName(element) == Names.CALL_NAME) {
// This is really a functionLikeTearOff.
break;
}
@@ -881,7 +903,8 @@ class FletchBackend extends Backend with ResolutionCallbacks
// that stub:
int stub = systemBuilder.lookupTearOffById(function.functionId);
if (stub == null) {
- compiler.internalError(element, "Couldn't find tear-off stub");
+ compiler.reporter
+ .internalError(element, "Couldn't find tear-off stub");
} else {
function = systemBuilder.lookupFunction(stub);
}
@@ -894,7 +917,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
case ClosureKind.functionLike:
case ClosureKind.functionLikeTearOff:
- compiler.internalError(element, "Unimplemented: $kind");
+ compiler.reporter.internalError(element, "Unimplemented: $kind");
break;
}
@@ -908,7 +931,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
FunctionElement function,
TreeElements elements,
FletchRegistry registry) {
- registry.registerStaticInvocation(fletchSystemEntry);
+ registry.registerStaticUse(new StaticUse.foreignUse(fletchSystemEntry));
ahe 2015/12/01 10:12:12 Should not create an instance of StaticUse.
sigurdm 2015/12/03 14:48:09 Done.
ClosureEnvironment closureEnvironment = createClosureEnvironment(
function,
@@ -919,7 +942,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
if (function.memberContext != function) {
functionBuilder = internalCreateFletchFunctionBuilder(
function,
- Compiler.CALL_OPERATOR_NAME,
+ Identifiers.call,
createClosureClass(function, closureEnvironment));
} else {
functionBuilder = createFletchFunctionBuilder(function);
@@ -1002,24 +1025,21 @@ class FletchBackend extends Backend with ResolutionCallbacks
// The static native method `Coroutine._coroutineNewStack` will invoke
// the instance method `Coroutine._coroutineStart`.
if (coroutineClass == null) {
- compiler.internalError(
+ compiler.reporter.internalError(
function, "required class [Coroutine] not found");
}
FunctionElement coroutineStart =
coroutineClass.lookupLocalMember("_coroutineStart");
Selector selector = new Selector.fromElement(coroutineStart);
- new FletchRegistry(compiler, function.resolvedAst.elements)
- ..registerDynamicInvocation(new UniverseSelector(selector, null));
+ new FletchRegistry(compiler)
+ ..registerDynamicUse(selector);
} else if (name == "Process._spawn") {
// The native method `Process._spawn` will do a closure invoke with 0, 1,
// or 2 arguments.
- new FletchRegistry(compiler, function.resolvedAst.elements)
- ..registerDynamicInvocation(
- new UniverseSelector(new Selector.callClosure(0), null))
- ..registerDynamicInvocation(
- new UniverseSelector(new Selector.callClosure(1), null))
- ..registerDynamicInvocation(
- new UniverseSelector(new Selector.callClosure(2), null));
+ new FletchRegistry(compiler)
+ ..registerDynamicUse(new Selector.callClosure(0))
ahe 2015/12/01 10:12:12 It's somewhat confusing that FletchRegistry uses t
sigurdm 2015/12/03 14:48:09 I renamed it to registerDynamicSelector
+ ..registerDynamicUse(new Selector.callClosure(1))
+ ..registerDynamicUse(new Selector.callClosure(2));
}
int arity = codegen.assembler.functionArity;
@@ -1055,7 +1075,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
function.library == compiler.coreLibrary) {
codegenExternalNoSuchMethodTrampoline(function, codegen);
} else {
- compiler.reportError(
+ compiler.reporter.reportErrorMessage(
function.node,
MessageKind.GENERIC,
{'text': 'External function is not supported'});
@@ -1090,7 +1110,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
void codegenExternalInvokeMain(
FunctionElement function,
FunctionCodegen codegen) {
- compiler.internalError(
+ compiler.reporter.internalError(
function, "[codegenExternalInvokeMain] not implemented.");
// TODO(ahe): This code shouldn't normally be called, only if invokeMain is
// torn off. Perhaps we should just say we don't support that.
@@ -1103,7 +1123,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
// kept in sync with:
// src/vm/interpreter.cc:HandleEnterNoSuchMethod
int id = context.getSymbolId(
- context.mangleName(noSuchMethodName, compiler.coreLibrary));
+ context.mangleName(new Name(noSuchMethodName, compiler.coreLibrary)));
int fletchSelector = FletchSelector.encodeMethod(id, 3);
BytecodeLabel skipGetter = new BytecodeLabel();
codegen.assembler
@@ -1159,9 +1179,8 @@ class FletchBackend extends Backend with ResolutionCallbacks
FunctionElement function = value.element;
createTearoffClass(createFletchFunctionBuilder(function));
// Be sure to actually enqueue the function for compilation.
- FletchRegistry registry =
- new FletchRegistry(compiler, function.resolvedAst.elements);
- registry.registerStaticInvocation(function);
+ FletchRegistry registry = new FletchRegistry(compiler);
+ registry.registerStaticUse(new StaticUse.foreignUse(function));
ahe 2015/12/01 10:12:12 Shouldn't instantiate StaticUse.
sigurdm 2015/12/03 14:48:09 Done.
}
FletchFunctionBase createParameterStubFor(
@@ -1289,8 +1308,10 @@ class FletchBackend extends Backend with ResolutionCallbacks
if (function.element != null) {
library = function.element.library;
}
+ // TODO(sigurdm): Avoid allocating new name here.
+ Name name = new Name(function.name, library);
int fletchSelector = context.toFletchSelector(
- new Selector.getter(function.name, library));
+ new Selector.getter(name));
ahe 2015/12/01 10:12:12 Also, we shouldn't allocate a selector.
sigurdm 2015/12/03 14:48:09 Added to TODO
FletchClassBuilder classBuilder = systemBuilder.lookupClassBuilder(
function.memberOf);
classBuilder.addToMethodTable(fletchSelector, getter);
@@ -1343,7 +1364,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
}
bool registerDeferredLoading(Spannable node, Registry registry) {
- compiler.reportWarning(
+ compiler.reporter.reportWarningMessage(
node,
MessageKind.GENERIC,
{'text': "Deferred loading is not supported."});
@@ -1391,13 +1412,13 @@ class FletchBackend extends Backend with ResolutionCallbacks
FunctionElement resolveExternalFunction(FunctionElement element) {
if (element.isPatched) {
FunctionElementX patch = element.patch;
- compiler.withCurrentElement(patch, () {
- patch.parseNode(compiler);
- patch.computeType(compiler);
+ compiler.reporter.withCurrentElement(patch, () {
+ patch.parseNode(compiler.parsing);
+ patch.computeType(compiler.resolution);
});
element = patch;
// TODO(ahe): Don't use ensureResolved (fix TODO in isNative instead).
- element.metadata.forEach((m) => m.ensureResolved(compiler));
+ element.metadata.forEach((m) => m.ensureResolved(compiler.resolution));
} else if (element.library == fletchSystemLibrary) {
// Nothing needed for now.
} else if (element.library == compiler.coreLibrary) {
@@ -1411,7 +1432,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
} else if (externals.contains(element)) {
// Nothing needed for now.
} else {
- compiler.reportError(
+ compiler.reporter.reportErrorMessage(
element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION);
}
return element;
@@ -1459,7 +1480,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
void compileConstructorInitializer(FletchFunctionBuilder functionBuilder) {
ConstructorElement constructor = functionBuilder.element;
assert(constructor.isImplementation);
- compiler.withCurrentElement(constructor, () {
+ compiler.reporter.withCurrentElement(constructor, () {
assert(functionBuilder ==
systemBuilder.lookupConstructorInitializerByElement(constructor));
context.compiler.reportVerboseInfo(
@@ -1470,8 +1491,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
// TODO(ahe): We shouldn't create a registry, but we have to as long as
// the enqueuer doesn't support elements with more than one compilation
// artifact.
- FletchRegistry registry =
- new FletchRegistry(compiler, elements);
+ FletchRegistry registry = new FletchRegistry(compiler);
FletchClassBuilder classBuilder =
registerClassElement(constructor.enclosingClass.declaration);
@@ -1517,7 +1537,7 @@ class FletchBackend extends Backend with ResolutionCallbacks
FletchFunctionBuilder function,
{bool suppressHint: false}) {
if (!suppressHint) {
- compiler.reportHint(
+ compiler.reporter.reportHintMessage(
spannable, MessageKind.GENERIC, {'text': reason});
}
var constString = constantSystem.createString(
@@ -1614,10 +1634,10 @@ class FletchBackend extends Backend with ResolutionCallbacks
}
bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) {
- if (!enqueuer.isResolutionQueue) {
+ if (enqueuer is! ResolutionEnqueuer) {
compilePendingConstructorInitializers();
}
- return super.onQueueEmpty(enqueuer, recentClasses);
+ return true;
}
FletchEnqueueTask makeEnqueuer() => new FletchEnqueueTask(compiler);
@@ -1656,6 +1676,51 @@ class FletchBackend extends Backend with ResolutionCallbacks
static FletchBackend newInstance(FletchCompilerImplementation compiler) {
return new FletchBackend(compiler);
}
+
+ Uri resolvePatchUri(String libraryName, Uri libraryRoot) {
+ throw "Not implemented";
+ }
+
ahe 2015/12/01 10:12:12 Extra line.
sigurdm 2015/12/03 14:48:09 Done.
+}
+
+class FletchImpactTransformer extends ImpactTransformer {
+ final FletchBackend backend;
+
+ FletchImpactTransformer(this.backend);
+
+ @override
+ WorldImpact transformResolutionImpact(ResolutionImpact worldImpact) {
+ TransformedWorldImpact transformed =
+ new TransformedWorldImpact(worldImpact);
+
+ bool anyChange = false;
+
+ if (worldImpact.constSymbolNames.isNotEmpty) {
+ ClassElement symbolClass =
+ backend.compiler.coreClasses.symbolClass.declaration;
+ transformed.registerTypeUse(
+ new TypeUse.instantiation(symbolClass.rawType));
+ transformed.registerStaticUse(
+ new StaticUse.foreignUse(
+ symbolClass.lookupConstructor("")));
+ anyChange = true;
+ }
+
+ for (MapLiteralUse mapLiteralUse in worldImpact.mapLiterals) {
+ if (mapLiteralUse.isConstant) continue;
+ transformed.registerTypeUse(
+ new TypeUse.instantiation(backend.mapImplementation.rawType));
+ transformed.registerStaticUse(
+ new StaticUse.constructorInvoke(
+ backend.mapImplementation.lookupConstructor(""),
+ CallStructure.NO_ARGS));
+ anyChange = true;
+ }
+ return anyChange ? transformed : worldImpact;
+ }
+
+ @override
+ transformCodegenImpact(impact) => throw "unimplemented";
}
bool isLocalFunction(Element element) {

Powered by Google App Engine
This is Rietveld 408576698