OLD | NEW |
---|---|
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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 AstValue* value = new (zone_) AstValue(name); | 323 AstValue* value = new (zone_) AstValue(name); |
324 return AddValue(value); | 324 return AddValue(value); |
325 } | 325 } |
326 | 326 |
327 | 327 |
328 const AstValue* AstValueFactory::NewNumber(double number, bool with_dot) { | 328 const AstValue* AstValueFactory::NewNumber(double number, bool with_dot) { |
329 AstValue* value = new (zone_) AstValue(number, with_dot); | 329 AstValue* value = new (zone_) AstValue(number, with_dot); |
330 return AddValue(value); | 330 return AddValue(value); |
331 } | 331 } |
332 | 332 |
333 | 333 const AstValue* AstValueFactory::NewSmi(uint32_t number) { |
vogelheim
2016/11/09 15:04:10
[nitpick, and purely a matter of personal preferen
| |
334 const AstValue* AstValueFactory::NewSmi(int number) { | 334 if (number <= kMaxCachedSmi) { |
335 AstValue* value = | 335 if (smis_[number] == nullptr) { |
336 new (zone_) AstValue(AstValue::SMI, number); | 336 AstValue* value = new (zone_) AstValue(AstValue::SMI, number); |
337 return AddValue(value); | 337 smis_[number] = AddValue(value); |
338 } | |
339 return smis_[number]; | |
340 } else { | |
341 AstValue* value = new (zone_) AstValue(AstValue::SMI, number); | |
342 return AddValue(value); | |
343 } | |
338 } | 344 } |
339 | 345 |
340 #define GENERATE_VALUE_GETTER(value, initializer) \ | 346 #define GENERATE_VALUE_GETTER(value, initializer) \ |
341 if (!value) { \ | 347 if (!value) { \ |
342 value = AddValue(new (zone_) AstValue(initializer)); \ | 348 value = AddValue(new (zone_) AstValue(initializer)); \ |
343 } \ | 349 } \ |
344 return value; | 350 return value; |
345 | 351 |
346 const AstValue* AstValueFactory::NewBoolean(bool b) { | 352 const AstValue* AstValueFactory::NewBoolean(bool b) { |
347 if (b) { | 353 if (b) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 length) == 0; | 424 length) == 0; |
419 } else { | 425 } else { |
420 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), | 426 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
421 reinterpret_cast<const uint16_t*>(r), | 427 reinterpret_cast<const uint16_t*>(r), |
422 length) == 0; | 428 length) == 0; |
423 } | 429 } |
424 } | 430 } |
425 } | 431 } |
426 } // namespace internal | 432 } // namespace internal |
427 } // namespace v8 | 433 } // namespace v8 |
OLD | NEW |