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

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

Issue 1249043006: fix truncate call to use extension method (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: format Created 5 years, 5 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/math.js ('k') | test/codegen/expect/DeltaBlue.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 1996 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW
« no previous file with comments | « lib/runtime/dart/math.js ('k') | test/codegen/expect/DeltaBlue.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698