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

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

Issue 1201783003: Allow numeric literals to be checked for a decimal point. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 5 years, 6 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 | « src/ast.h ('k') | src/ast-value-factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast-value-factory.h
diff --git a/src/ast-value-factory.h b/src/ast-value-factory.h
index dd575e26abe337585351d96cbfddced2961cb23b..2fee0396fd487b02ac8d4020de783abcb989c810 100644
--- a/src/ast-value-factory.h
+++ b/src/ast-value-factory.h
@@ -142,9 +142,11 @@ class AstValue : public ZoneObject {
}
bool IsNumber() const {
- return type_ == NUMBER || type_ == SMI;
+ return type_ == NUMBER || type_ == NUMBER_WITH_DOT || type_ == SMI;
}
+ bool ContainsDot() const { return type_ == NUMBER_WITH_DOT; }
+
const AstRawString* AsString() const {
if (type_ == STRING)
return string_;
@@ -153,7 +155,7 @@ class AstValue : public ZoneObject {
}
double AsNumber() const {
- if (type_ == NUMBER)
+ if (type_ == NUMBER || type_ == NUMBER_WITH_DOT)
return number_;
if (type_ == SMI)
return smi_;
@@ -189,6 +191,7 @@ class AstValue : public ZoneObject {
STRING,
SYMBOL,
NUMBER,
+ NUMBER_WITH_DOT,
SMI,
BOOLEAN,
NULL_TYPE,
@@ -200,7 +203,14 @@ class AstValue : public ZoneObject {
explicit AstValue(const char* name) : type_(SYMBOL) { symbol_name_ = name; }
- explicit AstValue(double n) : type_(NUMBER) { number_ = n; }
+ explicit AstValue(double n, bool with_dot) {
+ if (with_dot) {
+ type_ = NUMBER_WITH_DOT;
+ } else {
+ type_ = NUMBER;
+ }
+ number_ = n;
+ }
AstValue(Type t, int i) : type_(t) {
DCHECK(type_ == SMI);
@@ -334,7 +344,7 @@ class AstValueFactory {
const AstValue* NewString(const AstRawString* string);
// A JavaScript symbol (ECMA-262 edition 6).
const AstValue* NewSymbol(const char* name);
- const AstValue* NewNumber(double number);
+ const AstValue* NewNumber(double number, bool with_dot = false);
const AstValue* NewSmi(int number);
const AstValue* NewBoolean(bool b);
const AstValue* NewStringList(ZoneList<const AstRawString*>* strings);
« no previous file with comments | « src/ast.h ('k') | src/ast-value-factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698