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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 17413013: Revert "Support runtime check of function types." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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()
11 : boundsChecked = new Set<HInstruction>(); 11 : boundsChecked = new Set<HInstruction>();
12 } 12 }
13 13
14
15 class CheckedModeHelper {
16 final SourceString name;
17
18 const CheckedModeHelper(SourceString this.name);
19
20 Element getElement(Compiler compiler) => compiler.findHelper(name);
21
22 jsAst.Expression generateCall(SsaCodeGenerator codegen,
23 HTypeConversion node) {
24 Element helperElement = getElement(codegen.compiler);
25 codegen.world.registerStaticUse(helperElement);
26 List<jsAst.Expression> arguments = <jsAst.Expression>[];
27 codegen.use(node.checkedInput);
28 arguments.add(codegen.pop());
29 generateAdditionalArguments(codegen, node, arguments);
30 String helperName = codegen.backend.namer.isolateAccess(helperElement);
31 return new jsAst.Call(new jsAst.VariableUse(helperName), arguments);
32 }
33
34 void generateAdditionalArguments(SsaCodeGenerator codegen,
35 HTypeConversion node,
36 List<jsAst.Expression> arguments) {
37 assert(!node.typeExpression.isMalformed);
38 // No additional arguments needed.
39 }
40 }
41
42 class PropertyCheckedModeHelper extends CheckedModeHelper {
43 const PropertyCheckedModeHelper(SourceString name) : super(name);
44
45 void generateAdditionalArguments(SsaCodeGenerator codegen,
46 HTypeConversion node,
47 List<jsAst.Expression> arguments) {
48 DartType type = node.typeExpression;
49 assert(!type.isMalformed);
50 String additionalArgument = codegen.backend.namer.operatorIsType(type);
51 arguments.add(js.string(additionalArgument));
52 }
53 }
54
55 class TypeVariableCheckedModeHelper extends CheckedModeHelper {
56 const TypeVariableCheckedModeHelper(SourceString name) : super(name);
57
58 void generateAdditionalArguments(SsaCodeGenerator codegen,
59 HTypeConversion node,
60 List<jsAst.Expression> arguments) {
61 assert(node.typeExpression.kind == TypeKind.TYPE_VARIABLE);
62 codegen.use(node.typeRepresentation);
63 arguments.add(codegen.pop());
64 }
65 }
66
67 class SubtypeCheckedModeHelper extends CheckedModeHelper {
68 const SubtypeCheckedModeHelper(SourceString name) : super(name);
69
70 void generateAdditionalArguments(SsaCodeGenerator codegen,
71 HTypeConversion node,
72 List<jsAst.Expression> arguments) {
73 DartType type = node.typeExpression;
74 Element element = type.element;
75 String isField = codegen.backend.namer.operatorIs(element);
76 arguments.add(js.string(isField));
77 codegen.use(node.typeRepresentation);
78 arguments.add(codegen.pop());
79 String asField = codegen.backend.namer.substitutionName(element);
80 arguments.add(js.string(asField));
81 }
82 }
83
84 class FunctionTypeCheckedModeHelper extends CheckedModeHelper {
85 const FunctionTypeCheckedModeHelper(SourceString name) : super(name);
86
87 void generateAdditionalArguments(SsaCodeGenerator codegen,
88 HTypeConversion node,
89 List<jsAst.Expression> arguments) {
90 DartType type = node.typeExpression;
91 String signatureName = codegen.backend.namer.getFunctionTypeName(type);
92 arguments.add(js.string(signatureName));
93
94 if (type.containsTypeVariables) {
95 ClassElement contextClass = Types.getClassContext(type);
96 String contextName = codegen.backend.namer.getName(contextClass);
97 arguments.add(js.string(contextName));
98
99 if (node.contextIsTypeArguments) {
100 arguments.add(new jsAst.LiteralNull());
101 codegen.use(node.context);
102 arguments.add(codegen.pop());
103 } else {
104 codegen.use(node.context);
105 arguments.add(codegen.pop());
106 }
107 }
108 }
109 }
110
111 class MalformedCheckedModeHelper extends CheckedModeHelper {
112 const MalformedCheckedModeHelper(SourceString name) : super(name);
113
114 void generateAdditionalArguments(SsaCodeGenerator codegen,
115 HTypeConversion node,
116 List<jsAst.Expression> arguments) {
117 DartType type = node.typeExpression;
118 assert(type.isMalformed);
119 String reasons = Types.fetchReasonsFromMalformedType(type);
120 arguments.add(js.string('$type'));
121 // TODO(johnniwinther): Handle escaping correctly.
122 arguments.add(js.string(reasons));
123 }
124 }
125
126
127 class JavaScriptBackend extends Backend { 14 class JavaScriptBackend extends Backend {
128 SsaBuilderTask builder; 15 SsaBuilderTask builder;
129 SsaOptimizerTask optimizer; 16 SsaOptimizerTask optimizer;
130 SsaCodeGeneratorTask generator; 17 SsaCodeGeneratorTask generator;
131 CodeEmitterTask emitter; 18 CodeEmitterTask emitter;
132 19
133 /** 20 /**
134 * The generated code as a js AST for compiled methods. 21 * The generated code as a js AST for compiled methods.
135 */ 22 */
136 Map<Element, jsAst.Expression> get generatedCode { 23 Map<Element, jsAst.Expression> get generatedCode {
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 } 606 }
720 607
721 void registerSetRuntimeType(TreeElements elements) { 608 void registerSetRuntimeType(TreeElements elements) {
722 enqueueInResolution(getSetRuntimeTypeInfo(), elements); 609 enqueueInResolution(getSetRuntimeTypeInfo(), elements);
723 } 610 }
724 611
725 void registerGetRuntimeTypeArgument(TreeElements elements) { 612 void registerGetRuntimeTypeArgument(TreeElements elements) {
726 enqueueInResolution(getGetRuntimeTypeArgument(), elements); 613 enqueueInResolution(getGetRuntimeTypeArgument(), elements);
727 } 614 }
728 615
729 void registerGenericCallMethod(Element callMethod, 616 void registerRuntimeType(TreeElements elements) {
730 Enqueuer enqueuer, TreeElements elements) {
731 if (enqueuer.isResolutionQueue || methodNeedsRti(callMethod)) {
732 registerComputeSignature(enqueuer, elements);
733 }
734 }
735
736 void registerGenericClosure(Element closure,
737 Enqueuer enqueuer, TreeElements elements) {
738 if (enqueuer.isResolutionQueue || methodNeedsRti(closure)) {
739 registerComputeSignature(enqueuer, elements);
740 }
741 }
742
743 void registerComputeSignature(Enqueuer enqueuer, TreeElements elements) {
744 // Calls to [:computeSignature:] are generated by the emitter and we
745 // therefore need to enqueue the used elements in the codegen enqueuer as
746 // well as in the resolution enqueuer.
747 enqueue(enqueuer, getSetRuntimeTypeInfo(), elements);
748 enqueue(enqueuer, getGetRuntimeTypeInfo(), elements);
749 enqueue(enqueuer, getComputeSignature(), elements);
750 enqueue(enqueuer, getGetRuntimeTypeArguments(), elements);
751 enqueuer.registerInstantiatedClass(compiler.listClass, elements);
752 }
753
754 void registerRuntimeType(Enqueuer enqueuer, TreeElements elements) {
755 registerComputeSignature(enqueuer, elements);
756 enqueueInResolution(getSetRuntimeTypeInfo(), elements); 617 enqueueInResolution(getSetRuntimeTypeInfo(), elements);
757 enqueueInResolution(getGetRuntimeTypeInfo(), elements); 618 enqueueInResolution(getGetRuntimeTypeInfo(), elements);
758 registerGetRuntimeTypeArgument(elements); 619 enqueueInResolution(getGetRuntimeTypeArgument(), elements);
759 compiler.enqueuer.resolution.registerInstantiatedClass( 620 compiler.enqueuer.resolution.registerInstantiatedClass(
760 compiler.listClass, elements); 621 compiler.listClass, elements);
761 } 622 }
762 623
763 void registerTypeVariableExpression(TreeElements elements) { 624 void registerTypeVariableExpression(TreeElements elements) {
764 enqueueInResolution(getSetRuntimeTypeInfo(), elements); 625 registerRuntimeType(elements);
765 enqueueInResolution(getGetRuntimeTypeInfo(), elements);
766 registerGetRuntimeTypeArgument(elements);
767 compiler.enqueuer.resolution.registerInstantiatedClass(
768 compiler.listClass, elements);
769 enqueueInResolution(getRuntimeTypeToString(), elements); 626 enqueueInResolution(getRuntimeTypeToString(), elements);
770 enqueueInResolution(getCreateRuntimeType(), elements); 627 enqueueInResolution(getCreateRuntimeType(), elements);
771 } 628 }
772 629
773 void registerIsCheck(DartType type, Enqueuer world, TreeElements elements) { 630 void registerIsCheck(DartType type, Enqueuer world, TreeElements elements) {
774 type = type.unalias(compiler);
775 world.registerInstantiatedClass(compiler.boolClass, elements); 631 world.registerInstantiatedClass(compiler.boolClass, elements);
632 bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE;
776 bool inCheckedMode = compiler.enableTypeAssertions; 633 bool inCheckedMode = compiler.enableTypeAssertions;
777 // [registerIsCheck] is also called for checked mode checks, so we 634 if (!type.isRaw || isTypeVariable) {
778 // need to register checked mode helpers.
779 if (inCheckedMode) {
780 CheckedModeHelper helper = getCheckedModeHelper(type, typeCast: false);
781 if (helper != null) world.addToWorkList(helper.getElement(compiler));
782 // We also need the native variant of the check (for DOM types).
783 helper = getNativeCheckedModeHelper(type, typeCast: false);
784 if (helper != null) world.addToWorkList(helper.getElement(compiler));
785 if (type.isMalformed) {
786 enqueueInResolution(getThrowMalformedSubtypeError(), elements);
787 return;
788 }
789 } else if (type.isMalformed) {
790 registerThrowRuntimeError(elements);
791 return;
792 }
793 bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE;
794 if (!type.isRaw || type.containsTypeVariables) {
795 enqueueInResolution(getSetRuntimeTypeInfo(), elements); 635 enqueueInResolution(getSetRuntimeTypeInfo(), elements);
796 enqueueInResolution(getGetRuntimeTypeInfo(), elements); 636 enqueueInResolution(getGetRuntimeTypeInfo(), elements);
797 enqueueInResolution(getGetRuntimeTypeArgument(), elements); 637 enqueueInResolution(getGetRuntimeTypeArgument(), elements);
798 if (inCheckedMode) { 638 if (inCheckedMode) {
799 enqueueInResolution(getAssertSubtype(), elements); 639 enqueueInResolution(getAssertSubtype(), elements);
800 } 640 }
801 enqueueInResolution(getCheckSubtype(), elements); 641 enqueueInResolution(getCheckSubtype(), elements);
802 if (isTypeVariable) { 642 if (isTypeVariable) {
803 enqueueInResolution(getCheckSubtypeOfRuntimeType(), elements); 643 enqueueInResolution(getCheckSubtypeOfRuntimeType(), elements);
804 if (inCheckedMode) { 644 if (inCheckedMode) {
805 enqueueInResolution(getAssertSubtypeOfRuntimeType(), elements); 645 enqueueInResolution(getAssertSubtypeOfRuntimeType(), elements);
806 } 646 }
807 } 647 }
808 world.registerInstantiatedClass(compiler.listClass, elements); 648 world.registerInstantiatedClass(compiler.listClass, elements);
809 } 649 }
810 if (type is FunctionType) { 650 // [registerIsCheck] is also called for checked mode checks, so we
811 enqueueInResolution(getCheckFunctionSubtype(), elements); 651 // need to register checked mode helpers.
652 if (inCheckedMode) {
653 Element e = getCheckedModeHelper(type, typeCast: false);
654 if (e != null) world.addToWorkList(e);
655 // We also need the native variant of the check (for DOM types).
656 e = getNativeCheckedModeHelper(type, typeCast: false);
657 if (e != null) world.addToWorkList(e);
812 } 658 }
813 if (type.element.isNative()) { 659 if (type.element.isNative()) {
814 // We will neeed to add the "$is" and "$as" properties on the 660 // We will neeed to add the "$is" and "$as" properties on the
815 // JavaScript object prototype, so we make sure 661 // JavaScript object prototype, so we make sure
816 // [:defineProperty:] is compiled. 662 // [:defineProperty:] is compiled.
817 world.addToWorkList( 663 world.addToWorkList(
818 compiler.findHelper(const SourceString('defineProperty'))); 664 compiler.findHelper(const SourceString('defineProperty')));
819 } 665 }
820 } 666 }
821 667
822 void registerAsCheck(DartType type, TreeElements elements) { 668 void registerAsCheck(DartType type, TreeElements elements) {
823 type = type.unalias(compiler); 669 Element e = getCheckedModeHelper(type, typeCast: true);
824 CheckedModeHelper helper = getCheckedModeHelper(type, typeCast: true); 670 enqueueInResolution(e, elements);
825 enqueueInResolution(helper.getElement(compiler), elements);
826 // We also need the native variant of the check (for DOM types). 671 // We also need the native variant of the check (for DOM types).
827 helper = getNativeCheckedModeHelper(type, typeCast: true); 672 e = getNativeCheckedModeHelper(type, typeCast: true);
828 if (helper != null) { 673 enqueueInResolution(e, elements);
829 enqueueInResolution(helper.getElement(compiler), elements);
830 }
831 } 674 }
832 675
833 void registerThrowNoSuchMethod(TreeElements elements) { 676 void registerThrowNoSuchMethod(TreeElements elements) {
834 enqueueInResolution(getThrowNoSuchMethod(), elements); 677 enqueueInResolution(getThrowNoSuchMethod(), elements);
835 } 678 }
836 679
837 void registerThrowRuntimeError(TreeElements elements) { 680 void registerThrowRuntimeError(TreeElements elements) {
838 enqueueInResolution(getThrowRuntimeError(), elements); 681 enqueueInResolution(getThrowRuntimeError(), elements);
839 } 682 }
840 683
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 analyzeTypeArgument(type, argument); 727 analyzeTypeArgument(type, argument);
885 }); 728 });
886 } 729 }
887 // TODO(ngeoffray): Also handle T a (in checked mode). 730 // TODO(ngeoffray): Also handle T a (in checked mode).
888 } 731 }
889 732
890 void registerClassUsingVariableExpression(ClassElement cls) { 733 void registerClassUsingVariableExpression(ClassElement cls) {
891 rti.classesUsingTypeVariableExpression.add(cls); 734 rti.classesUsingTypeVariableExpression.add(cls);
892 } 735 }
893 736
894 bool classNeedsRti(ClassElement cls) { 737 bool needsRti(ClassElement cls) {
895 return rti.classesNeedingRti.contains(cls.declaration) || 738 return rti.classesNeedingRti.contains(cls.declaration) ||
896 compiler.enabledRuntimeType; 739 compiler.enabledRuntimeType;
897 } 740 }
898 741
899 bool isDefaultNoSuchMethodImplementation(Element element) { 742 bool isDefaultNoSuchMethodImplementation(Element element) {
900 assert(element.name == Compiler.NO_SUCH_METHOD); 743 assert(element.name == Compiler.NO_SUCH_METHOD);
901 ClassElement classElement = element.getEnclosingClass(); 744 ClassElement classElement = element.getEnclosingClass();
902 return classElement == compiler.objectClass 745 return classElement == compiler.objectClass
903 || classElement == jsInterceptorClass; 746 || classElement == jsInterceptorClass;
904 } 747 }
905 748
906 bool isDefaultEqualityImplementation(Element element) { 749 bool isDefaultEqualityImplementation(Element element) {
907 assert(element.name == const SourceString('==')); 750 assert(element.name == const SourceString('=='));
908 ClassElement classElement = element.getEnclosingClass(); 751 ClassElement classElement = element.getEnclosingClass();
909 return classElement == compiler.objectClass 752 return classElement == compiler.objectClass
910 || classElement == jsInterceptorClass 753 || classElement == jsInterceptorClass
911 || classElement == jsNullClass; 754 || classElement == jsNullClass;
912 } 755 }
913 756
914 bool methodNeedsRti(FunctionElement function) {
915 return rti.methodsNeedingRti.contains(function) ||
916 compiler.enabledRuntimeType;
917 }
918
919 void enqueue(Enqueuer enqueuer, Element e, TreeElements elements) {
920 enqueuer.addToWorkList(e);
921 elements.registerDependency(e);
922 }
923
924 void enqueueInResolution(Element e, TreeElements elements) { 757 void enqueueInResolution(Element e, TreeElements elements) {
925 if (e == null) return; 758 if (e == null) return;
926 ResolutionEnqueuer enqueuer = compiler.enqueuer.resolution; 759 ResolutionEnqueuer enqueuer = compiler.enqueuer.resolution;
927 enqueue(enqueuer, e, elements); 760 enqueuer.addToWorkList(e);
761 elements.registerDependency(e);
928 } 762 }
929 763
930 void registerConstantMap(TreeElements elements) { 764 void registerConstantMap(TreeElements elements) {
931 Element e = compiler.findHelper(const SourceString('ConstantMap')); 765 Element e = compiler.findHelper(const SourceString('ConstantMap'));
932 if (e != null) { 766 if (e != null) {
933 compiler.enqueuer.resolution.registerInstantiatedClass(e, elements); 767 compiler.enqueuer.resolution.registerInstantiatedClass(e, elements);
934 } 768 }
935 e = compiler.findHelper(const SourceString('ConstantProtoMap')); 769 e = compiler.findHelper(const SourceString('ConstantProtoMap'));
936 if (e != null) { 770 if (e != null) {
937 compiler.enqueuer.resolution.registerInstantiatedClass(e, elements); 771 compiler.enqueuer.resolution.registerInstantiatedClass(e, elements);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 return element; 850 return element;
1017 } 851 }
1018 } 852 }
1019 853
1020 /** 854 /**
1021 * Returns the checked mode helper that will be needed to do a type check/type 855 * Returns the checked mode helper that will be needed to do a type check/type
1022 * cast on [type] at runtime. Note that this method is being called both by 856 * cast on [type] at runtime. Note that this method is being called both by
1023 * the resolver with interface types (int, String, ...), and by the SSA 857 * the resolver with interface types (int, String, ...), and by the SSA
1024 * backend with implementation types (JSInt, JSString, ...). 858 * backend with implementation types (JSInt, JSString, ...).
1025 */ 859 */
1026 CheckedModeHelper getCheckedModeHelper(DartType type, {bool typeCast}) { 860 Element getCheckedModeHelper(DartType type, {bool typeCast}) {
1027 return getCheckedModeHelperInternal( 861 SourceString name = getCheckedModeHelperName(
1028 type, typeCast: typeCast, nativeCheckOnly: false); 862 type, typeCast: typeCast, nativeCheckOnly: false);
863 return compiler.findHelper(name);
1029 } 864 }
1030 865
1031 /** 866 /**
1032 * Returns the native checked mode helper that will be needed to do a type 867 * Returns the native checked mode helper that will be needed to do a type
1033 * check/type cast on [type] at runtime. If no native helper exists for 868 * check/type cast on [type] at runtime. If no native helper exists for
1034 * [type], [:null:] is returned. 869 * [type], [:null:] is returned.
1035 */ 870 */
1036 CheckedModeHelper getNativeCheckedModeHelper(DartType type, {bool typeCast}) { 871 Element getNativeCheckedModeHelper(DartType type, {bool typeCast}) {
1037 return getCheckedModeHelperInternal( 872 SourceString sourceName = getCheckedModeHelperName(
1038 type, typeCast: typeCast, nativeCheckOnly: true); 873 type, typeCast: typeCast, nativeCheckOnly: true);
874 if (sourceName == null) return null;
875 return compiler.findHelper(sourceName);
1039 } 876 }
1040 877
1041 /** 878 /**
1042 * Returns the checked mode helper for the type check/type cast for [type]. If 879 * Returns the name of the type check/type cast helper method for [type]. If
1043 * [nativeCheckOnly] is [:true:], only names for native helpers are returned. 880 * [nativeCheckOnly] is [:true:], only names for native helpers are returned.
1044 */ 881 */
1045 CheckedModeHelper getCheckedModeHelperInternal(DartType type, 882 SourceString getCheckedModeHelperName(DartType type,
1046 {bool typeCast, 883 {bool typeCast,
1047 bool nativeCheckOnly}) { 884 bool nativeCheckOnly}) {
1048 assert(type.kind != TypeKind.TYPEDEF);
1049 Element element = type.element; 885 Element element = type.element;
1050 bool nativeCheck = nativeCheckOnly || 886 bool nativeCheck = nativeCheckOnly ||
1051 emitter.nativeEmitter.requiresNativeIsCheck(element); 887 emitter.nativeEmitter.requiresNativeIsCheck(element);
1052 if (type.isMalformed) { 888 if (type.isMalformed) {
1053 // Check for malformed types first, because the type may be a list type 889 // Check for malformed types first, because the type may be a list type
1054 // with a malformed argument type. 890 // with a malformed argument type.
1055 if (nativeCheckOnly) return null; 891 if (nativeCheckOnly) return null;
1056 return typeCast 892 return typeCast
1057 ? const MalformedCheckedModeHelper( 893 ? const SourceString('malformedTypeCast')
1058 const SourceString('malformedTypeCast')) 894 : const SourceString('malformedTypeCheck');
1059 : const MalformedCheckedModeHelper(
1060 const SourceString('malformedTypeCheck'));
1061 } else if (type == compiler.types.voidType) { 895 } else if (type == compiler.types.voidType) {
1062 assert(!typeCast); // Cannot cast to void. 896 assert(!typeCast); // Cannot cast to void.
1063 if (nativeCheckOnly) return null; 897 if (nativeCheckOnly) return null;
1064 return const CheckedModeHelper(const SourceString('voidTypeCheck')); 898 return const SourceString('voidTypeCheck');
1065 } else if (element == jsStringClass || element == compiler.stringClass) { 899 } else if (element == jsStringClass || element == compiler.stringClass) {
1066 if (nativeCheckOnly) return null; 900 if (nativeCheckOnly) return null;
1067 return typeCast 901 return typeCast
1068 ? const CheckedModeHelper(const SourceString("stringTypeCast")) 902 ? const SourceString("stringTypeCast")
1069 : const CheckedModeHelper(const SourceString('stringTypeCheck')); 903 : const SourceString('stringTypeCheck');
1070 } else if (element == jsDoubleClass || element == compiler.doubleClass) { 904 } else if (element == jsDoubleClass || element == compiler.doubleClass) {
1071 if (nativeCheckOnly) return null; 905 if (nativeCheckOnly) return null;
1072 return typeCast 906 return typeCast
1073 ? const CheckedModeHelper(const SourceString("doubleTypeCast")) 907 ? const SourceString("doubleTypeCast")
1074 : const CheckedModeHelper(const SourceString('doubleTypeCheck')); 908 : const SourceString('doubleTypeCheck');
1075 } else if (element == jsNumberClass || element == compiler.numClass) { 909 } else if (element == jsNumberClass || element == compiler.numClass) {
1076 if (nativeCheckOnly) return null; 910 if (nativeCheckOnly) return null;
1077 return typeCast 911 return typeCast
1078 ? const CheckedModeHelper(const SourceString("numTypeCast")) 912 ? const SourceString("numTypeCast")
1079 : const CheckedModeHelper(const SourceString('numTypeCheck')); 913 : const SourceString('numTypeCheck');
1080 } else if (element == jsBoolClass || element == compiler.boolClass) { 914 } else if (element == jsBoolClass || element == compiler.boolClass) {
1081 if (nativeCheckOnly) return null; 915 if (nativeCheckOnly) return null;
1082 return typeCast 916 return typeCast
1083 ? const CheckedModeHelper(const SourceString("boolTypeCast")) 917 ? const SourceString("boolTypeCast")
1084 : const CheckedModeHelper(const SourceString('boolTypeCheck')); 918 : const SourceString('boolTypeCheck');
1085 } else if (element == jsIntClass || element == compiler.intClass) { 919 } else if (element == jsIntClass || element == compiler.intClass) {
1086 if (nativeCheckOnly) return null; 920 if (nativeCheckOnly) return null;
1087 return typeCast 921 return typeCast ?
1088 ? const CheckedModeHelper(const SourceString("intTypeCast")) 922 const SourceString("intTypeCast") :
1089 : const CheckedModeHelper(const SourceString('intTypeCheck')); 923 const SourceString('intTypeCheck');
1090 } else if (Elements.isNumberOrStringSupertype(element, compiler)) { 924 } else if (Elements.isNumberOrStringSupertype(element, compiler)) {
1091 if (nativeCheck) { 925 if (nativeCheck) {
1092 return typeCast 926 return typeCast
1093 ? const PropertyCheckedModeHelper( 927 ? const SourceString("numberOrStringSuperNativeTypeCast")
1094 const SourceString("numberOrStringSuperNativeTypeCast")) 928 : const SourceString('numberOrStringSuperNativeTypeCheck');
1095 : const PropertyCheckedModeHelper(
1096 const SourceString('numberOrStringSuperNativeTypeCheck'));
1097 } else { 929 } else {
1098 return typeCast 930 return typeCast
1099 ? const PropertyCheckedModeHelper( 931 ? const SourceString("numberOrStringSuperTypeCast")
1100 const SourceString("numberOrStringSuperTypeCast")) 932 : const SourceString('numberOrStringSuperTypeCheck');
1101 : const PropertyCheckedModeHelper(
1102 const SourceString('numberOrStringSuperTypeCheck'));
1103 } 933 }
1104 } else if (Elements.isStringOnlySupertype(element, compiler)) { 934 } else if (Elements.isStringOnlySupertype(element, compiler)) {
1105 if (nativeCheck) { 935 if (nativeCheck) {
1106 return typeCast 936 return typeCast
1107 ? const PropertyCheckedModeHelper( 937 ? const SourceString("stringSuperNativeTypeCast")
1108 const SourceString("stringSuperNativeTypeCast")) 938 : const SourceString('stringSuperNativeTypeCheck');
1109 : const PropertyCheckedModeHelper(
1110 const SourceString('stringSuperNativeTypeCheck'));
1111 } else { 939 } else {
1112 return typeCast 940 return typeCast
1113 ? const PropertyCheckedModeHelper( 941 ? const SourceString("stringSuperTypeCast")
1114 const SourceString("stringSuperTypeCast")) 942 : const SourceString('stringSuperTypeCheck');
1115 : const PropertyCheckedModeHelper(
1116 const SourceString('stringSuperTypeCheck'));
1117 } 943 }
1118 } else if ((element == compiler.listClass || element == jsArrayClass) && 944 } else if ((element == compiler.listClass || element == jsArrayClass) &&
1119 type.isRaw) { 945 type.isRaw) {
1120 if (nativeCheckOnly) return null; 946 if (nativeCheckOnly) return null;
1121 return typeCast 947 return typeCast
1122 ? const CheckedModeHelper(const SourceString("listTypeCast")) 948 ? const SourceString("listTypeCast")
1123 : const CheckedModeHelper(const SourceString('listTypeCheck')); 949 : const SourceString('listTypeCheck');
1124 } else { 950 } else {
1125 if (Elements.isListSupertype(element, compiler)) { 951 if (Elements.isListSupertype(element, compiler)) {
1126 if (nativeCheck) { 952 if (nativeCheck) {
1127 return typeCast 953 return typeCast
1128 ? const PropertyCheckedModeHelper( 954 ? const SourceString("listSuperNativeTypeCast")
1129 const SourceString("listSuperNativeTypeCast")) 955 : const SourceString('listSuperNativeTypeCheck');
1130 : const PropertyCheckedModeHelper(
1131 const SourceString('listSuperNativeTypeCheck'));
1132 } else { 956 } else {
1133 return typeCast 957 return typeCast
1134 ? const PropertyCheckedModeHelper( 958 ? const SourceString("listSuperTypeCast")
1135 const SourceString("listSuperTypeCast")) 959 : const SourceString('listSuperTypeCheck');
1136 : const PropertyCheckedModeHelper(
1137 const SourceString('listSuperTypeCheck'));
1138 } 960 }
1139 } else { 961 } else {
1140 if (nativeCheck) { 962 if (nativeCheck) {
1141 // TODO(karlklose): can we get rid of this branch when we use 963 // TODO(karlklose): can we get rid of this branch when we use
1142 // interceptors? 964 // interceptors?
1143 return typeCast 965 return typeCast
1144 ? const PropertyCheckedModeHelper( 966 ? const SourceString("interceptedTypeCast")
1145 const SourceString("interceptedTypeCast")) 967 : const SourceString('interceptedTypeCheck');
1146 : const PropertyCheckedModeHelper(
1147 const SourceString('interceptedTypeCheck'));
1148 } else { 968 } else {
1149 if (type.kind == TypeKind.INTERFACE && !type.isRaw) { 969 if (type.kind == TypeKind.INTERFACE && !type.isRaw) {
1150 return typeCast 970 return typeCast
1151 ? const SubtypeCheckedModeHelper( 971 ? const SourceString('subtypeCast')
1152 const SourceString('subtypeCast')) 972 : const SourceString('assertSubtype');
1153 : const SubtypeCheckedModeHelper(
1154 const SourceString('assertSubtype'));
1155 } else if (type.kind == TypeKind.TYPE_VARIABLE) { 973 } else if (type.kind == TypeKind.TYPE_VARIABLE) {
1156 return typeCast 974 return typeCast
1157 ? const TypeVariableCheckedModeHelper( 975 ? const SourceString('subtypeOfRuntimeTypeCast')
1158 const SourceString('subtypeOfRuntimeTypeCast')) 976 : const SourceString('assertSubtypeOfRuntimeType');
1159 : const TypeVariableCheckedModeHelper(
1160 const SourceString('assertSubtypeOfRuntimeType'));
1161 } else if (type.kind == TypeKind.FUNCTION) {
1162 return typeCast
1163 ? const FunctionTypeCheckedModeHelper(
1164 const SourceString('functionSubtypeCast'))
1165 : const FunctionTypeCheckedModeHelper(
1166 const SourceString('assertFunctionSubtype'));
1167 } else { 977 } else {
1168 return typeCast 978 return typeCast
1169 ? const PropertyCheckedModeHelper( 979 ? const SourceString('propertyTypeCast')
1170 const SourceString('propertyTypeCast')) 980 : const SourceString('propertyTypeCheck');
1171 : const PropertyCheckedModeHelper(
1172 const SourceString('propertyTypeCheck'));
1173 } 981 }
1174 } 982 }
1175 } 983 }
1176 } 984 }
1177 } 985 }
1178 986
1179 Element getExceptionUnwrapper() { 987 Element getExceptionUnwrapper() {
1180 return compiler.findHelper(const SourceString('unwrapException')); 988 return compiler.findHelper(const SourceString('unwrapException'));
1181 } 989 }
1182 990
1183 Element getThrowRuntimeError() { 991 Element getThrowRuntimeError() {
1184 return compiler.findHelper(const SourceString('throwRuntimeError')); 992 return compiler.findHelper(const SourceString('throwRuntimeError'));
1185 } 993 }
1186 994
1187 Element getMalformedTypeCheck() {
1188 return compiler.findHelper(const SourceString('malformedTypeCheck'));
1189 }
1190
1191 Element getThrowMalformedSubtypeError() { 995 Element getThrowMalformedSubtypeError() {
1192 return compiler.findHelper( 996 return compiler.findHelper(
1193 const SourceString('throwMalformedSubtypeError')); 997 const SourceString('throwMalformedSubtypeError'));
1194 } 998 }
1195 999
1196 Element getThrowAbstractClassInstantiationError() { 1000 Element getThrowAbstractClassInstantiationError() {
1197 return compiler.findHelper( 1001 return compiler.findHelper(
1198 const SourceString('throwAbstractClassInstantiationError')); 1002 const SourceString('throwAbstractClassInstantiationError'));
1199 } 1003 }
1200 1004
(...skipping 22 matching lines...) Expand all
1223 } 1027 }
1224 1028
1225 Element getSetRuntimeTypeInfo() { 1029 Element getSetRuntimeTypeInfo() {
1226 return compiler.findHelper(const SourceString('setRuntimeTypeInfo')); 1030 return compiler.findHelper(const SourceString('setRuntimeTypeInfo'));
1227 } 1031 }
1228 1032
1229 Element getGetRuntimeTypeInfo() { 1033 Element getGetRuntimeTypeInfo() {
1230 return compiler.findHelper(const SourceString('getRuntimeTypeInfo')); 1034 return compiler.findHelper(const SourceString('getRuntimeTypeInfo'));
1231 } 1035 }
1232 1036
1233 Element getComputeSignature() {
1234 return compiler.findHelper(const SourceString('computeSignature'));
1235 }
1236
1237 Element getGetRuntimeTypeArguments() {
1238 return compiler.findHelper(const SourceString('getRuntimeTypeArguments'));
1239 }
1240
1241 Element getGetRuntimeTypeArgument() { 1037 Element getGetRuntimeTypeArgument() {
1242 return compiler.findHelper(const SourceString('getRuntimeTypeArgument')); 1038 return compiler.findHelper(const SourceString('getRuntimeTypeArgument'));
1243 } 1039 }
1244 1040
1245 Element getRuntimeTypeToString() { 1041 Element getRuntimeTypeToString() {
1246 return compiler.findHelper(const SourceString('runtimeTypeToString')); 1042 return compiler.findHelper(const SourceString('runtimeTypeToString'));
1247 } 1043 }
1248 1044
1249 Element getCheckSubtype() { 1045 Element getCheckSubtype() {
1250 return compiler.findHelper(const SourceString('checkSubtype')); 1046 return compiler.findHelper(const SourceString('checkSubtype'));
1251 } 1047 }
1252 1048
1253 Element getAssertSubtype() { 1049 Element getAssertSubtype() {
1254 return compiler.findHelper(const SourceString('assertSubtype')); 1050 return compiler.findHelper(const SourceString('assertSubtype'));
1255 } 1051 }
1256 1052
1257 Element getCheckSubtypeOfRuntimeType() { 1053 Element getCheckSubtypeOfRuntimeType() {
1258 return compiler.findHelper(const SourceString('checkSubtypeOfRuntimeType')); 1054 return compiler.findHelper(const SourceString('checkSubtypeOfRuntimeType'));
1259 } 1055 }
1260 1056
1261 Element getAssertSubtypeOfRuntimeType() { 1057 Element getAssertSubtypeOfRuntimeType() {
1262 return compiler.findHelper( 1058 return compiler.findHelper(
1263 const SourceString('assertSubtypeOfRuntimeType')); 1059 const SourceString('assertSubtypeOfRuntimeType'));
1264 } 1060 }
1265 1061
1266 Element getCheckFunctionSubtype() {
1267 return compiler.findHelper(const SourceString('checkFunctionSubtype'));
1268 }
1269
1270 Element getThrowNoSuchMethod() { 1062 Element getThrowNoSuchMethod() {
1271 return compiler.findHelper(const SourceString('throwNoSuchMethod')); 1063 return compiler.findHelper(const SourceString('throwNoSuchMethod'));
1272 } 1064 }
1273 1065
1274 Element getCreateRuntimeType() { 1066 Element getCreateRuntimeType() {
1275 return compiler.findHelper(const SourceString('createRuntimeType')); 1067 return compiler.findHelper(const SourceString('createRuntimeType'));
1276 } 1068 }
1277 1069
1278 Element getFallThroughError() { 1070 Element getFallThroughError() {
1279 return compiler.findHelper(const SourceString("getFallThroughError")); 1071 return compiler.findHelper(const SourceString("getFallThroughError"));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 } 1119 }
1328 1120
1329 void registerStaticUse(Element element, Enqueuer enqueuer) { 1121 void registerStaticUse(Element element, Enqueuer enqueuer) {
1330 if (element == disableTreeShakingMarker) { 1122 if (element == disableTreeShakingMarker) {
1331 enqueuer.enqueueEverything(); 1123 enqueuer.enqueueEverything();
1332 compiler.disableTypeInferenceForMirrors = true; 1124 compiler.disableTypeInferenceForMirrors = true;
1333 } else if (element == preserveNamesMarker) { 1125 } else if (element == preserveNamesMarker) {
1334 } 1126 }
1335 } 1127 }
1336 } 1128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698