| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.ir_builder_task; | 5 library dart2js.ir_builder_task; |
| 6 | 6 |
| 7 import '../closure.dart' as closure; | 7 import '../closure.dart' as closure; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/names.dart' show | 9 import '../common/names.dart' show |
| 10 Identifiers, | 10 Identifiers, |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 callStructure.getOrderedNamedArguments()); | 871 callStructure.getOrderedNamedArguments()); |
| 872 } | 872 } |
| 873 | 873 |
| 874 /// Read the value of [field]. | 874 /// Read the value of [field]. |
| 875 ir.Primitive buildStaticFieldGet(FieldElement field, SourceInformation src) { | 875 ir.Primitive buildStaticFieldGet(FieldElement field, SourceInformation src) { |
| 876 ConstantValue constant = getConstantForVariable(field); | 876 ConstantValue constant = getConstantForVariable(field); |
| 877 if (constant != null && !field.isAssignable) { | 877 if (constant != null && !field.isAssignable) { |
| 878 typeMaskSystem.associateConstantValueWithElement(constant, field); | 878 typeMaskSystem.associateConstantValueWithElement(constant, field); |
| 879 return irBuilder.buildConstant(constant, sourceInformation: src); | 879 return irBuilder.buildConstant(constant, sourceInformation: src); |
| 880 } else if (backend.constants.lazyStatics.contains(field)) { | 880 } else if (backend.constants.lazyStatics.contains(field)) { |
| 881 return irBuilder.addPrimitive(new ir.GetLazyStatic(field, src)); | 881 return irBuilder.addPrimitive(new ir.GetLazyStatic(field, |
| 882 sourceInformation: src, |
| 883 isFinal: compiler.world.fieldNeverChanges(field))); |
| 882 } else { | 884 } else { |
| 883 return irBuilder.addPrimitive(new ir.GetStatic(field, src)); | 885 return irBuilder.addPrimitive(new ir.GetStatic(field, |
| 886 sourceInformation: src, |
| 887 isFinal: compiler.world.fieldNeverChanges(field))); |
| 884 } | 888 } |
| 885 } | 889 } |
| 886 | 890 |
| 887 ir.FunctionDefinition _makeFunctionBody( | 891 ir.FunctionDefinition _makeFunctionBody( |
| 888 IrBuilder builder, | 892 IrBuilder builder, |
| 889 FunctionElement element, | 893 FunctionElement element, |
| 890 ast.FunctionExpression node) { | 894 ast.FunctionExpression node) { |
| 891 FunctionSignature signature = element.functionSignature; | 895 FunctionSignature signature = element.functionSignature; |
| 892 List<Local> parameters = <Local>[]; | 896 List<Local> parameters = <Local>[]; |
| 893 signature.orderedForEachParameter( | 897 signature.orderedForEachParameter( |
| (...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 LocalElement element, | 1933 LocalElement element, |
| 1930 _) { | 1934 _) { |
| 1931 return irBuilder.buildLocalGet(element); | 1935 return irBuilder.buildLocalGet(element); |
| 1932 } | 1936 } |
| 1933 | 1937 |
| 1934 @override | 1938 @override |
| 1935 ir.Primitive handleStaticFunctionGet( | 1939 ir.Primitive handleStaticFunctionGet( |
| 1936 ast.Send node, | 1940 ast.Send node, |
| 1937 MethodElement function, | 1941 MethodElement function, |
| 1938 _) { | 1942 _) { |
| 1939 return irBuilder.addPrimitive(new ir.GetStatic(function)); | 1943 return irBuilder.addPrimitive(new ir.GetStatic(function, isFinal: true)); |
| 1940 } | 1944 } |
| 1941 | 1945 |
| 1942 @override | 1946 @override |
| 1943 ir.Primitive handleStaticGetterGet( | 1947 ir.Primitive handleStaticGetterGet( |
| 1944 ast.Send node, | 1948 ast.Send node, |
| 1945 FunctionElement getter, | 1949 FunctionElement getter, |
| 1946 _) { | 1950 _) { |
| 1947 return buildStaticGetterGet(getter, node); | 1951 return buildStaticGetterGet(getter, node); |
| 1948 } | 1952 } |
| 1949 | 1953 |
| (...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2895 CompoundRhs rhs, | 2899 CompoundRhs rhs, |
| 2896 arg) { | 2900 arg) { |
| 2897 return translateCompounds(node, () { | 2901 return translateCompounds(node, () { |
| 2898 switch (getterKind) { | 2902 switch (getterKind) { |
| 2899 case CompoundGetter.FIELD: | 2903 case CompoundGetter.FIELD: |
| 2900 SourceInformation src = sourceInformationBuilder.buildGet(node); | 2904 SourceInformation src = sourceInformationBuilder.buildGet(node); |
| 2901 return buildStaticFieldGet(getter, src); | 2905 return buildStaticFieldGet(getter, src); |
| 2902 case CompoundGetter.GETTER: | 2906 case CompoundGetter.GETTER: |
| 2903 return buildStaticGetterGet(getter, node); | 2907 return buildStaticGetterGet(getter, node); |
| 2904 case CompoundGetter.METHOD: | 2908 case CompoundGetter.METHOD: |
| 2905 return irBuilder.addPrimitive(new ir.GetStatic(getter)); | 2909 return irBuilder.addPrimitive(new ir.GetStatic(getter, |
| 2910 isFinal: true)); |
| 2906 case CompoundGetter.UNRESOLVED: | 2911 case CompoundGetter.UNRESOLVED: |
| 2907 return irBuilder.buildStaticNoSuchMethod( | 2912 return irBuilder.buildStaticNoSuchMethod( |
| 2908 new Selector.getter(new Name(getter.name, getter.library)), | 2913 new Selector.getter(new Name(getter.name, getter.library)), |
| 2909 <ir.Primitive>[]); | 2914 <ir.Primitive>[]); |
| 2910 } | 2915 } |
| 2911 }, rhs, (ir.Primitive result) { | 2916 }, rhs, (ir.Primitive result) { |
| 2912 switch (setterKind) { | 2917 switch (setterKind) { |
| 2913 case CompoundSetter.FIELD: | 2918 case CompoundSetter.FIELD: |
| 2914 irBuilder.addPrimitive(new ir.SetStatic(setter, result)); | 2919 irBuilder.addPrimitive(new ir.SetStatic(setter, result)); |
| 2915 return; | 2920 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2935 ast.Node rhs, | 2940 ast.Node rhs, |
| 2936 _) { | 2941 _) { |
| 2937 return translateSetIfNull(node, () { | 2942 return translateSetIfNull(node, () { |
| 2938 switch (getterKind) { | 2943 switch (getterKind) { |
| 2939 case CompoundGetter.FIELD: | 2944 case CompoundGetter.FIELD: |
| 2940 SourceInformation src = sourceInformationBuilder.buildGet(node); | 2945 SourceInformation src = sourceInformationBuilder.buildGet(node); |
| 2941 return buildStaticFieldGet(getter, src); | 2946 return buildStaticFieldGet(getter, src); |
| 2942 case CompoundGetter.GETTER: | 2947 case CompoundGetter.GETTER: |
| 2943 return buildStaticGetterGet(getter, node); | 2948 return buildStaticGetterGet(getter, node); |
| 2944 case CompoundGetter.METHOD: | 2949 case CompoundGetter.METHOD: |
| 2945 return irBuilder.addPrimitive(new ir.GetStatic(getter)); | 2950 return irBuilder.addPrimitive(new ir.GetStatic(getter, |
| 2951 isFinal: true)); |
| 2946 case CompoundGetter.UNRESOLVED: | 2952 case CompoundGetter.UNRESOLVED: |
| 2947 return irBuilder.buildStaticNoSuchMethod( | 2953 return irBuilder.buildStaticNoSuchMethod( |
| 2948 new Selector.getter(new Name(getter.name, getter.library)), | 2954 new Selector.getter(new Name(getter.name, getter.library)), |
| 2949 <ir.Primitive>[]); | 2955 <ir.Primitive>[]); |
| 2950 } | 2956 } |
| 2951 }, rhs, (ir.Primitive result) { | 2957 }, rhs, (ir.Primitive result) { |
| 2952 switch (setterKind) { | 2958 switch (setterKind) { |
| 2953 case CompoundSetter.FIELD: | 2959 case CompoundSetter.FIELD: |
| 2954 irBuilder.addPrimitive(new ir.SetStatic(setter, result)); | 2960 irBuilder.addPrimitive(new ir.SetStatic(setter, result)); |
| 2955 return; | 2961 return; |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4007 } | 4013 } |
| 4008 | 4014 |
| 4009 TypeMask getTypeMaskForNativeFunction(FunctionElement function) { | 4015 TypeMask getTypeMaskForNativeFunction(FunctionElement function) { |
| 4010 return _compiler.typesTask.getGuaranteedReturnTypeOfElement(function); | 4016 return _compiler.typesTask.getGuaranteedReturnTypeOfElement(function); |
| 4011 } | 4017 } |
| 4012 | 4018 |
| 4013 FieldElement locateSingleField(Selector selector, TypeMask type) { | 4019 FieldElement locateSingleField(Selector selector, TypeMask type) { |
| 4014 return _compiler.world.locateSingleField(selector, type); | 4020 return _compiler.world.locateSingleField(selector, type); |
| 4015 } | 4021 } |
| 4016 | 4022 |
| 4023 bool fieldNeverChanges(FieldElement field) { |
| 4024 return _compiler.world.fieldNeverChanges(field); |
| 4025 } |
| 4026 |
| 4017 Element get closureConverter { | 4027 Element get closureConverter { |
| 4018 return _backend.helpers.closureConverter; | 4028 return _backend.helpers.closureConverter; |
| 4019 } | 4029 } |
| 4020 | 4030 |
| 4021 void addNativeMethod(FunctionElement function) { | 4031 void addNativeMethod(FunctionElement function) { |
| 4022 _backend.emitter.nativeEmitter.nativeMethods.add(function); | 4032 _backend.emitter.nativeEmitter.nativeMethods.add(function); |
| 4023 } | 4033 } |
| 4024 | 4034 |
| 4025 bool get trustJSInteropTypeAnnotations => | 4035 bool get trustJSInteropTypeAnnotations => |
| 4026 _compiler.trustJSInteropTypeAnnotations; | 4036 _compiler.trustJSInteropTypeAnnotations; |
| 4027 | 4037 |
| 4028 bool isNative(ClassElement element) => _backend.isNative(element); | 4038 bool isNative(ClassElement element) => _backend.isNative(element); |
| 4029 | 4039 |
| 4030 bool isJsInterop(FunctionElement element) => _backend.isJsInterop(element); | 4040 bool isJsInterop(FunctionElement element) => _backend.isJsInterop(element); |
| 4031 | 4041 |
| 4032 bool isJsInteropAnonymous(FunctionElement element) => | 4042 bool isJsInteropAnonymous(FunctionElement element) => |
| 4033 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); | 4043 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); |
| 4034 | 4044 |
| 4035 String getJsInteropTargetPath(FunctionElement element) { | 4045 String getJsInteropTargetPath(FunctionElement element) { |
| 4036 return '${_backend.namer.fixedBackendPath(element)}.' | 4046 return '${_backend.namer.fixedBackendPath(element)}.' |
| 4037 '${_backend.getFixedBackendName(element)}'; | 4047 '${_backend.getFixedBackendName(element)}'; |
| 4038 } | 4048 } |
| 4039 | 4049 |
| 4040 DartType get jsJavascriptObjectType => | 4050 DartType get jsJavascriptObjectType => |
| 4041 _backend.helpers.jsJavaScriptObjectClass.thisType; | 4051 _backend.helpers.jsJavaScriptObjectClass.thisType; |
| 4042 } | 4052 } |
| OLD | NEW |