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

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

Issue 1163393002: remove ignoreTypes flag, to reimplement later, see #134 (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/src/checker/rules.dart ('k') | lib/src/options.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, 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 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 } 1872 }
1873 1873
1874 @override 1874 @override
1875 JS.Expression visitBinaryExpression(BinaryExpression node) { 1875 JS.Expression visitBinaryExpression(BinaryExpression node) {
1876 var op = node.operator; 1876 var op = node.operator;
1877 var left = node.leftOperand; 1877 var left = node.leftOperand;
1878 var right = node.rightOperand; 1878 var right = node.rightOperand;
1879 var leftType = getStaticType(left); 1879 var leftType = getStaticType(left);
1880 var rightType = getStaticType(right); 1880 var rightType = getStaticType(right);
1881 1881
1882 // TODO(jmesserly): this may not work correctly with options.ignoreTypes,
1883 // because that results in unreliable type annotations. See issue #134,
1884 // probably the checker/resolver is the right place to implement that, by
1885 // replacing staticTypes with `dynamic` as needed, so codegen "just works".
1886 var code; 1882 var code;
1887 if (op.type.isEqualityOperator) { 1883 if (op.type.isEqualityOperator) {
1888 // If we statically know LHS or RHS is null we can generate a clean check. 1884 // If we statically know LHS or RHS is null we can generate a clean check.
1889 // We can also do this if both sides are the same primitive type. 1885 // We can also do this if both sides are the same primitive type.
1890 if (_canUsePrimitiveEquality(left, right)) { 1886 if (_canUsePrimitiveEquality(left, right)) {
1891 code = op.type == TokenType.EQ_EQ ? '# == #' : '# != #'; 1887 code = op.type == TokenType.EQ_EQ ? '# == #' : '# != #';
1892 } else { 1888 } else {
1893 var bang = op.type == TokenType.BANG_EQ ? '!' : ''; 1889 var bang = op.type == TokenType.BANG_EQ ? '!' : '';
1894 code = '${bang}dart.equals(#, #)'; 1890 code = '${bang}dart.equals(#, #)';
1895 } 1891 }
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
2742 2738
2743 /// A special kind of element created by the compiler, signifying a temporary 2739 /// A special kind of element created by the compiler, signifying a temporary
2744 /// variable. These objects use instance equality, and should be shared 2740 /// variable. These objects use instance equality, and should be shared
2745 /// everywhere in the tree where they are treated as the same variable. 2741 /// everywhere in the tree where they are treated as the same variable.
2746 class TemporaryVariableElement extends LocalVariableElementImpl { 2742 class TemporaryVariableElement extends LocalVariableElementImpl {
2747 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); 2743 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name);
2748 2744
2749 int get hashCode => identityHashCode(this); 2745 int get hashCode => identityHashCode(this);
2750 bool operator ==(Object other) => identical(this, other); 2746 bool operator ==(Object other) => identical(this, other);
2751 } 2747 }
OLDNEW
« no previous file with comments | « lib/src/checker/rules.dart ('k') | lib/src/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698