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 'package:js_runtime/shared/embedded_names.dart' | 7 import 'package:js_runtime/shared/embedded_names.dart' |
8 show JsBuiltin, JsGetName; | 8 show JsBuiltin, JsGetName; |
9 | 9 |
10 import '../closure.dart' as closure; | 10 import '../closure.dart' as closure; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 String toString() => 'ExplicitReceiverParameter($executableContext)'; | 49 String toString() => 'ExplicitReceiverParameter($executableContext)'; |
50 } | 50 } |
51 | 51 |
52 /// This task provides the interface to build IR nodes from [ast.Node]s, which | 52 /// This task provides the interface to build IR nodes from [ast.Node]s, which |
53 /// is used from the [CpsFunctionCompiler] to generate code. | 53 /// is used from the [CpsFunctionCompiler] to generate code. |
54 /// | 54 /// |
55 /// This class is mainly there to correctly measure how long building the IR | 55 /// This class is mainly there to correctly measure how long building the IR |
56 /// takes. | 56 /// takes. |
57 class IrBuilderTask extends CompilerTask { | 57 class IrBuilderTask extends CompilerTask { |
58 final SourceInformationStrategy sourceInformationStrategy; | 58 final SourceInformationStrategy sourceInformationStrategy; |
| 59 final Compiler compiler; |
59 | 60 |
60 String bailoutMessage = null; | 61 String bailoutMessage = null; |
61 | 62 |
62 /// If not null, this function will be called with for each | 63 /// If not null, this function will be called with for each |
63 /// [ir.FunctionDefinition] node that has been built. | 64 /// [ir.FunctionDefinition] node that has been built. |
64 IrBuilderCallback builderCallback; | 65 IrBuilderCallback builderCallback; |
65 | 66 |
66 IrBuilderTask(Compiler compiler, this.sourceInformationStrategy, | 67 IrBuilderTask(Compiler compiler, this.sourceInformationStrategy, |
67 [this.builderCallback]) | 68 [this.builderCallback]) |
68 : super(compiler); | 69 : compiler = compiler, |
| 70 super(compiler.measurer); |
69 | 71 |
70 String get name => 'CPS builder'; | 72 String get name => 'CPS builder'; |
71 | 73 |
72 ir.FunctionDefinition buildNode( | 74 ir.FunctionDefinition buildNode( |
73 AstElement element, TypeMaskSystem typeMaskSystem) { | 75 AstElement element, TypeMaskSystem typeMaskSystem) { |
74 return measure(() { | 76 return measure(() { |
75 bailoutMessage = null; | 77 bailoutMessage = null; |
76 | 78 |
77 ResolvedAst resolvedAst = element.resolvedAst; | 79 ResolvedAst resolvedAst = element.resolvedAst; |
78 element = element.implementation; | 80 element = element.implementation; |
79 return reporter.withCurrentElement(element, () { | 81 return compiler.reporter.withCurrentElement(element, () { |
80 SourceInformationBuilder sourceInformationBuilder = | 82 SourceInformationBuilder sourceInformationBuilder = |
81 sourceInformationStrategy.createBuilderForContext(resolvedAst); | 83 sourceInformationStrategy.createBuilderForContext(resolvedAst); |
82 | 84 |
83 IrBuilderVisitor builder = new IrBuilderVisitor( | 85 IrBuilderVisitor builder = new IrBuilderVisitor( |
84 resolvedAst, compiler, sourceInformationBuilder, typeMaskSystem); | 86 resolvedAst, compiler, sourceInformationBuilder, typeMaskSystem); |
85 ir.FunctionDefinition irNode = builder.buildExecutable(element); | 87 ir.FunctionDefinition irNode = builder.buildExecutable(element); |
86 if (irNode == null) { | 88 if (irNode == null) { |
87 bailoutMessage = builder.bailoutMessage; | 89 bailoutMessage = builder.bailoutMessage; |
88 } else if (builderCallback != null) { | 90 } else if (builderCallback != null) { |
89 builderCallback(element, irNode); | 91 builderCallback(element, irNode); |
(...skipping 3930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4020 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); | 4022 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); |
4021 | 4023 |
4022 String getJsInteropTargetPath(FunctionElement element) { | 4024 String getJsInteropTargetPath(FunctionElement element) { |
4023 return '${_backend.namer.fixedBackendPath(element)}.' | 4025 return '${_backend.namer.fixedBackendPath(element)}.' |
4024 '${_backend.nativeData.getFixedBackendName(element)}'; | 4026 '${_backend.nativeData.getFixedBackendName(element)}'; |
4025 } | 4027 } |
4026 | 4028 |
4027 DartType get jsJavascriptObjectType => | 4029 DartType get jsJavascriptObjectType => |
4028 _backend.helpers.jsJavaScriptObjectClass.thisType; | 4030 _backend.helpers.jsJavaScriptObjectClass.thisType; |
4029 } | 4031 } |
OLD | NEW |