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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 ir.FunctionDefinition buildNode( | 72 ir.FunctionDefinition buildNode( |
73 AstElement element, TypeMaskSystem typeMaskSystem) { | 73 AstElement element, TypeMaskSystem typeMaskSystem) { |
74 return measure(() { | 74 return measure(() { |
75 bailoutMessage = null; | 75 bailoutMessage = null; |
76 | 76 |
77 ResolvedAst resolvedAst = element.resolvedAst; | 77 ResolvedAst resolvedAst = element.resolvedAst; |
78 element = element.implementation; | 78 element = element.implementation; |
79 return reporter.withCurrentElement(element, () { | 79 return reporter.withCurrentElement(element, () { |
80 SourceInformationBuilder sourceInformationBuilder = | 80 SourceInformationBuilder sourceInformationBuilder = |
81 sourceInformationStrategy.createBuilderForContext(element); | 81 sourceInformationStrategy.createBuilderForContext(resolvedAst); |
82 | 82 |
83 IrBuilderVisitor builder = new IrBuilderVisitor( | 83 IrBuilderVisitor builder = new IrBuilderVisitor( |
84 resolvedAst, compiler, sourceInformationBuilder, typeMaskSystem); | 84 resolvedAst, compiler, sourceInformationBuilder, typeMaskSystem); |
85 ir.FunctionDefinition irNode = builder.buildExecutable(element); | 85 ir.FunctionDefinition irNode = builder.buildExecutable(element); |
86 if (irNode == null) { | 86 if (irNode == null) { |
87 bailoutMessage = builder.bailoutMessage; | 87 bailoutMessage = builder.bailoutMessage; |
88 } else if (builderCallback != null) { | 88 } else if (builderCallback != null) { |
89 builderCallback(element, irNode); | 89 builderCallback(element, irNode); |
90 } | 90 } |
91 return irNode; | 91 return irNode; |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 return irBuilder.makeFunctionDefinition( | 495 return irBuilder.makeFunctionDefinition( |
496 sourceInformationBuilder.buildVariableDeclaration()); | 496 sourceInformationBuilder.buildVariableDeclaration()); |
497 }); | 497 }); |
498 } | 498 } |
499 | 499 |
500 /// Make a visitor suitable for translating ASTs taken from [context]. | 500 /// Make a visitor suitable for translating ASTs taken from [context]. |
501 /// | 501 /// |
502 /// Every visitor can only be applied to nodes in one context, because | 502 /// Every visitor can only be applied to nodes in one context, because |
503 /// the [elements] field is specific to that context. | 503 /// the [elements] field is specific to that context. |
504 IrBuilderVisitor makeVisitorForContext(AstElement context) { | 504 IrBuilderVisitor makeVisitorForContext(AstElement context) { |
505 return new IrBuilderVisitor(context.resolvedAst, compiler, | 505 ResolvedAst resolvedAst = backend.frontend.getResolvedAst(context); |
506 sourceInformationBuilder.forContext(context), typeMaskSystem); | 506 return new IrBuilderVisitor(resolvedAst, compiler, |
| 507 sourceInformationBuilder.forContext(resolvedAst), typeMaskSystem); |
507 } | 508 } |
508 | 509 |
509 /// Builds the IR for an [expression] taken from a different [context]. | 510 /// Builds the IR for an [expression] taken from a different [context]. |
510 /// | 511 /// |
511 /// Such expressions need to be compiled with a different [sourceFile] and | 512 /// Such expressions need to be compiled with a different [sourceFile] and |
512 /// [elements] mapping. | 513 /// [elements] mapping. |
513 ir.Primitive inlineExpression(AstElement context, ast.Expression expression) { | 514 ir.Primitive inlineExpression(AstElement context, ast.Expression expression) { |
514 IrBuilderVisitor visitor = makeVisitorForContext(context); | 515 IrBuilderVisitor visitor = makeVisitorForContext(context); |
515 return visitor.withBuilder(irBuilder, () => visitor.visit(expression)); | 516 return visitor.withBuilder(irBuilder, () => visitor.visit(expression)); |
516 } | 517 } |
(...skipping 3501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4018 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); | 4019 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); |
4019 | 4020 |
4020 String getJsInteropTargetPath(FunctionElement element) { | 4021 String getJsInteropTargetPath(FunctionElement element) { |
4021 return '${_backend.namer.fixedBackendPath(element)}.' | 4022 return '${_backend.namer.fixedBackendPath(element)}.' |
4022 '${_backend.nativeData.getFixedBackendName(element)}'; | 4023 '${_backend.nativeData.getFixedBackendName(element)}'; |
4023 } | 4024 } |
4024 | 4025 |
4025 DartType get jsJavascriptObjectType => | 4026 DartType get jsJavascriptObjectType => |
4026 _backend.helpers.jsJavaScriptObjectClass.thisType; | 4027 _backend.helpers.jsJavaScriptObjectClass.thisType; |
4027 } | 4028 } |
OLD | NEW |