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

Unified Diff: pkg/compiler/lib/src/kernel/kernel_visitor.dart

Issue 2360603002: Roll kernel to latest and add baseline test. (Closed)
Patch Set: dartfmt Created 4 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
« no previous file with comments | « pkg/compiler/lib/src/kernel/kernel.dart ('k') | pkg/compiler/lib/src/serialization/modelz.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/kernel/kernel_visitor.dart
diff --git a/pkg/compiler/lib/src/kernel/kernel_visitor.dart b/pkg/compiler/lib/src/kernel/kernel_visitor.dart
index 415483f4c371f9fc985d87784e52833e0b56c13a..2787d2247b64296014c9bdfc452d45c568f1efdd 100644
--- a/pkg/compiler/lib/src/kernel/kernel_visitor.dart
+++ b/pkg/compiler/lib/src/kernel/kernel_visitor.dart
@@ -20,6 +20,7 @@ import 'package:kernel/frontend/accessors.dart'
makeLet,
makeOrReuseVariable;
+import '../common.dart';
import '../constants/expressions.dart'
show
BoolFromEnvironmentConstantExpression,
@@ -1383,22 +1384,6 @@ class KernelVisitor extends Object
.buildAssignment(visitForValue(rhs), voidContext: isVoidContext);
}
- void addFieldsWithInitializers(
- ConstructorElement constructor, List<ir.Initializer> initializers) {
- constructor.enclosingClass.forEachInstanceField((_, FieldElement element) {
- // Convert the element into the corresponding IR field before asking
- // if the initializer exists. This is necessary to ensure that the
- // element has been analyzed before looking at its initializer.
- ir.Field field = kernel.fieldToIr(element);
- if (element.initializer != null) {
- KernelVisitor visitor =
- new KernelVisitor(element, element.treeElements, kernel);
- ir.Expression value = visitor.buildInitializer();
- initializers.add(new ir.FieldInitializer(field, value));
- }
- });
- }
-
IrFunction buildGenerativeConstructor(
ConstructorElement constructor, NodeList parameters, Node body) {
List<ir.Initializer> constructorInitializers = <ir.Initializer>[];
@@ -1424,13 +1409,11 @@ class KernelVisitor extends Object
if (kernel.isSyntheticError(constructor.definingConstructor)) {
constructorInitializers.add(new ir.InvalidInitializer());
} else {
- addFieldsWithInitializers(constructor, constructorInitializers);
constructorInitializers.add(new ir.SuperInitializer(
kernel.functionToIr(constructor.definingConstructor),
new ir.Arguments(arguments, named: named, types: null)));
}
} else {
- addFieldsWithInitializers(constructor, constructorInitializers);
if (parameters != null) {
// TODO(ahe): the following is a (modified) copy of
// [SemanticDeclarationResolvedMixin.visitParameters].
@@ -1959,11 +1942,13 @@ class KernelVisitor extends Object
ir.VariableDeclaration getLocal(LocalElement local) {
return locals.putIfAbsent(local, () {
+ // Currently, initializing formals are not final.
+ bool isFinal = local.isFinal && !local.isInitializingFormal;
return associateElement(
new ir.VariableDeclaration(local.name,
initializer: null,
type: typeToIrHack(local.type),
- isFinal: local.isFinal,
+ isFinal: isFinal,
isConst: local.isConst),
local);
});
@@ -1997,7 +1982,11 @@ class KernelVisitor extends Object
initializer.parent = variable;
}
});
- returnType = typeToIrHack(signature.type.returnType);
+ if (function.isGenerativeConstructor) {
+ returnType = const ir.VoidType();
+ } else {
+ returnType = typeToIrHack(signature.type.returnType);
+ }
if (function.isFactoryConstructor) {
InterfaceType type = function.enclosingClass.thisType;
if (type.isGeneric) {
@@ -2033,8 +2022,20 @@ class KernelVisitor extends Object
break;
}
}
- ir.Statement body =
- (bodyNode == null) ? null : buildStatementInBlock(bodyNode);
+ ir.Statement body;
+ if (function.isExternal) {
+ // [body] must be `null`.
+ } else if (function.isConstructor) {
+ // TODO(johnniwinther): Clean this up pending kernel issue #28.
+ ConstructorElement constructor = function;
+ if (constructor.isDefaultConstructor) {
+ body = new ir.EmptyStatement();
+ } else if (bodyNode != null && bodyNode.asEmptyStatement() == null) {
+ body = buildStatementInBlock(bodyNode);
+ }
+ } else if (bodyNode != null) {
+ body = buildStatementInBlock(bodyNode);
+ }
return associateElement(
new ir.FunctionNode(body,
asyncMarker: asyncMarker,
« no previous file with comments | « pkg/compiler/lib/src/kernel/kernel.dart ('k') | pkg/compiler/lib/src/serialization/modelz.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698