Index: src/compiler/operation-typer.cc |
diff --git a/src/compiler/operation-typer.cc b/src/compiler/operation-typer.cc |
index f3ef778dc020d40213b1f5b2bb984031421816e5..564b3981020d72787fcf98d818b150cdd428bc7c 100644 |
--- a/src/compiler/operation-typer.cc |
+++ b/src/compiler/operation-typer.cc |
@@ -17,7 +17,7 @@ namespace internal { |
namespace compiler { |
OperationTyper::OperationTyper(Isolate* isolate, Zone* zone) |
- : zone_(zone), cache_(TypeCache::Get()) { |
+ : isolate_(isolate), zone_(zone), cache_(TypeCache::Get()) { |
Factory* factory = isolate->factory(); |
infinity_ = Type::Constant(factory->infinity_value(), zone); |
minus_infinity_ = Type::Constant(factory->minus_infinity_value(), zone); |
@@ -484,6 +484,25 @@ Type* OperationTyper::NumberToUint32(Type* type) { |
return Type::Unsigned32(); |
} |
+Type* OperationTyper::NumberToString(Type* lhs, Type* rhs) { |
+ DCHECK(lhs->Is(Type::Number())); |
+ DCHECK(rhs->Is(Type::Unsigned30())); |
+ if (!lhs->IsInhabited()) return Type::None(); |
+ if (lhs->Is(Type::NaN())) { |
+ return Type::Constant(factory()->nan_string(), zone()); |
+ } |
+ if (lhs->Is(cache_.kZeroish)) { |
+ return Type::Constant(factory()->zero_string(), zone()); |
+ } |
+ if (lhs->Is(infinity_)) { |
+ return Type::Constant(factory()->infinity_string(), zone()); |
+ } |
+ if (lhs->Is(minus_infinity_)) { |
+ return Type::Constant(factory()->minus_infinity_string(), zone()); |
+ } |
+ return Type::String(); |
+} |
+ |
Type* OperationTyper::NumberSilenceNaN(Type* type) { |
DCHECK(type->Is(Type::Number())); |
// TODO(jarin): This is a terrible hack; we definitely need a dedicated type |
@@ -963,6 +982,8 @@ Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { |
return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); |
} |
+Factory* OperationTyper::factory() const { return isolate()->factory(); } |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |