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

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: Extra parens in parameter lists now recognized, no longer segfaults on "()" Created 6 years, 7 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/objects-inl.h ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index 7f9f9f230f4ffd912f1bc94e2d762c27eb75744e..0f8bda5ec97045e283d2d875dcc81ba02311c269 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;
marja 2014/05/26 12:46:06 Why is this needed?
marja 2014/05/26 12:48:33 Ahh, nothing, I see we discussed scopes before. :)
typedef Variable GeneratorVariable;
typedef v8::internal::Zone Zone;
+ typedef v8::internal::AstProperties AstProperties;
+ typedef Vector<VariableProxy*> ParameterIdentifierVector;
+
// Return types for traversing functions.
typedef Handle<String> Identifier;
typedef v8::internal::Expression* Expression;
@@ -447,6 +451,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) {
@@ -535,11 +543,15 @@ class ParserTraits {
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();
+
// Odd-ball literal creators.
Literal* GetLiteralTheHole(int position,
AstNodeFactory<AstConstructionVisitor>* factory);
@@ -549,7 +561,8 @@ class ParserTraits {
Handle<String> NextLiteralString(Scanner* scanner,
PretenureFlag tenured);
Expression* ThisExpression(Scope* scope,
- AstNodeFactory<AstConstructionVisitor>* factory);
+ AstNodeFactory<AstConstructionVisitor>* factory,
+ int pos = RelocInfo::kNoPosition);
Literal* ExpressionFromLiteral(
Token::Value token, int pos, Scanner* scanner,
AstNodeFactory<AstConstructionVisitor>* factory);
@@ -568,6 +581,12 @@ 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, bool* ok);
+ void InferFunctionName(FunctionLiteral* func_to_infer);
// Temporary glue; these functions will move to ParserBase.
Expression* ParseV8Intrinsic(bool* ok);
@@ -579,6 +598,21 @@ class ParserTraits {
int function_token_position,
FunctionLiteral::FunctionType type,
bool* ok);
+ V8_INLINE void SkipLazyFunctionBody(
+ Handle<String> function_name,
+ int* materialized_literal_count,
+ int* expected_property_count,
+ bool* ok);
+ V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody(
+ Handle<String> function_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_;
@@ -763,6 +797,9 @@ class Parser : public ParserBase<ParserTraits> {
void RegisterTargetUse(Label* target, Target* stop);
+ Vector<VariableProxy*> ParameterListFromExpression(Expression* expression,
+ bool* ok);
+
// Factory methods.
Scope* NewScope(Scope* parent, ScopeType type);
@@ -809,6 +846,42 @@ class Parser : public ParserBase<ParserTraits> {
};
+Scope* ParserTraits::NewScope(Scope* parent_scope, ScopeType scope_type) {
+ return parser_->NewScope(parent_scope, scope_type);
+}
+
+
+Handle<String> ParserTraits::EmptyIdentifierString() {
+ return parser_->isolate()->factory()->empty_string();
+}
+
+
+void ParserTraits::SkipLazyFunctionBody(
+ Handle<String> 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(
+ Handle<String> function_name,
+ int pos,
+ Variable* fvar,
+ Token::Value fvar_init_op,
+ bool is_generator,
+ bool* ok) {
+ return parser_->ParseEagerFunctionBody(function_name, pos,
+ fvar, fvar_init_op, is_generator, ok);
+}
+
+void ParserTraits::CheckConflictingVarDeclarations(
+ v8::internal::Scope* scope, bool* ok) {
+ parser_->CheckConflictingVarDeclarations(scope, ok);
+}
+
// Support for handling complex values (array and object literals) that
// can be fully handled at compile time.
class CompileTimeValue: public AllStatic {
« no previous file with comments | « src/objects-inl.h ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698