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

Unified Diff: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart

Issue 1526623004: cps_ir: Add JS checks, use argument nullability (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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/compiler/lib/src/tree_ir/tree_ir_builder.dart
diff --git a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
index e6b8c34597602dc4b2cc88c901b214dc7c930ef8..d91c9111744d3c8701e83308d5a9fa41d91b7f65 100644
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
@@ -625,21 +625,16 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
visitForeignCode(cps_ir.ForeignCode node) {
List<Expression> arguments =
node.arguments.map(getVariableUse).toList(growable: false);
- if (HasCapturedArguments.check(node.codeTemplate.ast)) {
- for (Expression arg in arguments) {
- if (arg is VariableUse) {
- arg.variable.isCaptured = true;
- } else {
- // TODO(asgerf): Avoid capture of 'this'.
- }
- }
- }
+ List<bool> nullableArguments = node.arguments
+ .map((argument) => argument.definition.type.isNullable)
+ .toList(growable: false);
if (node.codeTemplate.isExpression) {
return new ForeignExpression(
node.codeTemplate,
node.type,
arguments,
node.nativeBehavior,
+ nullableArguments,
node.dependency);
} else {
return (Statement next) {
@@ -649,6 +644,7 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
node.type,
arguments,
node.nativeBehavior,
+ nullableArguments,
node.dependency);
};
}
@@ -704,28 +700,3 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
visitContinuation(cps_ir.Continuation node) => unexpectedNode(node);
visitMutableVariable(cps_ir.MutableVariable node) => unexpectedNode(node);
}
-
-class HasCapturedArguments extends js.BaseVisitor {
- static bool check(js.Node node) {
- HasCapturedArguments visitor = new HasCapturedArguments();
- node.accept(visitor);
- return visitor.found;
- }
-
- int enclosingFunctions = 0;
- bool found = false;
-
- @override
- visitFun(js.Fun node) {
- ++enclosingFunctions;
- node.visitChildren(this);
- --enclosingFunctions;
- }
-
- @override
- visitInterpolatedNode(js.InterpolatedNode node) {
- if (enclosingFunctions > 0) {
- found = true;
- }
- }
-}
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698