| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 /// Returns `null` if the constructor does not have a body. | 284 /// Returns `null` if the constructor does not have a body. |
| 285 ConstructorBodyElement getConstructorBody(FunctionElement constructor) { | 285 ConstructorBodyElement getConstructorBody(FunctionElement constructor) { |
| 286 // TODO(asgerf): This is largely inherited from the SSA builder. | 286 // TODO(asgerf): This is largely inherited from the SSA builder. |
| 287 // The ConstructorBodyElement has an invalid function signature, but we | 287 // The ConstructorBodyElement has an invalid function signature, but we |
| 288 // cannot add a BoxLocal as parameter, because BoxLocal is not an element. | 288 // cannot add a BoxLocal as parameter, because BoxLocal is not an element. |
| 289 // Instead of forging ParameterElements to forge a FunctionSignature, we | 289 // Instead of forging ParameterElements to forge a FunctionSignature, we |
| 290 // need a way to create backend methods without creating more fake elements. | 290 // need a way to create backend methods without creating more fake elements. |
| 291 assert(constructor.isGenerativeConstructor); | 291 assert(constructor.isGenerativeConstructor); |
| 292 assert(constructor.isImplementation); | 292 assert(constructor.isImplementation); |
| 293 if (constructor.isSynthesized) return null; | 293 if (constructor.isSynthesized) return null; |
| 294 ResolvedAst resolvedAst = backend.frontend.getResolvedAst(constructor); | 294 ResolvedAst resolvedAst = constructor.resolvedAst; |
| 295 ast.FunctionExpression node = constructor.node; | 295 ast.FunctionExpression node = constructor.node; |
| 296 // If we know the body doesn't have any code, we don't generate it. | 296 // If we know the body doesn't have any code, we don't generate it. |
| 297 if (!node.hasBody) return null; | 297 if (!node.hasBody) return null; |
| 298 if (node.hasEmptyBody) return null; | 298 if (node.hasEmptyBody) return null; |
| 299 ClassElement classElement = constructor.enclosingClass; | 299 ClassElement classElement = constructor.enclosingClass; |
| 300 ConstructorBodyElement bodyElement; | 300 ConstructorBodyElement bodyElement; |
| 301 classElement.forEachBackendMember((Element backendMember) { | 301 classElement.forEachBackendMember((Element backendMember) { |
| 302 if (backendMember.isGenerativeConstructorBody) { | 302 if (backendMember.isGenerativeConstructorBody) { |
| 303 ConstructorBodyElement body = backendMember; | 303 ConstructorBodyElement body = backendMember; |
| 304 if (body.constructor == constructor) { | 304 if (body.constructor == constructor) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 return irBuilder.makeFunctionDefinition( | 496 return irBuilder.makeFunctionDefinition( |
| 497 sourceInformationBuilder.buildVariableDeclaration()); | 497 sourceInformationBuilder.buildVariableDeclaration()); |
| 498 }); | 498 }); |
| 499 } | 499 } |
| 500 | 500 |
| 501 /// Make a visitor suitable for translating ASTs taken from [context]. | 501 /// Make a visitor suitable for translating ASTs taken from [context]. |
| 502 /// | 502 /// |
| 503 /// Every visitor can only be applied to nodes in one context, because | 503 /// Every visitor can only be applied to nodes in one context, because |
| 504 /// the [elements] field is specific to that context. | 504 /// the [elements] field is specific to that context. |
| 505 IrBuilderVisitor makeVisitorForContext(AstElement context) { | 505 IrBuilderVisitor makeVisitorForContext(AstElement context) { |
| 506 ResolvedAst resolvedAst = backend.frontend.getResolvedAst(context); | 506 ResolvedAst resolvedAst = context.resolvedAst; |
| 507 return new IrBuilderVisitor(resolvedAst, compiler, | 507 return new IrBuilderVisitor(resolvedAst, compiler, |
| 508 sourceInformationBuilder.forContext(resolvedAst), typeMaskSystem); | 508 sourceInformationBuilder.forContext(resolvedAst), typeMaskSystem); |
| 509 } | 509 } |
| 510 | 510 |
| 511 /// Builds the IR for an [expression] taken from a different [context]. | 511 /// Builds the IR for an [expression] taken from a different [context]. |
| 512 /// | 512 /// |
| 513 /// Such expressions need to be compiled with a different [sourceFile] and | 513 /// Such expressions need to be compiled with a different [sourceFile] and |
| 514 /// [elements] mapping. | 514 /// [elements] mapping. |
| 515 ir.Primitive inlineExpression(AstElement context, ast.Expression expression) { | 515 ir.Primitive inlineExpression(AstElement context, ast.Expression expression) { |
| 516 IrBuilderVisitor visitor = makeVisitorForContext(context); | 516 IrBuilderVisitor visitor = makeVisitorForContext(context); |
| (...skipping 3503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4020 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); | 4020 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); |
| 4021 | 4021 |
| 4022 String getJsInteropTargetPath(FunctionElement element) { | 4022 String getJsInteropTargetPath(FunctionElement element) { |
| 4023 return '${_backend.namer.fixedBackendPath(element)}.' | 4023 return '${_backend.namer.fixedBackendPath(element)}.' |
| 4024 '${_backend.nativeData.getFixedBackendName(element)}'; | 4024 '${_backend.nativeData.getFixedBackendName(element)}'; |
| 4025 } | 4025 } |
| 4026 | 4026 |
| 4027 DartType get jsJavascriptObjectType => | 4027 DartType get jsJavascriptObjectType => |
| 4028 _backend.helpers.jsJavaScriptObjectClass.thisType; | 4028 _backend.helpers.jsJavaScriptObjectClass.thisType; |
| 4029 } | 4029 } |
| OLD | NEW |