OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/typer.h" | 5 #include "src/compiler/typer.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 | 8 |
9 #include "src/base/flags.h" | 9 #include "src/base/flags.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 return type; | 416 return type; |
417 } | 417 } |
418 return Type::Primitive(); | 418 return Type::Primitive(); |
419 } | 419 } |
420 | 420 |
421 | 421 |
422 Type* Typer::Visitor::ToBoolean(Type* type, Typer* t) { | 422 Type* Typer::Visitor::ToBoolean(Type* type, Typer* t) { |
423 if (type->Is(Type::Boolean())) return type; | 423 if (type->Is(Type::Boolean())) return type; |
424 if (type->Is(t->falsish_)) return t->singleton_false_; | 424 if (type->Is(t->falsish_)) return t->singleton_false_; |
425 if (type->Is(t->truish_)) return t->singleton_true_; | 425 if (type->Is(t->truish_)) return t->singleton_true_; |
426 if (type->Is(Type::PlainNumber()) && (type->Max() < 0 || 0 < type->Min())) { | 426 if (type->Is(Type::Number())) { |
427 return t->singleton_true_; // Ruled out nan, -0 and +0. | 427 return t->operation_typer()->NumberToBoolean(type); |
428 } | 428 } |
429 return Type::Boolean(); | 429 return Type::Boolean(); |
430 } | 430 } |
431 | 431 |
432 | 432 |
433 // static | 433 // static |
434 Type* Typer::Visitor::ToInteger(Type* type, Typer* t) { | 434 Type* Typer::Visitor::ToInteger(Type* type, Typer* t) { |
435 // ES6 section 7.1.4 ToInteger ( argument ) | 435 // ES6 section 7.1.4 ToInteger ( argument ) |
436 type = ToNumber(type, t); | 436 type = ToNumber(type, t); |
437 if (type->Is(t->cache_.kIntegerOrMinusZero)) return type; | 437 if (type->Is(t->cache_.kIntegerOrMinusZero)) return type; |
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1703 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 1703 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
1704 if (Type::IsInteger(*value)) { | 1704 if (Type::IsInteger(*value)) { |
1705 return Type::Range(value->Number(), value->Number(), zone()); | 1705 return Type::Range(value->Number(), value->Number(), zone()); |
1706 } | 1706 } |
1707 return Type::Constant(value, zone()); | 1707 return Type::Constant(value, zone()); |
1708 } | 1708 } |
1709 | 1709 |
1710 } // namespace compiler | 1710 } // namespace compiler |
1711 } // namespace internal | 1711 } // namespace internal |
1712 } // namespace v8 | 1712 } // namespace v8 |
OLD | NEW |