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

Side by Side Diff: lib/src/codegen/js_codegen.dart

Issue 1056183003: use VariableElement instead of VariableElementImpl in _isStateless (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | test/codegen/cascade.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) 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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | test/codegen/cascade.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698