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

Unified Diff: src/parser.h

Issue 160073006: Implement handling of arrow functions in the parser (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed ParamListFinder Created 6 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
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index 3d44d585ca069c9ba82bd05069cda0d0bd176730..260b30b8db8a308e1bda78c27786a5c8fb944735 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -385,9 +385,13 @@ class ParserTraits {
// Used by FunctionState and BlockState.
typedef v8::internal::Scope Scope;
+ typedef v8::internal::Scope* ScopePtr;
typedef Variable GeneratorVariable;
typedef v8::internal::Zone Zone;
+ typedef v8::internal::AstProperties AstProperties;
+ typedef Vector<VariableProxy*> ParameterIdentifierVector;
+
// Return types for traversing functions.
typedef const AstRawString* Identifier;
typedef v8::internal::Expression* Expression;
@@ -422,6 +426,7 @@ class ParserTraits {
// Helper functions for recursive descent.
bool IsEvalOrArguments(const AstRawString* identifier) const;
+ V8_INLINE bool IsFutureStrictReserved(const AstRawString* identifier) const;
// Returns true if the expression is of type "this.foo".
static bool IsThisProperty(Expression* expression);
@@ -447,6 +452,10 @@ class ParserTraits {
fni->PushLiteralName(id);
}
void PushPropertyName(FuncNameInferrer* fni, Expression* expression);
+ static void InferFunctionName(FuncNameInferrer* fni,
+ FunctionLiteral* func_to_infer) {
+ fni->AddFunction(func_to_infer);
+ }
static void CheckFunctionLiteralInsideTopLevelObjectLiteral(
Scope* scope, Expression* value, bool* has_function) {
@@ -536,14 +545,21 @@ class ParserTraits {
static Expression* EmptyExpression() {
return NULL;
}
+ static Expression* EmptyArrowParamList() {
+ return NULL;
+ }
static Literal* EmptyLiteral() {
return NULL;
}
+
// Used in error return values.
static ZoneList<Expression*>* NullExpressionList() {
return NULL;
}
+ // Non-"null" empty string.
+ V8_INLINE Handle<String> EmptyIdentifierString();
marja 2014/06/26 14:38:13 Isn't this dead code?
+
// Odd-ball literal creators.
Literal* GetLiteralTheHole(int position,
AstNodeFactory<AstConstructionVisitor>* factory);
@@ -553,7 +569,8 @@ class ParserTraits {
const AstRawString* GetNextSymbol(Scanner* scanner);
Expression* ThisExpression(Scope* scope,
- AstNodeFactory<AstConstructionVisitor>* factory);
+ AstNodeFactory<AstConstructionVisitor>* factory,
+ int pos = RelocInfo::kNoPosition);
marja 2014/06/26 14:38:13 Why is the position needed?
Literal* ExpressionFromLiteral(
Token::Value token, int pos, Scanner* scanner,
AstNodeFactory<AstConstructionVisitor>* factory);
@@ -572,6 +589,13 @@ class ParserTraits {
ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
}
+ V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type);
+
+ // Utility functions
+ Vector<VariableProxy*> ParameterListFromExpression( Expression* expression);
marja 2014/06/26 14:38:13 Nit: extra space.
+ bool IsValidArrowFunctionParameterList(Expression* expression);
marja 2014/06/26 14:38:13 This function should go where the other IsThisAndT
+ void InferFunctionName(FunctionLiteral* func_to_infer);
marja 2014/06/26 14:38:13 Isn't this a stray definition?
+ V8_INLINE AstValueFactory* ast_value_factory();
// Temporary glue; these functions will move to ParserBase.
Expression* ParseV8Intrinsic(bool* ok);
@@ -584,6 +608,21 @@ class ParserTraits {
FunctionLiteral::FunctionType type,
FunctionLiteral::ArityRestriction arity_restriction,
bool* ok);
+ V8_INLINE void SkipLazyFunctionBody(
+ const AstRawString* name,
+ int* materialized_literal_count,
+ int* expected_property_count,
+ bool* ok);
+ V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody(
+ const AstRawString* name,
+ int pos,
+ Variable* fvar,
+ Token::Value fvar_init_op,
+ bool is_generator,
+ bool* ok);
+ V8_INLINE void CheckConflictingVarDeclarations(
+ v8::internal::Scope* scope,
+ bool* ok);
private:
Parser* parser_;
@@ -822,6 +861,55 @@ class Parser : public ParserBase<ParserTraits> {
};
+bool ParserTraits::IsFutureStrictReserved(
+ const AstRawString* identifier) const {
+ return identifier->IsOneByteEqualTo("yield") ||
+ parser_->scanner()->IdentifierIsFutureStrictReserved(identifier);
+}
+
+
+Scope* ParserTraits::NewScope(Scope* parent_scope, ScopeType scope_type) {
+ return parser_->NewScope(parent_scope, scope_type);
+}
+
+
+Handle<String> ParserTraits::EmptyIdentifierString() {
+ return parser_->zone()->isolate()->factory()->empty_string();
+}
+
+
+void ParserTraits::SkipLazyFunctionBody(
+ const AstRawString* function_name,
+ int* materialized_literal_count,
+ int* expected_property_count,
+ bool* ok) {
+ return parser_->SkipLazyFunctionBody(function_name,
+ materialized_literal_count, expected_property_count, ok);
+}
+
+
+ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody(
+ const AstRawString* name,
+ int pos,
+ Variable* fvar,
+ Token::Value fvar_init_op,
+ bool is_generator,
+ bool* ok) {
+ return parser_->ParseEagerFunctionBody(name, pos,
+ fvar, fvar_init_op, is_generator, ok);
+}
+
+void ParserTraits::CheckConflictingVarDeclarations(
+ v8::internal::Scope* scope, bool* ok) {
+ parser_->CheckConflictingVarDeclarations(scope, ok);
+}
+
+
+AstValueFactory* ParserTraits::ast_value_factory() {
+ return parser_->ast_value_factory_;
+}
+
+
// Support for handling complex values (array and object literals) that
// can be fully handled at compile time.
class CompileTimeValue: public AllStatic {

Powered by Google App Engine
This is Rietveld 408576698