| 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 ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 class SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
| 8 | 8 |
| 9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
| 10 final SourceInformationStrategy sourceInformationFactory; | 10 final SourceInformationStrategy sourceInformationFactory; |
| (...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 } | 1904 } |
| 1905 if (constant.isType) { | 1905 if (constant.isType) { |
| 1906 // If the type is a web component, we need to ensure the constructors are | 1906 // If the type is a web component, we need to ensure the constructors are |
| 1907 // available to 'upgrade' the native object. | 1907 // available to 'upgrade' the native object. |
| 1908 TypeConstantValue type = constant; | 1908 TypeConstantValue type = constant; |
| 1909 Element element = type.representedType.element; | 1909 Element element = type.representedType.element; |
| 1910 if (element != null && element.isClass) { | 1910 if (element != null && element.isClass) { |
| 1911 registry.registerTypeConstant(element); | 1911 registry.registerTypeConstant(element); |
| 1912 } | 1912 } |
| 1913 } | 1913 } |
| 1914 push(backend.emitter.constantReference(constant) | 1914 js.Expression expression = backend.emitter.constantReference(constant); |
| 1915 .withSourceInformation(sourceInformation)); | 1915 if (!constant.isDummy) { |
| 1916 // TODO(johnniwinther): Support source information on synthetic constants. |
| 1917 expression = expression.withSourceInformation(sourceInformation); |
| 1918 } |
| 1919 push(expression); |
| 1916 } | 1920 } |
| 1917 | 1921 |
| 1918 visitConstant(HConstant node) { | 1922 visitConstant(HConstant node) { |
| 1919 assert(isGenerateAtUseSite(node)); | 1923 assert(isGenerateAtUseSite(node)); |
| 1920 generateConstant(node.constant, node.sourceInformation); | 1924 generateConstant(node.constant, node.sourceInformation); |
| 1921 | 1925 |
| 1922 registry.registerCompileTimeConstant(node.constant); | 1926 registry.registerCompileTimeConstant(node.constant); |
| 1923 backend.constants.addCompileTimeConstantForEmission(node.constant); | 1927 backend.constants.addCompileTimeConstantForEmission(node.constant); |
| 1924 } | 1928 } |
| 1925 | 1929 |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2702 // sufficient for doing an argument or receiver check. | 2706 // sufficient for doing an argument or receiver check. |
| 2703 assert(compiler.trustTypeAnnotations || | 2707 assert(compiler.trustTypeAnnotations || |
| 2704 !node.checkedType.containsOnlyInt(classWorld) || | 2708 !node.checkedType.containsOnlyInt(classWorld) || |
| 2705 node.checkedInput.isIntegerOrNull(compiler)); | 2709 node.checkedInput.isIntegerOrNull(compiler)); |
| 2706 js.Expression test = generateReceiverOrArgumentTypeTest( | 2710 js.Expression test = generateReceiverOrArgumentTypeTest( |
| 2707 node.checkedInput, node.checkedType); | 2711 node.checkedInput, node.checkedType); |
| 2708 js.Block oldContainer = currentContainer; | 2712 js.Block oldContainer = currentContainer; |
| 2709 js.Statement body = new js.Block.empty(); | 2713 js.Statement body = new js.Block.empty(); |
| 2710 currentContainer = body; | 2714 currentContainer = body; |
| 2711 if (node.isArgumentTypeCheck) { | 2715 if (node.isArgumentTypeCheck) { |
| 2712 generateThrowWithHelper('iae', node.checkedInput); | 2716 generateThrowWithHelper('iae', |
| 2717 node.checkedInput, |
| 2718 sourceInformation: node.sourceInformation); |
| 2713 } else if (node.isReceiverTypeCheck) { | 2719 } else if (node.isReceiverTypeCheck) { |
| 2714 use(node.checkedInput); | 2720 use(node.checkedInput); |
| 2715 js.Name methodName = | 2721 js.Name methodName = |
| 2716 backend.namer.invocationName(node.receiverTypeCheckSelector); | 2722 backend.namer.invocationName(node.receiverTypeCheckSelector); |
| 2717 js.Expression call = js.propertyCall(pop(), methodName, []); | 2723 js.Expression call = js.propertyCall(pop(), methodName, []); |
| 2718 pushStatement(new js.Return(call)); | 2724 pushStatement(new js.Return(call)); |
| 2719 } | 2725 } |
| 2720 currentContainer = oldContainer; | 2726 currentContainer = oldContainer; |
| 2721 body = unwrapStatement(body); | 2727 body = unwrapStatement(body); |
| 2722 pushStatement(new js.If.noElse(test, body) | 2728 pushStatement(new js.If.noElse(test, body) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2852 | 2858 |
| 2853 js.PropertyAccess accessHelper(String name) { | 2859 js.PropertyAccess accessHelper(String name) { |
| 2854 Element helper = backend.findHelper(name); | 2860 Element helper = backend.findHelper(name); |
| 2855 if (helper == null) { | 2861 if (helper == null) { |
| 2856 // For mocked-up tests. | 2862 // For mocked-up tests. |
| 2857 return js.js('(void 0).$name'); | 2863 return js.js('(void 0).$name'); |
| 2858 } | 2864 } |
| 2859 registry.registerStaticUse(helper); | 2865 registry.registerStaticUse(helper); |
| 2860 return backend.emitter.staticFunctionAccess(helper); | 2866 return backend.emitter.staticFunctionAccess(helper); |
| 2861 } | 2867 } |
| 2868 |
| 2869 @override |
| 2870 void visitRef(HRef node) { |
| 2871 visit(node.value); |
| 2872 } |
| 2862 } | 2873 } |
| OLD | NEW |