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

Unified Diff: src/parsing/parser-base.h

Issue 1801633003: Add parsing for type queries (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@types
Patch Set: Created 4 years, 9 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 | « src/parsing/parser.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index 09061dfb062db23e3fb1bc389abef49dcd08673d..f701db75420c154c751b00082690b60a5c585db3 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -82,6 +82,7 @@ class ParserBase : public Traits {
// Shorten type names defined by Traits.
typedef typename Traits::Type::Expression ExpressionT;
typedef typename Traits::Type::Identifier IdentifierT;
+ typedef typename Traits::Type::IdentifierList IdentifierListT;
typedef typename Traits::Type::FormalParameter FormalParameterT;
typedef typename Traits::Type::FormalParameters FormalParametersT;
typedef typename Traits::Type::FunctionLiteral FunctionLiteralT;
@@ -842,6 +843,7 @@ class ParserBase : public Traits {
typename TypeSystem::Type ParsePrimaryTypeOrParameterList(bool* ok);
typename TypeSystem::TypeParameters ParseTypeParameters(bool* ok);
typename TypeSystem::TypeArguments ParseTypeArguments(bool* ok);
+ IdentifierListT ParsePropertyNameList(bool* ok);
typename TypeSystem::Type ValidateType(typename TypeSystem::Type type,
Scanner::Location location, bool* ok) {
@@ -3288,7 +3290,6 @@ ParserBase<Traits>::ParsePrimaryTypeOrParameterList(bool* ok) {
type = factory()->NewPredefinedType(
typesystem::PredefinedType::kSymbolType, pos);
} else {
- // TODO(nikolaos): Missing typeof.
IdentifierT name = ParseIdentifierName(CHECK_OK_TYPE);
typename TypeSystem::TypeArguments type_arguments =
this->NullTypeArguments();
@@ -3299,6 +3300,16 @@ ParserBase<Traits>::ParsePrimaryTypeOrParameterList(bool* ok) {
}
break;
}
+ case Token::TYPEOF: {
+ Consume(Token::TYPEOF);
+ IdentifierT name = ParseIdentifierName(CHECK_OK_TYPE);
+ IdentifierListT property_names = this->NullIdentifierList();
+ if (peek() == Token::PERIOD) { // Braces required here.
+ property_names = ParsePropertyNameList(CHECK_OK_TYPE);
+ }
+ type = factory()->NewQueryType(name, property_names, pos);
+ break;
+ }
case Token::VOID: {
Consume(Token::VOID);
type = factory()->NewPredefinedType(typesystem::PredefinedType::kVoidType,
@@ -3338,6 +3349,20 @@ ParserBase<Traits>::ParsePrimaryTypeOrParameterList(bool* ok) {
}
+template <typename Traits>
+typename ParserBase<Traits>::IdentifierListT
rossberg 2016/03/17 12:34:09 Doesn't make much sense to allow identifier lists
rossberg 2016/03/17 12:37:17 Ah sorry, I was confused. Disregard that comment.
+ParserBase<Traits>::ParsePropertyNameList(bool* ok) {
+ Expect(Token::PERIOD, CHECK_OK_CUSTOM(NullIdentifierList));
+ IdentifierListT property_names = this->EmptyIdentifierList();
+ do {
+ IdentifierT property_name =
+ ParseIdentifierName(CHECK_OK_CUSTOM(NullIdentifierList));
+ property_names->Add(property_name, zone());
+ } while (Check(Token::PERIOD));
+ return property_names;
+}
+
+
#undef CHECK_OK
#undef CHECK_OK_CUSTOM
#undef CHECK_OK_TYPE
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698