Chromium Code Reviews| Index: src/parser.h |
| diff --git a/src/parser.h b/src/parser.h |
| index 16c2eff6d3a45a62c11cba0a93a564cb5667f649..7ad529fe1e78b6ed3c72ff16d337459ea09647a2 100644 |
| --- a/src/parser.h |
| +++ b/src/parser.h |
| @@ -1,4 +1,4 @@ |
| -// Copyright 2011 the V8 project authors. All rights reserved. |
| +// Copyright 2012 the V8 project authors. All rights reserved. |
| // Redistribution and use in source and binary forms, with or without |
| // modification, are permitted provided that the following conditions are |
| // met: |
| @@ -435,9 +435,10 @@ class Parser { |
| v8::Extension* extension, |
| ScriptDataImpl* pre_data); |
| virtual ~Parser() { |
| - if (reusable_preparser_ != NULL) { |
| - delete reusable_preparser_; |
| - } |
| + delete reusable_preparser_; |
| + reusable_preparser_ = NULL; |
| + delete ast_node_factory_; |
| + ast_node_factory_ = NULL; |
| } |
| // Returns NULL if parsing failed. |
| @@ -477,7 +478,64 @@ class Parser { |
| }; |
| class BlockState; |
| - class FunctionState; |
| + |
| + class FunctionState BASE_EMBEDDED { |
| + public: |
| + FunctionState(Parser* parser, Scope* scope, Isolate* isolate); |
| + ~FunctionState(); |
| + |
| + int NextMaterializedLiteralIndex() { |
| + return next_materialized_literal_index_++; |
| + } |
| + int materialized_literal_count() { |
| + return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; |
| + } |
| + |
| + int NextHandlerIndex() { return next_handler_index_++; } |
| + int handler_count() { return next_handler_index_; } |
| + |
| + void SetThisPropertyAssignmentInfo( |
| + bool only_simple_this_property_assignments, |
| + Handle<FixedArray> this_property_assignments) { |
| + only_simple_this_property_assignments_ = |
| + only_simple_this_property_assignments; |
| + this_property_assignments_ = this_property_assignments; |
| + } |
| + bool only_simple_this_property_assignments() { |
| + return only_simple_this_property_assignments_; |
| + } |
| + Handle<FixedArray> this_property_assignments() { |
| + return this_property_assignments_; |
| + } |
| + |
| + void AddProperty() { expected_property_count_++; } |
| + int expected_property_count() { return expected_property_count_; } |
| + |
| + private: |
| + // Used to assign an index to each literal that needs materialization in |
| + // the function. Includes regexp literals, and boilerplate for object and |
| + // array literals. |
| + int next_materialized_literal_index_; |
| + |
| + // Used to assign a per-function index to try and catch handlers. |
| + int next_handler_index_; |
| + |
| + // Properties count estimation. |
| + int expected_property_count_; |
| + |
| + // Keeps track of assignments to properties of this. Used for |
| + // optimizing constructors. |
| + bool only_simple_this_property_assignments_; |
| + Handle<FixedArray> this_property_assignments_; |
| + |
| + Parser* parser_; |
| + FunctionState* outer_function_state_; |
| + Scope* outer_scope_; |
| + unsigned saved_ast_node_id_; |
| + }; |
| + |
| + |
| + |
| FunctionLiteral* ParseLazy(CompilationInfo* info, |
| UC16CharacterStream* source, |
| @@ -651,7 +709,6 @@ class Parser { |
| // Get odd-ball literals. |
| Literal* GetLiteralUndefined(); |
| Literal* GetLiteralTheHole(); |
| - Literal* GetLiteralNumber(double value); |
| Handle<String> ParseIdentifier(bool* ok); |
| Handle<String> ParseIdentifierOrStrictReservedWord( |
| @@ -699,31 +756,12 @@ class Parser { |
| // Factory methods. |
| - Statement* EmptyStatement() { |
| - static v8::internal::EmptyStatement* empty = |
| - ::new v8::internal::EmptyStatement(); |
| - return empty; |
| - } |
| - |
| Scope* NewScope(Scope* parent, ScopeType type); |
| Handle<String> LookupSymbol(int symbol_id); |
| Handle<String> LookupCachedSymbol(int symbol_id); |
| - Expression* NewCall(Expression* expression, |
| - ZoneList<Expression*>* arguments, |
| - int pos) { |
| - return new(zone()) Call(isolate(), expression, arguments, pos); |
| - } |
| - |
| - inline Literal* NewLiteral(Handle<Object> handle) { |
| - return new(zone()) Literal(isolate(), handle); |
| - } |
| - |
| - // Create a number literal. |
| - Literal* NewNumberLiteral(double value); |
| - |
| // Generate AST node that throw a ReferenceError with the given type. |
| Expression* NewThrowReferenceError(Handle<String> type); |
| @@ -746,6 +784,8 @@ class Parser { |
| preparser::PreParser::PreParseResult LazyParseFunctionLiteral( |
| SingletonLogger* logger); |
| + AstNodeFactory* factory() { return ast_node_factory_; } |
| + |
| Isolate* isolate_; |
| ZoneList<Handle<String> > symbol_cache_; |
| @@ -754,6 +794,7 @@ class Parser { |
| preparser::PreParser* reusable_preparser_; |
| Scope* top_scope_; |
| FunctionState* current_function_state_; |
| + AstNodeFactory* ast_node_factory_; |
|
fschneider
2012/01/30 12:10:35
Embedded instance
AstNodeFactory ast_node_factor
Jakob Kummerow
2012/02/01 14:46:09
Done.
|
| Target* target_stack_; // for break, continue statements |
| v8::Extension* extension_; |
| ScriptDataImpl* pre_data_; |