OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
9 import '../common/names.dart'; | 9 import '../common/names.dart'; |
10 import '../common/tasks.dart' show CompilerTask; | 10 import '../common/tasks.dart' show CompilerTask; |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 StringConstantValue stringConstant = hConstant.constant; | 1211 StringConstantValue stringConstant = hConstant.constant; |
1212 return stringConstant.primitiveValue.slowToString(); | 1212 return stringConstant.primitiveValue.slowToString(); |
1213 } | 1213 } |
1214 | 1214 |
1215 void handleForeignJsCurrentIsolateContext(ir.StaticInvocation invocation) { | 1215 void handleForeignJsCurrentIsolateContext(ir.StaticInvocation invocation) { |
1216 if (_unexpectedForeignArguments(invocation, 0, 0)) { | 1216 if (_unexpectedForeignArguments(invocation, 0, 0)) { |
1217 stack.add(graph.addConstantNull(compiler)); // Result expected on stack. | 1217 stack.add(graph.addConstantNull(compiler)); // Result expected on stack. |
1218 return; | 1218 return; |
1219 } | 1219 } |
1220 | 1220 |
1221 if (!compiler.hasIsolateSupport) { | 1221 if (!backend.hasIsolateSupport) { |
1222 // If the isolate library is not used, we just generate code | 1222 // If the isolate library is not used, we just generate code |
1223 // to fetch the static state. | 1223 // to fetch the static state. |
1224 String name = backend.namer.staticStateHolder; | 1224 String name = backend.namer.staticStateHolder; |
1225 push(new HForeignCode( | 1225 push(new HForeignCode( |
1226 js.js.parseForeignJS(name), backend.dynamicType, <HInstruction>[], | 1226 js.js.parseForeignJS(name), backend.dynamicType, <HInstruction>[], |
1227 nativeBehavior: native.NativeBehavior.DEPENDS_OTHER)); | 1227 nativeBehavior: native.NativeBehavior.DEPENDS_OTHER)); |
1228 } else { | 1228 } else { |
1229 // Call a helper method from the isolate library. The isolate library uses | 1229 // Call a helper method from the isolate library. The isolate library uses |
1230 // its own isolate structure that encapsulates the isolate structure used | 1230 // its own isolate structure that encapsulates the isolate structure used |
1231 // for binding to methods. | 1231 // for binding to methods. |
1232 ir.Procedure target = astAdapter.currentIsolate; | 1232 ir.Procedure target = astAdapter.currentIsolate; |
1233 if (target == null) { | 1233 if (target == null) { |
1234 compiler.reporter.internalError(astAdapter.getNode(invocation), | 1234 compiler.reporter.internalError(astAdapter.getNode(invocation), |
1235 'Isolate library and compiler mismatch.'); | 1235 'Isolate library and compiler mismatch.'); |
1236 } | 1236 } |
1237 _pushStaticInvocation(target, <HInstruction>[], backend.dynamicType); | 1237 _pushStaticInvocation(target, <HInstruction>[], backend.dynamicType); |
1238 } | 1238 } |
1239 } | 1239 } |
1240 | 1240 |
1241 void handleForeignJsCallInIsolate(ir.StaticInvocation invocation) { | 1241 void handleForeignJsCallInIsolate(ir.StaticInvocation invocation) { |
1242 if (_unexpectedForeignArguments(invocation, 2, 2)) { | 1242 if (_unexpectedForeignArguments(invocation, 2, 2)) { |
1243 stack.add(graph.addConstantNull(compiler)); // Result expected on stack. | 1243 stack.add(graph.addConstantNull(compiler)); // Result expected on stack. |
1244 return; | 1244 return; |
1245 } | 1245 } |
1246 | 1246 |
1247 List<HInstruction> inputs = _visitArguments(invocation.arguments); | 1247 List<HInstruction> inputs = _visitArguments(invocation.arguments); |
1248 | 1248 |
1249 if (!compiler.hasIsolateSupport) { | 1249 if (!backend.hasIsolateSupport) { |
1250 // If the isolate library is not used, we ignore the isolate argument and | 1250 // If the isolate library is not used, we ignore the isolate argument and |
1251 // just invoke the closure. | 1251 // just invoke the closure. |
1252 push(new HInvokeClosure(new Selector.callClosure(0), | 1252 push(new HInvokeClosure(new Selector.callClosure(0), |
1253 <HInstruction>[inputs[1]], backend.dynamicType)); | 1253 <HInstruction>[inputs[1]], backend.dynamicType)); |
1254 } else { | 1254 } else { |
1255 // Call a helper method from the isolate library. | 1255 // Call a helper method from the isolate library. |
1256 ir.Procedure callInIsolate = astAdapter.callInIsolate; | 1256 ir.Procedure callInIsolate = astAdapter.callInIsolate; |
1257 if (callInIsolate == null) { | 1257 if (callInIsolate == null) { |
1258 compiler.reporter.internalError(astAdapter.getNode(invocation), | 1258 compiler.reporter.internalError(astAdapter.getNode(invocation), |
1259 'Isolate library and compiler mismatch.'); | 1259 'Isolate library and compiler mismatch.'); |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 push(new HNot(popBoolified(), backend.boolType)); | 1725 push(new HNot(popBoolified(), backend.boolType)); |
1726 } | 1726 } |
1727 | 1727 |
1728 @override | 1728 @override |
1729 void visitStringConcatenation(ir.StringConcatenation stringConcat) { | 1729 void visitStringConcatenation(ir.StringConcatenation stringConcat) { |
1730 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); | 1730 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); |
1731 stringConcat.accept(stringBuilder); | 1731 stringConcat.accept(stringBuilder); |
1732 stack.add(stringBuilder.result); | 1732 stack.add(stringBuilder.result); |
1733 } | 1733 } |
1734 } | 1734 } |
OLD | NEW |