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

Side by Side Diff: src/ast-value-factory.cc

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, 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 | « src/ast-value-factory.h ('k') | src/parser.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 134
135 bool AstValue::BooleanValue() const { 135 bool AstValue::BooleanValue() const {
136 switch (type_) { 136 switch (type_) {
137 case STRING: 137 case STRING:
138 DCHECK(string_ != NULL); 138 DCHECK(string_ != NULL);
139 return !string_->IsEmpty(); 139 return !string_->IsEmpty();
140 case SYMBOL: 140 case SYMBOL:
141 UNREACHABLE(); 141 UNREACHABLE();
142 break; 142 break;
143 case NUMBER_WITH_DOT:
143 case NUMBER: 144 case NUMBER:
144 return DoubleToBoolean(number_); 145 return DoubleToBoolean(number_);
145 case SMI: 146 case SMI:
146 return smi_ != 0; 147 return smi_ != 0;
147 case BOOLEAN: 148 case BOOLEAN:
148 return bool_; 149 return bool_;
149 case NULL_TYPE: 150 case NULL_TYPE:
150 return false; 151 return false;
151 case THE_HOLE: 152 case THE_HOLE:
152 UNREACHABLE(); 153 UNREACHABLE();
(...skipping 15 matching lines...) Expand all
168 break; 169 break;
169 case SYMBOL: 170 case SYMBOL:
170 if (symbol_name_[0] == 'i') { 171 if (symbol_name_[0] == 'i') {
171 DCHECK_EQ(0, strcmp(symbol_name_, "iterator_symbol")); 172 DCHECK_EQ(0, strcmp(symbol_name_, "iterator_symbol"));
172 value_ = isolate->factory()->iterator_symbol(); 173 value_ = isolate->factory()->iterator_symbol();
173 } else { 174 } else {
174 DCHECK_EQ(0, strcmp(symbol_name_, "home_object_symbol")); 175 DCHECK_EQ(0, strcmp(symbol_name_, "home_object_symbol"));
175 value_ = isolate->factory()->home_object_symbol(); 176 value_ = isolate->factory()->home_object_symbol();
176 } 177 }
177 break; 178 break;
179 case NUMBER_WITH_DOT:
178 case NUMBER: 180 case NUMBER:
179 value_ = isolate->factory()->NewNumber(number_, TENURED); 181 value_ = isolate->factory()->NewNumber(number_, TENURED);
180 break; 182 break;
181 case SMI: 183 case SMI:
182 value_ = handle(Smi::FromInt(smi_), isolate); 184 value_ = handle(Smi::FromInt(smi_), isolate);
183 break; 185 break;
184 case BOOLEAN: 186 case BOOLEAN:
185 if (bool_) { 187 if (bool_) {
186 value_ = isolate->factory()->true_value(); 188 value_ = isolate->factory()->true_value();
187 } else { 189 } else {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 const AstValue* AstValueFactory::NewSymbol(const char* name) { 285 const AstValue* AstValueFactory::NewSymbol(const char* name) {
284 AstValue* value = new (zone_) AstValue(name); 286 AstValue* value = new (zone_) AstValue(name);
285 if (isolate_) { 287 if (isolate_) {
286 value->Internalize(isolate_); 288 value->Internalize(isolate_);
287 } 289 }
288 values_.Add(value); 290 values_.Add(value);
289 return value; 291 return value;
290 } 292 }
291 293
292 294
293 const AstValue* AstValueFactory::NewNumber(double number) { 295 const AstValue* AstValueFactory::NewNumber(double number, bool with_dot) {
294 AstValue* value = new (zone_) AstValue(number); 296 AstValue* value = new (zone_) AstValue(number, with_dot);
295 if (isolate_) { 297 if (isolate_) {
296 value->Internalize(isolate_); 298 value->Internalize(isolate_);
297 } 299 }
298 values_.Add(value); 300 values_.Add(value);
299 return value; 301 return value;
300 } 302 }
301 303
302 304
303 const AstValue* AstValueFactory::NewSmi(int number) { 305 const AstValue* AstValueFactory::NewSmi(int number) {
304 AstValue* value = 306 AstValue* value =
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 const AstRawString* lhs = static_cast<AstRawString*>(a); 380 const AstRawString* lhs = static_cast<AstRawString*>(a);
379 const AstRawString* rhs = static_cast<AstRawString*>(b); 381 const AstRawString* rhs = static_cast<AstRawString*>(b);
380 if (lhs->is_one_byte() != rhs->is_one_byte()) return false; 382 if (lhs->is_one_byte() != rhs->is_one_byte()) return false;
381 if (lhs->hash() != rhs->hash()) return false; 383 if (lhs->hash() != rhs->hash()) return false;
382 int len = lhs->byte_length(); 384 int len = lhs->byte_length();
383 if (rhs->byte_length() != len) return false; 385 if (rhs->byte_length() != len) return false;
384 return memcmp(lhs->raw_data(), rhs->raw_data(), len) == 0; 386 return memcmp(lhs->raw_data(), rhs->raw_data(), len) == 0;
385 } 387 }
386 } // namespace internal 388 } // namespace internal
387 } // namespace v8 389 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast-value-factory.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698