Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dev_compiler.src.codegen.js_codegen; | 5 library dev_compiler.src.codegen.js_codegen; |
| 6 | 6 |
| 7 import 'dart:collection' show HashSet, HashMap; | 7 import 'dart:collection' show HashSet, HashMap; |
| 8 import 'dart:io' show Directory, File; | 8 import 'dart:io' show Directory, File; |
| 9 | 9 |
| 10 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 10 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| (...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1690 | 1690 |
| 1691 /// True is the expression can be evaluated multiple times without causing | 1691 /// True is the expression can be evaluated multiple times without causing |
| 1692 /// code execution. This is true for final fields. This can be true for local | 1692 /// code execution. This is true for final fields. This can be true for local |
| 1693 /// variables, if: | 1693 /// variables, if: |
| 1694 /// * they are not assigned within the [context]. | 1694 /// * they are not assigned within the [context]. |
| 1695 /// * they are not assigned in a function closure anywhere. | 1695 /// * they are not assigned in a function closure anywhere. |
| 1696 bool _isStateless(Expression node, [AstNode context]) { | 1696 bool _isStateless(Expression node, [AstNode context]) { |
| 1697 if (node is SimpleIdentifier) { | 1697 if (node is SimpleIdentifier) { |
| 1698 var e = node.staticElement; | 1698 var e = node.staticElement; |
| 1699 if (e is PropertyAccessorElement) e = e.variable; | 1699 if (e is PropertyAccessorElement) e = e.variable; |
| 1700 if (e is VariableElementImpl && !e.isSynthetic) { | 1700 if (e is VariableElement && !e.isSynthetic) { |
|
Brian Wilkerson
2015/04/04 15:58:24
This is a good first step, but doesn't fix the pro
Jennifer Messerly
2015/04/06 15:19:22
Sounds good, but how can I get a ParameterMember h
Brian Wilkerson
2015/04/06 15:23:05
I don't think you can. My comment was based on a m
Jennifer Messerly
2015/04/06 15:46:31
Ah that's good. I think I still like your variatio
| |
| 1701 if (e.isFinal) return true; | 1701 if (e.isFinal) return true; |
| 1702 if (e is LocalVariableElementImpl || e is ParameterElementImpl) { | 1702 if (e is LocalVariableElementImpl || e is ParameterElementImpl) { |
| 1703 // make sure the local isn't mutated in the context. | 1703 // make sure the local isn't mutated in the context. |
| 1704 return !_isPotentiallyMutated(e, context); | 1704 return !_isPotentiallyMutated(e, context); |
| 1705 } | 1705 } |
| 1706 } | 1706 } |
| 1707 } | 1707 } |
| 1708 return false; | 1708 return false; |
| 1709 } | 1709 } |
| 1710 | 1710 |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2361 | 2361 |
| 2362 // TODO(jmesserly): in many cases marking the end will be unncessary. | 2362 // TODO(jmesserly): in many cases marking the end will be unncessary. |
| 2363 printer.mark(_location(node.end)); | 2363 printer.mark(_location(node.end)); |
| 2364 } | 2364 } |
| 2365 | 2365 |
| 2366 String _getIdentifier(AstNode node) { | 2366 String _getIdentifier(AstNode node) { |
| 2367 if (node is SimpleIdentifier) return node.name; | 2367 if (node is SimpleIdentifier) return node.name; |
| 2368 return null; | 2368 return null; |
| 2369 } | 2369 } |
| 2370 } | 2370 } |
| OLD | NEW |