| 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 1996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2007 | 2007 |
| 2008 if (binaryOperationIsPrimitive(leftType, rightType) || | 2008 if (binaryOperationIsPrimitive(leftType, rightType) || |
| 2009 rules.isStringType(leftType) && op.type == TokenType.PLUS) { | 2009 rules.isStringType(leftType) && op.type == TokenType.PLUS) { |
| 2010 | 2010 |
| 2011 // special cases where we inline the operation | 2011 // special cases where we inline the operation |
| 2012 // these values are assumed to be non-null (determined by the checker) | 2012 // these values are assumed to be non-null (determined by the checker) |
| 2013 // TODO(jmesserly): it would be nice to just inline the method from core, | 2013 // TODO(jmesserly): it would be nice to just inline the method from core, |
| 2014 // instead of special cases here. | 2014 // instead of special cases here. |
| 2015 if (op.type == TokenType.TILDE_SLASH) { | 2015 if (op.type == TokenType.TILDE_SLASH) { |
| 2016 // `a ~/ b` is equivalent to `(a / b).truncate()` | 2016 // `a ~/ b` is equivalent to `(a / b).truncate()` |
| 2017 code = '(# / #).truncate()'; | 2017 var div = AstBuilder.binaryExpression(left, '/', right) |
| 2018 ..staticType = node.staticType; |
| 2019 return _emitSend(div, 'truncate', []); |
| 2018 } else { | 2020 } else { |
| 2019 // TODO(vsm): When do Dart ops not map to JS? | 2021 // TODO(vsm): When do Dart ops not map to JS? |
| 2020 code = '# $op #'; | 2022 code = '# $op #'; |
| 2021 } | 2023 } |
| 2022 return js.call(code, [notNull(left), notNull(right)]); | 2024 return js.call(code, [notNull(left), notNull(right)]); |
| 2023 } | 2025 } |
| 2024 | 2026 |
| 2025 return _emitSend(left, op.lexeme, [right]); | 2027 return _emitSend(left, op.lexeme, [right]); |
| 2026 } | 2028 } |
| 2027 | 2029 |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2848 | 2850 |
| 2849 class _JsThisFinder extends JS.BaseVisitor { | 2851 class _JsThisFinder extends JS.BaseVisitor { |
| 2850 bool found = false; | 2852 bool found = false; |
| 2851 visitThis(JS.This node) { | 2853 visitThis(JS.This node) { |
| 2852 found = true; | 2854 found = true; |
| 2853 } | 2855 } |
| 2854 visitNode(JS.Node node) { | 2856 visitNode(JS.Node node) { |
| 2855 if (!found) super.visitNode(node); | 2857 if (!found) super.visitNode(node); |
| 2856 } | 2858 } |
| 2857 } | 2859 } |
| OLD | NEW |