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

Unified Diff: runtime/vm/ast.cc

Issue 281823002: Fix an undetected Smi overflow on ARM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast.cc
===================================================================
--- runtime/vm/ast.cc (revision 36182)
+++ runtime/vm/ast.cc (working copy)
@@ -119,15 +119,20 @@
}
-// TODO(srdjan): Add code for logical negation.
AstNode* LiteralNode::ApplyUnaryOp(Token::Kind unary_op_kind) {
if (unary_op_kind == Token::kNEGATE) {
if (literal().IsSmi()) {
const Smi& smi = Smi::Cast(literal());
const Instance& literal =
- Instance::ZoneHandle(Integer::New(-smi.Value()));
+ Instance::ZoneHandle(Integer::New(-smi.Value(), Heap::kOld));
return new LiteralNode(this->token_pos(), literal);
}
+ if (literal().IsMint()) {
+ const Mint& mint = Mint::Cast(literal());
+ const Instance& literal =
+ Instance::ZoneHandle(Integer::New(-mint.value(), Heap::kOld));
+ return new LiteralNode(this->token_pos(), literal);
+ }
if (literal().IsDouble()) {
const Double& dbl = Double::Cast(literal());
// Preserve negative zero.
@@ -136,6 +141,24 @@
Double::ZoneHandle(Double::NewCanonical(new_value));
return new LiteralNode(this->token_pos(), double_instance);
}
+ } else if (unary_op_kind == Token::kBIT_NOT) {
+ if (literal().IsSmi()) {
+ const Smi& smi = Smi::Cast(literal());
+ const Instance& literal =
+ Instance::ZoneHandle(Integer::New(~smi.Value(), Heap::kOld));
+ return new LiteralNode(this->token_pos(), literal);
+ }
+ if (literal().IsMint()) {
+ const Mint& mint = Mint::Cast(literal());
+ const Instance& literal =
+ Instance::ZoneHandle(Integer::New(~mint.value(), Heap::kOld));
+ return new LiteralNode(this->token_pos(), literal);
+ }
+ } else if (unary_op_kind == Token::kNOT) {
+ if (literal().IsBool()) {
+ const Bool& boolean = Bool::Cast(literal());
+ return new LiteralNode(this->token_pos(), Bool::Get(!boolean.value()));
+ }
}
return NULL;
}
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698