| Index: lib/compiler/implementation/ssa/builder.dart
|
| diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart
|
| index e47ab6f10893eb8b13e3d38248589fe302a02448..bd07dc412bfdba7f69b2b3e66d623c2b0580cf76 100644
|
| --- a/lib/compiler/implementation/ssa/builder.dart
|
| +++ b/lib/compiler/implementation/ssa/builder.dart
|
| @@ -2944,7 +2944,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
|
| HInstruction runtimeType = createForeign(runtimeTypeString, rtiInputs);
|
| add(runtimeType);
|
| runtimeCodeInputs.add(runtimeType);
|
| - runtimeCode.add('runtimeType: #');
|
| + runtimeCode.add("runtimeType: '#'");
|
| }
|
| if (needsRti) {
|
| if (runtimeTypeIsUsed) runtimeCode.add(', ');
|
| @@ -3016,9 +3016,23 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
|
| return;
|
| }
|
| if (compiler.world.needsRti(constructor.enclosingElement)) {
|
| - type.arguments.forEach((DartType argument) {
|
| - inputs.add(analyzeTypeArgument(argument, node));
|
| - });
|
| + if (!type.arguments.isEmpty) {
|
| + type.arguments.forEach((DartType argument) {
|
| + inputs.add(analyzeTypeArgument(argument, node));
|
| + });
|
| + } else if (compiler.enabledRuntimeType) {
|
| + Link<DartType> variables =
|
| + constructor.getEnclosingClass().typeVariables;
|
| + if (!variables.isEmpty) {
|
| + // If the class has type variables but no type arguments have been
|
| + // provided, add [:dynamic:] as argument for all type variables.
|
| + DartString stringDynamic = new DartString.literal('dynamic');
|
| + HInstruction input = graph.addConstantString(stringDynamic,
|
| + node,
|
| + constantSystem);
|
| + variables.forEach((_) => inputs.add(input));
|
| + }
|
| + }
|
| }
|
|
|
| HType elementType = computeType(constructor);
|
| @@ -3090,6 +3104,46 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
|
| }
|
| }
|
|
|
| + HConstant addConstantString(Send node, String string) {
|
| + DartString dartString = new DartString.literal(string);
|
| + Constant constant = constantSystem.createString(dartString, node);
|
| + return graph.addConstant(constant);
|
| + }
|
| +
|
| + visitTypeReferenceSend(Send node) {
|
| + Element element = elements[node];
|
| + HInstruction name;
|
| + Element helper =
|
| + compiler.findHelper(RuntimeTypeInformation.CACHE_HELPER_NAME);
|
| + if (element.isClass()) {
|
| + String string = rti.generateRuntimeTypeString(element, 0);
|
| + name = addConstantString(node.selector, string);
|
| + } else if (element.isTypedef()) {
|
| + // TODO(karlklose): implement support for type variables in typedefs.
|
| + name = addConstantString(node.selector, rti.getName(element));
|
| + } else if (element.isTypeVariable()) {
|
| + // TODO(6248): implement support for type variables.
|
| + compiler.unimplemented('first class type for type variable', node: node);
|
| + } else {
|
| + internalError('unexpected element $element', node: node);
|
| + }
|
| + pushInvokeHelper1(helper, name);
|
| + if (node.isCall) {
|
| + // This send is of the form 'e(...)', where e is resolved to a type
|
| + // reference. We create a regular closure call on the result of the type
|
| + // reference instead of creating a NoSuchMethodError to avoid pulling it
|
| + // in if it is not used (e.g., in a try/catch).
|
| + HInstruction target = pop();
|
| + Selector selector = elements.getSelector(node);
|
| + List<HInstruction> inputs = <HInstruction>[target];
|
| + addDynamicSendArgumentsToList(node, inputs);
|
| + push(new HInvokeClosure(selector, inputs));
|
| + }
|
| + // Enable the runtime type cache, so that the emitter generates one even
|
| + // if we do not have [runtimeType] in the program.
|
| + compiler.enableRuntimeTypeCache();
|
| + }
|
| +
|
| visitGetterSend(Send node) {
|
| generateGetter(node, elements[node]);
|
| }
|
| @@ -3100,10 +3154,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
|
| }
|
|
|
| void generateError(Node node, String message, Element helper) {
|
| - DartString messageObject = new DartString.literal(message);
|
| - Constant messageConstant =
|
| - constantSystem.createString(messageObject, node);
|
| - HInstruction errorMessage = graph.addConstant(messageConstant);
|
| + HInstruction errorMessage = addConstantString(node, message);
|
| pushInvokeHelper1(helper, errorMessage);
|
| }
|
|
|
| @@ -3283,7 +3334,11 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
|
|
|
| // [receiver] is only used if the node is an instance send.
|
| HInstruction receiver = null;
|
| - if (Elements.isInstanceSend(node, elements)) {
|
| + Element selectorElement = elements[node];
|
| + if (!Elements.isUnresolved(selectorElement)
|
| + && selectorElement.impliesType()) {
|
| + visitTypeReferenceSend(node);
|
| + } else if (Elements.isInstanceSend(node, elements)) {
|
| receiver = generateInstanceSendReceiver(node);
|
| generateInstanceGetterWithCompiledReceiver(node, receiver);
|
| } else {
|
|
|