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

Unified Diff: src/ast/ast-value-factory.h

Issue 2248693005: [Parser] Track ContainsDot for SMI values. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | src/ast/ast-value-factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast-value-factory.h
diff --git a/src/ast/ast-value-factory.h b/src/ast/ast-value-factory.h
index 818bcc7dc342dba15c87146c3481fbf589c750a8..f2240f6396e87db4c46a413747ce865c9881f4cc 100644
--- a/src/ast/ast-value-factory.h
+++ b/src/ast/ast-value-factory.h
@@ -154,10 +154,13 @@ class AstValue : public ZoneObject {
}
bool IsNumber() const {
- return type_ == NUMBER || type_ == NUMBER_WITH_DOT || type_ == SMI;
+ return type_ == NUMBER || type_ == NUMBER_WITH_DOT || type_ == SMI ||
+ type_ == SMI_WITH_DOT;
}
- bool ContainsDot() const { return type_ == NUMBER_WITH_DOT; }
+ bool ContainsDot() const {
+ return type_ == NUMBER_WITH_DOT || type_ == SMI_WITH_DOT;
+ }
const AstRawString* AsString() const {
CHECK_EQ(STRING, type_);
@@ -167,14 +170,14 @@ class AstValue : public ZoneObject {
double AsNumber() const {
if (type_ == NUMBER || type_ == NUMBER_WITH_DOT)
return number_;
- if (type_ == SMI)
+ if (type_ == SMI || type_ == SMI_WITH_DOT)
return smi_;
UNREACHABLE();
return 0;
}
Smi* AsSmi() const {
- CHECK_EQ(SMI, type_);
+ CHECK(type_ == SMI || type_ == SMI_WITH_DOT);
return Smi::FromInt(smi_);
}
@@ -186,7 +189,7 @@ class AstValue : public ZoneObject {
bool BooleanValue() const;
- bool IsSmi() const { return type_ == SMI; }
+ bool IsSmi() const { return type_ == SMI || type_ == SMI_WITH_DOT; }
bool IsFalse() const { return type_ == BOOLEAN && !bool_; }
bool IsTrue() const { return type_ == BOOLEAN && bool_; }
bool IsUndefined() const { return type_ == UNDEFINED; }
@@ -215,6 +218,7 @@ class AstValue : public ZoneObject {
NUMBER,
NUMBER_WITH_DOT,
SMI,
+ SMI_WITH_DOT,
BOOLEAN,
NULL_TYPE,
UNDEFINED,
@@ -230,18 +234,13 @@ class AstValue : public ZoneObject {
}
explicit AstValue(double n, bool with_dot) : next_(nullptr) {
- if (with_dot) {
- type_ = NUMBER_WITH_DOT;
- number_ = n;
+ int int_value;
+ if (DoubleToSmiInteger(n, &int_value)) {
+ type_ = with_dot ? SMI_WITH_DOT : SMI;
+ smi_ = int_value;
} else {
- int int_value;
- if (DoubleToSmiInteger(n, &int_value)) {
- type_ = SMI;
- smi_ = int_value;
- } else {
- type_ = NUMBER;
- number_ = n;
- }
+ type_ = with_dot ? NUMBER_WITH_DOT : NUMBER;
+ number_ = n;
}
}
« no previous file with comments | « no previous file | src/ast/ast-value-factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698