Skip to content

Commit 2ee5807

Browse files
create selectors directly from method invocations in kernel -> ssa
BUG= [email protected] Review URL: https://codereview.chromium.org/2297283002 .
1 parent 227766e commit 2ee5807

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

pkg/compiler/lib/src/ssa/builder_kernel.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
8888
sourceInformationBuilder.buildVariableDeclaration();
8989
this.localsHandler =
9090
new LocalsHandler(this, functionElement, null, compiler);
91-
this.astAdapter = new KernelAstAdapter(compiler.backend, resolvedAst,
92-
visitor.nodeToAst, visitor.nodeToElement, kernel.functions);
91+
this.astAdapter = new KernelAstAdapter(
92+
compiler.backend,
93+
resolvedAst,
94+
visitor.nodeToAst,
95+
visitor.nodeToElement,
96+
kernel.functions,
97+
kernel.libraries);
9398
}
9499

95100
HGraph build() {

pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import '../js_backend/js_backend.dart';
1212
import '../resolution/tree_elements.dart';
1313
import '../tree/tree.dart' as ast;
1414
import '../types/masks.dart';
15+
import '../universe/call_structure.dart';
1516
import '../universe/selector.dart';
1617
import '../universe/side_effects.dart';
1718

@@ -26,11 +27,19 @@ class KernelAstAdapter {
2627
final Map<ir.Node, ast.Node> _nodeToAst;
2728
final Map<ir.Node, Element> _nodeToElement;
2829

29-
KernelAstAdapter(this._backend, this._resolvedAst, this._nodeToAst,
30-
this._nodeToElement, Map<FunctionElement, ir.Member> functions) {
30+
KernelAstAdapter(
31+
this._backend,
32+
this._resolvedAst,
33+
this._nodeToAst,
34+
this._nodeToElement,
35+
Map<FunctionElement, ir.Member> functions,
36+
Map<LibraryElement, ir.Library> libraries) {
3137
for (FunctionElement functionElement in functions.keys) {
3238
_nodeToElement[functions[functionElement]] = functionElement;
3339
}
40+
for (LibraryElement libraryElement in libraries.keys) {
41+
_nodeToElement[libraries[libraryElement]] = libraryElement;
42+
}
3443
}
3544

3645
Compiler get _compiler => _backend.compiler;
@@ -73,7 +82,22 @@ class KernelAstAdapter {
7382

7483
// TODO(het): Create the selector directly from the invocation
7584
Selector getSelector(ir.MethodInvocation invocation) {
76-
return _elements.getSelector(getNode(invocation));
85+
SelectorKind kind = Elements.isOperatorName(invocation.name.name)
86+
? SelectorKind.OPERATOR
87+
: SelectorKind.CALL;
88+
89+
ir.Name irName = invocation.name;
90+
Name name = new Name(
91+
irName.name, irName.isPrivate ? getElement(irName.library) : null);
92+
93+
int argumentCount = invocation.arguments.positional.length +
94+
invocation.arguments.named.length;
95+
List<String> namedArguments =
96+
invocation.arguments.named.map((e) => e.name).toList();
97+
CallStructure callStructure =
98+
new CallStructure(argumentCount, namedArguments);
99+
100+
return new Selector(kind, name, callStructure);
77101
}
78102

79103
TypeMask getTypeMask(ir.MethodInvocation invocation) {

0 commit comments

Comments
 (0)