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 closurelib; | 7 import '../closure.dart' as closurelib; |
8 import '../closure.dart' hide ClosureScope; | 8 import '../closure.dart' hide ClosureScope; |
9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 11 matching lines...) Expand all Loading... |
22 import 'cps_ir_builder.dart'; | 22 import 'cps_ir_builder.dart'; |
23 | 23 |
24 typedef void IrBuilderCallback(Element element, ir.FunctionDefinition irNode); | 24 typedef void IrBuilderCallback(Element element, ir.FunctionDefinition irNode); |
25 | 25 |
26 /// This task provides the interface to build IR nodes from [ast.Node]s, which | 26 /// This task provides the interface to build IR nodes from [ast.Node]s, which |
27 /// is used from the [CpsFunctionCompiler] to generate code. | 27 /// is used from the [CpsFunctionCompiler] to generate code. |
28 /// | 28 /// |
29 /// This class is mainly there to correctly measure how long building the IR | 29 /// This class is mainly there to correctly measure how long building the IR |
30 /// takes. | 30 /// takes. |
31 class IrBuilderTask extends CompilerTask { | 31 class IrBuilderTask extends CompilerTask { |
32 final SourceInformationFactory sourceInformationFactory; | 32 final SourceInformationStrategy sourceInformationStrategy; |
33 | 33 |
34 String bailoutMessage = null; | 34 String bailoutMessage = null; |
35 | 35 |
36 /// If not null, this function will be called with for each | 36 /// If not null, this function will be called with for each |
37 /// [ir.FunctionDefinition] node that has been built. | 37 /// [ir.FunctionDefinition] node that has been built. |
38 IrBuilderCallback builderCallback; | 38 IrBuilderCallback builderCallback; |
39 | 39 |
40 IrBuilderTask(Compiler compiler, this.sourceInformationFactory, | 40 IrBuilderTask(Compiler compiler, this.sourceInformationStrategy, |
41 [this.builderCallback]) | 41 [this.builderCallback]) |
42 : super(compiler); | 42 : super(compiler); |
43 | 43 |
44 String get name => 'IR builder'; | 44 String get name => 'IR builder'; |
45 | 45 |
46 ir.FunctionDefinition buildNode(AstElement element) { | 46 ir.FunctionDefinition buildNode(AstElement element) { |
47 return measure(() { | 47 return measure(() { |
48 bailoutMessage = null; | 48 bailoutMessage = null; |
49 | 49 |
50 TreeElements elementsMapping = element.resolvedAst.elements; | 50 TreeElements elementsMapping = element.resolvedAst.elements; |
51 element = element.implementation; | 51 element = element.implementation; |
52 return compiler.withCurrentElement(element, () { | 52 return compiler.withCurrentElement(element, () { |
53 SourceInformationBuilder sourceInformationBuilder = | 53 SourceInformationBuilder sourceInformationBuilder = |
54 sourceInformationFactory.forContext(element); | 54 sourceInformationStrategy.createBuilderForContext(element); |
55 | 55 |
56 IrBuilderVisitor builder = | 56 IrBuilderVisitor builder = |
57 new JsIrBuilderVisitor( | 57 new JsIrBuilderVisitor( |
58 elementsMapping, compiler, sourceInformationBuilder); | 58 elementsMapping, compiler, sourceInformationBuilder); |
59 ir.FunctionDefinition irNode = builder.buildExecutable(element); | 59 ir.FunctionDefinition irNode = builder.buildExecutable(element); |
60 if (irNode == null) { | 60 if (irNode == null) { |
61 bailoutMessage = builder.bailoutMessage; | 61 bailoutMessage = builder.bailoutMessage; |
62 } else if (builderCallback != null) { | 62 } else if (builderCallback != null) { |
63 builderCallback(element, irNode); | 63 builderCallback(element, irNode); |
64 } | 64 } |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 MethodElement function, | 997 MethodElement function, |
998 ast.NodeList arguments, | 998 ast.NodeList arguments, |
999 CallStructure callStructure, | 999 CallStructure callStructure, |
1000 _) { | 1000 _) { |
1001 // TODO(karlklose): support foreign functions. | 1001 // TODO(karlklose): support foreign functions. |
1002 if (compiler.backend.isForeign(function)) { | 1002 if (compiler.backend.isForeign(function)) { |
1003 return giveup(node, 'handleStaticFunctionInvoke: foreign: $function'); | 1003 return giveup(node, 'handleStaticFunctionInvoke: foreign: $function'); |
1004 } | 1004 } |
1005 return irBuilder.buildStaticFunctionInvocation(function, callStructure, | 1005 return irBuilder.buildStaticFunctionInvocation(function, callStructure, |
1006 translateStaticArguments(arguments, function, callStructure), | 1006 translateStaticArguments(arguments, function, callStructure), |
1007 sourceInformation: sourceInformationBuilder.buildCall(node)); | 1007 sourceInformation: sourceInformationBuilder.buildCall( |
| 1008 node, node.selector)); |
1008 } | 1009 } |
1009 | 1010 |
1010 @override | 1011 @override |
1011 ir.Primitive handleStaticFunctionIncompatibleInvoke( | 1012 ir.Primitive handleStaticFunctionIncompatibleInvoke( |
1012 ast.Send node, | 1013 ast.Send node, |
1013 MethodElement function, | 1014 MethodElement function, |
1014 ast.NodeList arguments, | 1015 ast.NodeList arguments, |
1015 CallStructure callStructure, _) { | 1016 CallStructure callStructure, _) { |
1016 return buildStaticNoSuchMethod( | 1017 return buildStaticNoSuchMethod( |
1017 elements.getSelector(node), | 1018 elements.getSelector(node), |
(...skipping 1842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 } | 2861 } |
2861 | 2862 |
2862 processSetStatic(ir.SetStatic node) { | 2863 processSetStatic(ir.SetStatic node) { |
2863 node.body = replacementFor(node.body); | 2864 node.body = replacementFor(node.body); |
2864 } | 2865 } |
2865 | 2866 |
2866 processContinuation(ir.Continuation node) { | 2867 processContinuation(ir.Continuation node) { |
2867 node.body = replacementFor(node.body); | 2868 node.body = replacementFor(node.body); |
2868 } | 2869 } |
2869 } | 2870 } |
OLD | NEW |