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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1574543003: dart2js: Start creating IR nodes in the IrBuilderVisitor class. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/cps_ir/cps_ir_builder.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
index dfb59eb46268e49b5a89fdec9619b75ac18f08fb..7dbf72c1d23e72af5ba599e6b1dc66c2abd7806d 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
@@ -470,7 +470,10 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
for (Local param in getConstructorBodyParameters(bodyElement)) {
bodyArguments.add(irBuilder.environment.lookup(param));
}
- irBuilder.buildInvokeDirectly(bodyElement, instance, bodyArguments);
+ Selector selector = new Selector.call(target.memberName,
+ new CallStructure(bodyArguments.length));
+ irBuilder.addPrimitive(new ir.InvokeMethodDirectly(
+ instance, bodyElement, selector, bodyArguments, null));
}
// --- step 4: return the created object ----
@@ -1062,13 +1065,15 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
}
visitAwait(ast.Await node) {
+ assert(irBuilder.isOpen);
ir.Primitive value = visit(node.expression);
- return irBuilder.buildAwait(value);
+ return irBuilder.addPrimitive(new ir.Await(value));
}
visitYield(ast.Yield node) {
+ assert(irBuilder.isOpen);
ir.Primitive value = visit(node.expression);
- return irBuilder.buildYield(value, node.hasStar);
+ return irBuilder.addPrimitive(new ir.Yield(value, node.hasStar));
}
visitSyncForIn(ast.SyncForIn node) {
@@ -1103,7 +1108,7 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
ir.Primitive checkType(ir.Primitive value, DartType dartType) {
if (!compiler.trustTypeAnnotations) return value;
TypeMask type = typeMaskSystem.subtypesOf(dartType).nullable();
- return irBuilder.buildRefinement(value, type);
+ return irBuilder.addPrimitive(new ir.Refinement(value, type));
}
ir.Primitive checkTypeVsElement(ir.Primitive value, TypedElement element) {
@@ -1391,13 +1396,14 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
ir.Primitive buildCheckDeferredIsLoaded(PrefixElement prefix, ast.Send node) {
SourceInformation sourceInformation =
sourceInformationBuilder.buildCall(node, node.selector);
+ ir.Primitive name = irBuilder.buildStringConstant(
+ compiler.deferredLoadTask.getImportDeferName(node, prefix));
+ ir.Primitive uri =
+ irBuilder.buildStringConstant('${prefix.deferredImport.uri}');
return irBuilder.buildStaticFunctionInvocation(
helpers.checkDeferredIsLoaded,
- CallStructure.TWO_ARGS, <ir.Primitive>[
- irBuilder.buildStringConstant(
- compiler.deferredLoadTask.getImportDeferName(node, prefix)),
- irBuilder.buildStringConstant('${prefix.deferredImport.uri}'),
- ], sourceInformation: sourceInformation);
+ <ir.Primitive>[name, uri],
+ sourceInformation: sourceInformation);
}
ir.Primitive visitNamedArgument(ast.NamedArgument node) {
@@ -1531,7 +1537,7 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
compiler.deferredLoadTask.getImportDeferName(node, prefix));
return irBuilder.buildStaticFunctionInvocation(
compiler.loadLibraryFunction,
- CallStructure.ONE_ARG, <ir.Primitive>[loadId],
+ <ir.Primitive>[loadId],
sourceInformation: sourceInformation);
} else {
return irBuilder.buildStaticGetterGet(getter, sourceInformation);
@@ -2004,10 +2010,8 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
List<ir.Primitive> arguments = <ir.Primitive>[];
callStructure = translateStaticArguments(argumentsNode, function,
callStructure, arguments);
- return irBuilder.buildStaticFunctionInvocation(function,
- callStructure,
- arguments,
- sourceInformation:
+ Selector selector = new Selector.call(function.memberName, callStructure);
+ return irBuilder.buildInvokeStatic(function, selector, arguments,
sourceInformationBuilder.buildCall(node, node.selector));
}
}
@@ -2788,11 +2792,8 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
List<ir.Primitive> arguments = <ir.Primitive>[];
callStructure = translateStaticArguments(argumentList, element,
callStructure, arguments);
- return irBuilder.buildStaticFunctionInvocation(
- element,
- callStructure,
- arguments,
- sourceInformation:
+ Selector selector = new Selector.call(element.memberName, callStructure);
+ return irBuilder.buildInvokeStatic(element, selector, arguments,
sourceInformationBuilder.buildCall(node, node.selector));
}
@@ -3013,7 +3014,9 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
buildStringParts(node.expression, accumulator);
} else {
ir.Primitive value = visit(node);
- accumulator.add(irBuilder.buildStringify(value));
+ accumulator.add(irBuilder.buildStaticFunctionInvocation(
+ helpers.stringInterpolationHelper,
+ <ir.Primitive>[value]));
}
}
@@ -3055,20 +3058,6 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
[irBuilder.buildInvocationMirror(selector, arguments)]);
}
- ir.Primitive buildRuntimeError(String message) {
- return irBuilder.buildStaticFunctionInvocation(
- helpers.throwRuntimeError,
- new CallStructure.unnamed(1),
- [irBuilder.buildStringConstant(message)]);
- }
-
- ir.Primitive buildAbstractClassInstantiationError(ClassElement element) {
- return irBuilder.buildStaticFunctionInvocation(
- helpers.throwAbstractClassInstantiationError,
- new CallStructure.unnamed(1),
- [irBuilder.buildStringConstant(element.name)]);
- }
-
@override
ir.Primitive visitUnresolvedCompound(
ast.Send node,
@@ -3088,7 +3077,11 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
ast.NodeList arguments,
Selector selector, _) {
// If the class is missing it's a runtime error.
- return buildRuntimeError("Unresolved class: '${element.name}'");
+ ir.Primitive message =
+ irBuilder.buildStringConstant("Unresolved class: '${element.name}'");
+ return irBuilder.buildStaticFunctionInvocation(
+ helpers.throwRuntimeError,
+ <ir.Primitive>[message]);
}
@override
@@ -3255,7 +3248,11 @@ class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
ast.NodeList arguments,
CallStructure callStructure, _) {
for (ast.Node argument in arguments) visit(argument);
- return buildAbstractClassInstantiationError(element.enclosingClass);
+ ir.Primitive name =
+ irBuilder.buildStringConstant(element.enclosingClass.name);
+ return irBuilder.buildStaticFunctionInvocation(
+ helpers.throwAbstractClassInstantiationError,
+ <ir.Primitive>[name]);
}
@override
@@ -3597,10 +3594,6 @@ class GlobalProgramInformation {
return cls.typeVariables.isNotEmpty && _backend.classNeedsRti(cls);
}
- FunctionElement get stringifyFunction {
- return _backend.helpers.stringInterpolationHelper;
- }
-
FunctionElement get throwTypeErrorHelper => _backend.helpers.throwTypeError;
Element get throwNoSuchMethod => _backend.helpers.throwNoSuchMethod;
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698