Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart

Issue 980853002: dart2dart: Bugfix in copy propagator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/codegen.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 511 }
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.definition is tree.FunctionExpression && 521 stmt.value is tree.FunctionExpression &&
522 !context.declaredVariables.contains(stmt.variable)) { 522 !context.declaredVariables.contains(stmt.variable)) {
523 tree.FunctionExpression functionExp = stmt.definition; 523 tree.FunctionExpression functionExp = stmt.value;
524 FunctionExpression function = 524 FunctionExpression function =
525 makeSubFunction(functionExp.definition, context); 525 makeSubFunction(functionExp.definition, context);
526 FunctionDeclaration decl = new FunctionDeclaration(function); 526 FunctionDeclaration decl = new FunctionDeclaration(function);
527 context.addStatement(decl); 527 context.addStatement(decl);
528 context.declaredVariables.add(stmt.variable); 528 context.declaredVariables.add(stmt.variable);
529 529
530 visitStatement(stmt.next, context); 530 visitStatement(stmt.next, context);
531 return; 531 return;
532 } 532 }
533 533
534 bool isFirstOccurrence = (context.variableNames[stmt.variable] == null); 534 bool isFirstOccurrence = (context.variableNames[stmt.variable] == null);
535 bool isDeclaredHere = stmt.variable.host == context.currentElement; 535 bool isDeclaredHere = stmt.variable.host == context.currentElement;
536 String name = context.getVariableName(stmt.variable); 536 String name = context.getVariableName(stmt.variable);
537 Expression definition = visitExpression(stmt.definition, context); 537 Expression definition = visitExpression(stmt.value, context);
538 538
539 // Try to pull into initializer. 539 // Try to pull into initializer.
540 if (context.firstStatement == stmt && isFirstOccurrence && isDeclaredHere) { 540 if (context.firstStatement == stmt && isFirstOccurrence && isDeclaredHere) {
541 if (isNullLiteral(definition)) definition = null; 541 if (isNullLiteral(definition)) definition = null;
542 context.addDeclaration(stmt.variable, definition); 542 context.addDeclaration(stmt.variable, definition);
543 context.firstStatement = stmt.next; 543 context.firstStatement = stmt.next;
544 visitStatement(stmt.next, context); 544 visitStatement(stmt.next, context);
545 return; 545 return;
546 } 546 }
547 547
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 : super(name, ElementKind.VARIABLE, enclosingElement, variables, null); 1308 : super(name, ElementKind.VARIABLE, enclosingElement, variables, null);
1309 1309
1310 ExecutableElement get executableContext => enclosingElement; 1310 ExecutableElement get executableContext => enclosingElement;
1311 1311
1312 ExecutableElement get memberContext => executableContext.memberContext; 1312 ExecutableElement get memberContext => executableContext.memberContext;
1313 1313
1314 bool get isLocal => true; 1314 bool get isLocal => true;
1315 1315
1316 LibraryElement get implementationLibrary => enclosingElement.library; 1316 LibraryElement get implementationLibrary => enclosingElement.library;
1317 } 1317 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698