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

Unified Diff: src/typing-asm.cc

Issue 1432423003: Fix ~ operator in asm typer, add more operator tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix gcc Created 5 years, 1 month 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 | « no previous file | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/typing-asm.cc
diff --git a/src/typing-asm.cc b/src/typing-asm.cc
index b267113400c8a6dc7995f0ad0305b35124298d7d..281491d638ad9696352e7632c8cdaa9d1bff922f 100644
--- a/src/typing-asm.cc
+++ b/src/typing-asm.cc
@@ -841,7 +841,7 @@ void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) {
}
case Token::OR:
case Token::AND:
- FAIL(expr, "logical operator encountered");
+ FAIL(expr, "illegal logical operator");
case Token::BIT_OR: {
// BIT_OR allows Any since it is used as a type coercion.
VisitIntegerBitwiseOperator(expr, Type::Any(), cache_.kIntegral32,
@@ -849,6 +849,19 @@ void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) {
return;
}
case Token::BIT_XOR: {
+ // Handle booleans specially to handle de-sugared !
+ Literal* left = expr->left()->AsLiteral();
+ if (left && left->value()->IsBoolean()) {
+ if (left->ToBooleanIsTrue()) {
+ left->set_bounds(Bounds(cache_.kSingletonOne));
+ RECURSE(VisitWithExpectation(expr->right(), cache_.kIntegral32,
+ "not operator expects an integer"));
+ IntersectResult(expr, cache_.kInt32);
+ return;
+ } else {
+ FAIL(left, "unexpected false");
+ }
+ }
// BIT_XOR allows Number since it is used as a type coercion (via ~~).
VisitIntegerBitwiseOperator(expr, Type::Number(), cache_.kIntegral32,
cache_.kInt32, true);
@@ -934,6 +947,11 @@ void AsmTyper::VisitCompareOperation(CompareOperation* expr) {
RECURSE(
VisitWithExpectation(expr->right(), Type::Number(),
"right comparison operand expected to be number"));
+ Token::Value op = expr->op();
+ if (op != Token::EQ && op != Token::NE && op != Token::LT &&
+ op != Token::LTE && op != Token::GT && op != Token::GTE) {
+ FAIL(expr, "illegal comparison operator");
+ }
Type* right_type = computed_type_;
Type* type = Type::Union(left_type, right_type, zone());
expr->set_combined_type(type);
« no previous file with comments | « no previous file | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698