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

Unified Diff: src/compiler/typer.cc

Issue 1218773002: [turbofan] Add typing rules for the typeof operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix typo 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index 3a77ec311c82235384419364dbaa027990016117..5d8b423290b05887fd62943af4831ae29a17416a 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -331,6 +331,7 @@ class Typer::Visitor : public Reducer {
#undef DECLARE_METHOD
static Type* JSUnaryNotTyper(Type*, Typer*);
+ static Type* JSTypeOfTyper(Type*, Typer*);
static Type* JSLoadPropertyTyper(Type*, Type*, Typer*);
static Type* JSCallFunctionTyper(Type*, Typer*);
@@ -1211,8 +1212,25 @@ Bounds Typer::Visitor::TypeJSUnaryNot(Node* node) {
}
+Type* Typer::Visitor::JSTypeOfTyper(Type* type, Typer* t) {
+ Factory* const f = t->isolate()->factory();
+ if (type->Is(Type::Boolean())) {
+ return Type::Constant(f->boolean_string(), t->zone());
+ } else if (type->Is(Type::Number())) {
+ return Type::Constant(f->number_string(), t->zone());
+ } else if (type->Is(Type::Symbol())) {
+ return Type::Constant(f->symbol_string(), t->zone());
+ } else if (type->Is(Type::Union(Type::Undefined(), Type::Undetectable()))) {
+ return Type::Constant(f->undefined_string(), t->zone());
+ } else if (type->Is(Type::Null())) {
+ return Type::Constant(f->object_string(), t->zone());
+ }
+ return Type::InternalizedString();
+}
+
+
Bounds Typer::Visitor::TypeJSTypeOf(Node* node) {
- return Bounds(Type::None(zone()), Type::InternalizedString(zone()));
+ return TypeUnaryOp(node, JSTypeOfTyper);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698