OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of js_backend; | 5 part of js_backend; |
6 | 6 |
7 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 7 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
8 final Set<HInstruction> boundsChecked; | 8 final Set<HInstruction> boundsChecked; |
9 | 9 |
10 JavaScriptItemCompilationContext() | 10 JavaScriptItemCompilationContext() |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 codegen.use(node.typeRepresentation); | 74 codegen.use(node.typeRepresentation); |
75 arguments.add(codegen.pop()); | 75 arguments.add(codegen.pop()); |
76 String asField = codegen.backend.namer.substitutionName(element); | 76 String asField = codegen.backend.namer.substitutionName(element); |
77 arguments.add(js.string(asField)); | 77 arguments.add(js.string(asField)); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 class FunctionTypeCheckedModeHelper extends CheckedModeHelper { | 81 class FunctionTypeCheckedModeHelper extends CheckedModeHelper { |
82 const FunctionTypeCheckedModeHelper(String name) : super(name); | 82 const FunctionTypeCheckedModeHelper(String name) : super(name); |
83 | 83 |
| 84 jsAst.Expression generateCall(SsaCodeGenerator codegen, |
| 85 HTypeConversion node) { |
| 86 codegen.use(node.inputs[0]); |
| 87 return codegen.pop(); |
| 88 // HInstruction functionType = node.typeRepresentation; |
| 89 // |
| 90 // |
| 91 // |
| 92 // |
| 93 // Element helperElement = getElement(codegen.compiler); |
| 94 // codegen.world.registerStaticUse(helperElement); |
| 95 // List<jsAst.Expression> arguments = <jsAst.Expression>[]; |
| 96 // codegen.use(node.checkedInput); |
| 97 // arguments.add(codegen.pop()); |
| 98 // generateAdditionalArguments(codegen, node, arguments); |
| 99 // String helperName = codegen.backend.namer.isolateAccess(helperElement); |
| 100 // return new jsAst.Call(new jsAst.VariableUse(helperName), arguments); |
| 101 // |
| 102 // |
| 103 // List arguments = [, expression]; |
| 104 // pushInvokeDynamic( |
| 105 // node, new Selector.call('_isTest', compiler.jsHelperLibrary, 1), |
| 106 // arguments); |
| 107 // |
| 108 // return new HIs.compound(type, expression, pop()); |
| 109 // |
| 110 // |
| 111 // generateRuntimeError(null, '<<as-test not implemented $type>>'); |
| 112 |
| 113 |
| 114 |
| 115 |
| 116 } |
| 117 |
| 118 // DEAD CODE, delete this. |
84 void generateAdditionalArguments(SsaCodeGenerator codegen, | 119 void generateAdditionalArguments(SsaCodeGenerator codegen, |
85 HTypeConversion node, | 120 HTypeConversion node, |
86 List<jsAst.Expression> arguments) { | 121 List<jsAst.Expression> arguments) { |
87 DartType type = node.typeExpression; | 122 DartType type = node.typeExpression; |
88 String signatureName = codegen.backend.namer.getFunctionTypeName(type); | 123 String signatureName = codegen.backend.namer.getFunctionTypeName(type); |
89 arguments.add(js.string(signatureName)); | 124 arguments.add(js.string(signatureName)); |
90 | 125 |
91 if (type.containsTypeVariables) { | 126 if (type.containsTypeVariables) { |
92 ClassElement contextClass = Types.getClassContext(type); | 127 ClassElement contextClass = Types.getClassContext(type); |
93 // TODO(ahe): Creating a string here is unfortunate. It is slow (due to | 128 // TODO(ahe): Creating a string here is unfortunate. It is slow (due to |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 enqueueInResolution(getCheckSubtype(), elements); | 1046 enqueueInResolution(getCheckSubtype(), elements); |
1012 if (isTypeVariable) { | 1047 if (isTypeVariable) { |
1013 enqueueInResolution(getCheckSubtypeOfRuntimeType(), elements); | 1048 enqueueInResolution(getCheckSubtypeOfRuntimeType(), elements); |
1014 if (inCheckedMode) { | 1049 if (inCheckedMode) { |
1015 enqueueInResolution(getAssertSubtypeOfRuntimeType(), elements); | 1050 enqueueInResolution(getAssertSubtypeOfRuntimeType(), elements); |
1016 } | 1051 } |
1017 } | 1052 } |
1018 enqueueClass(world, compiler.listClass, elements); | 1053 enqueueClass(world, compiler.listClass, elements); |
1019 } | 1054 } |
1020 if (type is FunctionType) { | 1055 if (type is FunctionType) { |
1021 enqueueInResolution(getCheckFunctionSubtype(), elements); | 1056 // enqueueInResolution(getCheckFunctionSubtype(), elements); |
| 1057 enqueueInResolution(getThrowRuntimeError(), elements); |
| 1058 enqueueInResolution(compiler.findHelper('buildFunctionType'), elements); |
| 1059 enqueueInResolution( |
| 1060 compiler.findHelper('buildNamedFunctionType'), elements); |
| 1061 enqueueInResolution(compiler.findHelper('buildInterfaceType'), elements); |
| 1062 enqueueInResolution( |
| 1063 compiler.findHelper('getDynamicRuntimeType'), elements); |
| 1064 enqueueInResolution( |
| 1065 compiler.findHelper('getVoidRuntimeType'), elements); |
| 1066 enqueueInResolution(compiler.findHelper('buildDummyType'), elements); |
| 1067 enqueueInResolution( |
| 1068 compiler.findHelper('convertRtiToRuntimeType'),elements); |
| 1069 compiler.enqueuer.resolution.registerInvocation( |
| 1070 new Selector.call('_isTest', compiler.jsHelperLibrary, 1)); |
| 1071 compiler.enqueuer.resolution.registerInvocation( |
| 1072 new Selector.call('_asCheck', compiler.jsHelperLibrary, 1)); |
| 1073 compiler.enqueuer.resolution.registerInvocation( |
| 1074 new Selector.call('_assertCheck', compiler.jsHelperLibrary, 1)); |
1022 } | 1075 } |
1023 if (type.element.isNative()) { | 1076 if (type.element.isNative()) { |
1024 // We will neeed to add the "$is" and "$as" properties on the | 1077 // We will neeed to add the "$is" and "$as" properties on the |
1025 // JavaScript object prototype, so we make sure | 1078 // JavaScript object prototype, so we make sure |
1026 // [:defineProperty:] is compiled. | 1079 // [:defineProperty:] is compiled. |
1027 enqueue(world, | 1080 enqueue(world, |
1028 compiler.findHelper('defineProperty'), | 1081 compiler.findHelper('defineProperty'), |
1029 elements); | 1082 elements); |
1030 } | 1083 } |
1031 } | 1084 } |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 } | 1579 } |
1527 | 1580 |
1528 Element getCheckSubtypeOfRuntimeType() { | 1581 Element getCheckSubtypeOfRuntimeType() { |
1529 return compiler.findHelper('checkSubtypeOfRuntimeType'); | 1582 return compiler.findHelper('checkSubtypeOfRuntimeType'); |
1530 } | 1583 } |
1531 | 1584 |
1532 Element getAssertSubtypeOfRuntimeType() { | 1585 Element getAssertSubtypeOfRuntimeType() { |
1533 return compiler.findHelper('assertSubtypeOfRuntimeType'); | 1586 return compiler.findHelper('assertSubtypeOfRuntimeType'); |
1534 } | 1587 } |
1535 | 1588 |
1536 Element getCheckFunctionSubtype() { | |
1537 return compiler.findHelper('checkFunctionSubtype'); | |
1538 } | |
1539 | |
1540 Element getThrowNoSuchMethod() { | 1589 Element getThrowNoSuchMethod() { |
1541 return compiler.findHelper('throwNoSuchMethod'); | 1590 return compiler.findHelper('throwNoSuchMethod'); |
1542 } | 1591 } |
1543 | 1592 |
1544 Element getCreateRuntimeType() { | 1593 Element getCreateRuntimeType() { |
1545 return compiler.findHelper('createRuntimeType'); | 1594 return compiler.findHelper('createRuntimeType'); |
1546 } | 1595 } |
1547 | 1596 |
1548 Element getFallThroughError() { | 1597 Element getFallThroughError() { |
1549 return compiler.findHelper("getFallThroughError"); | 1598 return compiler.findHelper("getFallThroughError"); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1856 copy(constant.values); | 1905 copy(constant.values); |
1857 copy(constant.protoValue); | 1906 copy(constant.protoValue); |
1858 copy(constant); | 1907 copy(constant); |
1859 } | 1908 } |
1860 | 1909 |
1861 void visitConstructed(ConstructedConstant constant) { | 1910 void visitConstructed(ConstructedConstant constant) { |
1862 copy(constant.fields); | 1911 copy(constant.fields); |
1863 copy(constant); | 1912 copy(constant); |
1864 } | 1913 } |
1865 } | 1914 } |
OLD | NEW |