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

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

Issue 1178523004: fixes #215, removes special case for length (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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 | « lib/runtime/dart/isolate.js ('k') | test/codegen/expect/BenchmarkBase.js » ('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, SplayTreeSet; 7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
(...skipping 2652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 if (name == '[]') { 2663 if (name == '[]') {
2664 name = 'get'; 2664 name = 'get';
2665 } else if (name == '[]=') { 2665 } else if (name == '[]=') {
2666 name = 'set'; 2666 name = 'set';
2667 } else if (name == '-' && unary) { 2667 } else if (name == '-' && unary) {
2668 name = 'unary-'; 2668 name = 'unary-';
2669 } 2669 }
2670 2670
2671 // Dart "extension" methods. Used for JS Array, Boolean, Number, String. 2671 // Dart "extension" methods. Used for JS Array, Boolean, Number, String.
2672 if (allowExtensions && _extensionTypes.contains(type.element)) { 2672 if (allowExtensions && _extensionTypes.contains(type.element)) {
2673 // Special case `length`. We can call it directly. 2673 return js.call('dartx.#', _propertyName(name));
vsm 2015/06/10 17:00:46 Will this really fix the broken text example? The
Jennifer Messerly 2015/06/10 17:13:16 yup. It works because of this logic: https://githu
2674 if (name != 'length') return js.call('dartx.#', _propertyName(name));
2675 } 2674 }
2676 2675
2677 return _propertyName(name); 2676 return _propertyName(name);
2678 } 2677 }
2679 2678
2680 bool _externalOrNative(node) => 2679 bool _externalOrNative(node) =>
2681 node.externalKeyword != null || _functionBody(node) is NativeFunctionBody; 2680 node.externalKeyword != null || _functionBody(node) is NativeFunctionBody;
2682 2681
2683 FunctionBody _functionBody(node) => 2682 FunctionBody _functionBody(node) =>
2684 node is FunctionDeclaration ? node.functionExpression.body : node.body; 2683 node is FunctionDeclaration ? node.functionExpression.body : node.body;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 2772
2774 /// A special kind of element created by the compiler, signifying a temporary 2773 /// A special kind of element created by the compiler, signifying a temporary
2775 /// variable. These objects use instance equality, and should be shared 2774 /// variable. These objects use instance equality, and should be shared
2776 /// everywhere in the tree where they are treated as the same variable. 2775 /// everywhere in the tree where they are treated as the same variable.
2777 class TemporaryVariableElement extends LocalVariableElementImpl { 2776 class TemporaryVariableElement extends LocalVariableElementImpl {
2778 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); 2777 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name);
2779 2778
2780 int get hashCode => identityHashCode(this); 2779 int get hashCode => identityHashCode(this);
2781 bool operator ==(Object other) => identical(this, other); 2780 bool operator ==(Object other) => identical(this, other);
2782 } 2781 }
OLDNEW
« no previous file with comments | « lib/runtime/dart/isolate.js ('k') | test/codegen/expect/BenchmarkBase.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698