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, 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 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 | 1931 |
1932 var leftType = getStaticType(left); | 1932 var leftType = getStaticType(left); |
1933 var rightType = getStaticType(right); | 1933 var rightType = getStaticType(right); |
1934 | 1934 |
1935 var code; | 1935 var code; |
1936 if (op.type.isEqualityOperator) { | 1936 if (op.type.isEqualityOperator) { |
1937 // If we statically know LHS or RHS is null we can generate a clean check. | 1937 // If we statically know LHS or RHS is null we can generate a clean check. |
1938 // We can also do this if both sides are the same primitive type. | 1938 // We can also do this if both sides are the same primitive type. |
1939 if (_canUsePrimitiveEquality(left, right)) { | 1939 if (_canUsePrimitiveEquality(left, right)) { |
1940 code = op.type == TokenType.EQ_EQ ? '# == #' : '# != #'; | 1940 code = op.type == TokenType.EQ_EQ ? '# == #' : '# != #'; |
| 1941 } else if (left is SuperExpression) { |
| 1942 return _emitSend(left, op.lexeme, [right]); |
1941 } else { | 1943 } else { |
1942 var bang = op.type == TokenType.BANG_EQ ? '!' : ''; | 1944 var bang = op.type == TokenType.BANG_EQ ? '!' : ''; |
1943 code = '${bang}dart.equals(#, #)'; | 1945 code = '${bang}dart.equals(#, #)'; |
1944 } | 1946 } |
1945 return js.call(code, [_visit(left), _visit(right)]); | 1947 return js.call(code, [_visit(left), _visit(right)]); |
1946 } | 1948 } |
1947 | 1949 |
1948 if (binaryOperationIsPrimitive(leftType, rightType) || | 1950 if (binaryOperationIsPrimitive(leftType, rightType) || |
1949 rules.isStringType(leftType) && op.type == TokenType.PLUS) { | 1951 rules.isStringType(leftType) && op.type == TokenType.PLUS) { |
1950 | 1952 |
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2800 | 2802 |
2801 /// A special kind of element created by the compiler, signifying a temporary | 2803 /// A special kind of element created by the compiler, signifying a temporary |
2802 /// variable. These objects use instance equality, and should be shared | 2804 /// variable. These objects use instance equality, and should be shared |
2803 /// everywhere in the tree where they are treated as the same variable. | 2805 /// everywhere in the tree where they are treated as the same variable. |
2804 class TemporaryVariableElement extends LocalVariableElementImpl { | 2806 class TemporaryVariableElement extends LocalVariableElementImpl { |
2805 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); | 2807 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); |
2806 | 2808 |
2807 int get hashCode => identityHashCode(this); | 2809 int get hashCode => identityHashCode(this); |
2808 bool operator ==(Object other) => identical(this, other); | 2810 bool operator ==(Object other) => identical(this, other); |
2809 } | 2811 } |
OLD | NEW |