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

Unified Diff: lib/compiler/implementation/ssa/builder.dart

Issue 10905305: Patch refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Replaced includeInjectedMembers by implementation Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/ssa/builder.dart
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart
index f3783d8e2ccf281f417e91c218988316d8a7eee5..b2faf0e430fbe98ca65795355da2b0347a42b72e 100644
--- a/lib/compiler/implementation/ssa/builder.dart
+++ b/lib/compiler/implementation/ssa/builder.dart
@@ -195,7 +195,8 @@ class SsaBuilderTask extends CompilerTask {
// If there is an estimate of the parameter types assume these types
// when compiling.
OptionalParameterTypes defaultValueTypes = null;
- FunctionSignature signature = element.computeSignature(compiler);
+ FunctionSignature signature =
+ element.computeSignature(compiler);
ahe 2012/10/02 13:27:04 Why this change?
Johnni Winther 2012/10/03 09:22:59 There was more code here at an intermediate step.
if (signature.optionalParameterCount > 0) {
defaultValueTypes =
new OptionalParameterTypes(signature.optionalParameterCount);
@@ -217,7 +218,7 @@ class SsaBuilderTask extends CompilerTask {
});
}
backend.registerParameterTypesOptimization(
- element, parameterTypes, defaultValueTypes);
+ element.declaration, parameterTypes, defaultValueTypes);
}
if (compiler.tracer.enabled) {
@@ -242,7 +243,8 @@ class SsaBuilderTask extends CompilerTask {
HGraph compileConstructor(SsaBuilder builder, WorkItem work) {
// The body of the constructor will be generated in a separate function.
final ClassElement classElement = work.element.getEnclosingClass();
- return builder.buildFactory(classElement, work.element.implementation);
+ return builder.buildFactory(classElement.implementation,
+ work.element.implementation);
}
}
@@ -974,6 +976,14 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
compiler.resolver.resolveMethodElement(constructor.declaration);
classElement.backendMembers =
classElement.backendMembers.prepend(bodyElement);
+
+ if (constructor.origin != null) {
ahe 2012/10/02 13:27:04 isPatched?
Johnni Winther 2012/10/03 09:22:59 Done.
+ // Create origin body element for patched constructors.
+ bodyElement.origin = new ConstructorBodyElement(constructor.origin);
+ bodyElement.origin.patch = bodyElement;
+ classElement.origin.backendMembers =
+ classElement.origin.backendMembers.prepend(bodyElement.origin);
+ }
compiler.enqueuer.codegen.addToWorkList(bodyElement.declaration,
treeElements);
}
@@ -1111,7 +1121,8 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
element: constructor);
}
- buildFieldInitializers(constructor.enclosingElement, fieldValues);
+ buildFieldInitializers(constructor.enclosingElement.implementation,
+ fieldValues);
int index = 0;
FunctionSignature params = constructor.computeSignature(compiler);
@@ -1189,6 +1200,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
assert(superClass.resolutionState == STATE_DONE);
Selector selector =
new Selector.call(superClass.name, enclosingClass.getLibrary(), 0);
+ // TODO(johnniwinther): Should we find injected constructors as well?
FunctionElement target = superClass.lookupConstructor(superClass.name);
if (target === null) {
compiler.internalError("no default constructor available");
@@ -1206,11 +1218,11 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
* Run through the fields of [cls] and add their potential
* initializers.
*
- * Invariant: [classElement] must be a declaration element.
+ * Invariant: [classElement] must be an implementation element.
*/
void buildFieldInitializers(ClassElement classElement,
Map<Element, HInstruction> fieldValues) {
- assert(invariant(classElement, classElement.isDeclaration));
+ assert(invariant(classElement, classElement.isImplementation));
classElement.forEachInstanceField(
includeBackendMembers: true,
includeSuperMembers: false,
@@ -1243,12 +1255,12 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
* - Call the the constructor bodies, starting from the constructor(s) in the
* super class(es).
*
- * Invariants: [classElement] must be a declaration element, and
- * [functionElement] must be an implementation element.
+ * Invariant: Both [classElement] and [functionElement] must be
+ * implementation elements.
*/
HGraph buildFactory(ClassElement classElement,
FunctionElement functionElement) {
- assert(invariant(classElement, classElement.isDeclaration));
+ assert(invariant(classElement, classElement.isImplementation));
assert(invariant(functionElement, functionElement.isImplementation));
FunctionExpression function = functionElement.parseNode(compiler);
// Note that constructors (like any other static function) do not need

Powered by Google App Engine
This is Rietveld 408576698