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

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 3000123002: dart2js kernel: minimal recognition of external native methods (Closed)
Patch Set: Created 3 years, 4 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: pkg/compiler/lib/src/ssa/builder_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 4857f2a711bbf31be8614d3b78847f77f366c7bb..2da1e5811649290fd0459f5525fcb02b4d3595f5 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -139,7 +139,11 @@ class KernelSsaGraphBuilder extends ir.Visitor
ir.Node target = definition.node;
if (target is ir.Procedure) {
_targetFunction = target.function;
- buildFunctionNode(_targetFunction);
+ if (target.isExternal) {
+ buildExternalFunctionNode(_targetFunction);
+ } else {
+ buildFunctionNode(_targetFunction);
+ }
} else if (target is ir.Field) {
if (handleConstantField(targetElement, registry, closedWorld)) {
// No code is generated for `targetElement`: All references inline
@@ -679,7 +683,7 @@ class KernelSsaGraphBuilder extends ir.Visitor
openFunction(functionNode);
ir.TreeNode parent = functionNode.parent;
if (parent is ir.Procedure && parent.kind == ir.ProcedureKind.Factory) {
- _addClassTypeVariablesIfNeeded(functionNode.parent);
+ _addClassTypeVariablesIfNeeded(parent);
}
// If [functionNode] is `operator==` we explicitly add a null check at the
@@ -713,6 +717,20 @@ class KernelSsaGraphBuilder extends ir.Visitor
closeFunction();
}
+ /// Builds a SSA graph for FunctionNodes of external methods.
+ void buildExternalFunctionNode(ir.FunctionNode functionNode) {
+ openFunction(functionNode);
+ ir.TreeNode parent = functionNode.parent;
+ if (parent is ir.Procedure && parent.kind == ir.ProcedureKind.Factory) {
+ _addClassTypeVariablesIfNeeded(parent);
+ }
+ // TODO(sra): Generate conversion of Function typed arguments to JavaScript
+ // functions.
+ // TODO(sra): Invoke native method.
+ assert(functionNode.body == null);
+ closeFunction();
+ }
+
void addImplicitInstantiation(DartType type) {
if (type != null) {
currentImplicitInstantiations.add(type);
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/dart2js_native.status » ('j') | tests/corelib_2/corelib_2.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698