| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 backend_ast_emitter; | 5 library backend_ast_emitter; |
| 6 | 6 |
| 7 import '../tree_ir/tree_ir_nodes.dart' as tree; | 7 import '../tree_ir/tree_ir_nodes.dart' as tree; |
| 8 import 'backend_ast_nodes.dart'; | 8 import 'backend_ast_nodes.dart'; |
| 9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
| 10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 512 |
| 513 bool isNullLiteral(Expression exp) => exp is Literal && exp.value.isNull; | 513 bool isNullLiteral(Expression exp) => exp is Literal && exp.value.isNull; |
| 514 | 514 |
| 515 @override | 515 @override |
| 516 void visitAssign(tree.Assign stmt, | 516 void visitAssign(tree.Assign stmt, |
| 517 BuilderContext<Statement> context) { | 517 BuilderContext<Statement> context) { |
| 518 // Try to emit a local function declaration. This is useful for functions | 518 // Try to emit a local function declaration. This is useful for functions |
| 519 // that may occur in expression context, but could not be inlined anywhere. | 519 // that may occur in expression context, but could not be inlined anywhere. |
| 520 if (stmt.variable.element is FunctionElement && | 520 if (stmt.variable.element is FunctionElement && |
| 521 stmt.value is tree.FunctionExpression && | 521 stmt.value is tree.FunctionExpression && |
| 522 !context.declaredVariables.contains(stmt.variable)) { | 522 !context.declaredVariables.contains(stmt.variable) && |
| 523 stmt.variable.writeCount == 1) { |
| 523 tree.FunctionExpression functionExp = stmt.value; | 524 tree.FunctionExpression functionExp = stmt.value; |
| 524 FunctionExpression function = | 525 FunctionExpression function = |
| 525 makeSubFunction(functionExp.definition, context); | 526 makeSubFunction(functionExp.definition, context); |
| 526 FunctionDeclaration decl = new FunctionDeclaration(function); | 527 FunctionDeclaration decl = new FunctionDeclaration(function); |
| 527 context.addStatement(decl); | 528 context.addStatement(decl); |
| 528 context.declaredVariables.add(stmt.variable); | 529 context.declaredVariables.add(stmt.variable); |
| 529 | 530 |
| 530 visitStatement(stmt.next, context); | 531 visitStatement(stmt.next, context); |
| 531 return; | 532 return; |
| 532 } | 533 } |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 : super(name, ElementKind.VARIABLE, enclosingElement, variables, null); | 1315 : super(name, ElementKind.VARIABLE, enclosingElement, variables, null); |
| 1315 | 1316 |
| 1316 ExecutableElement get executableContext => enclosingElement; | 1317 ExecutableElement get executableContext => enclosingElement; |
| 1317 | 1318 |
| 1318 ExecutableElement get memberContext => executableContext.memberContext; | 1319 ExecutableElement get memberContext => executableContext.memberContext; |
| 1319 | 1320 |
| 1320 bool get isLocal => true; | 1321 bool get isLocal => true; |
| 1321 | 1322 |
| 1322 LibraryElement get implementationLibrary => enclosingElement.library; | 1323 LibraryElement get implementationLibrary => enclosingElement.library; |
| 1323 } | 1324 } |
| OLD | NEW |