| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 bool is_generator_; | 221 bool is_generator_; |
| 222 // For generators, this variable may hold the generator object. It variable | 222 // For generators, this variable may hold the generator object. It variable |
| 223 // is used by yield expressions and return statements. It is not necessary | 223 // is used by yield expressions and return statements. It is not necessary |
| 224 // for generator functions to have this variable set. | 224 // for generator functions to have this variable set. |
| 225 Variable* generator_object_variable_; | 225 Variable* generator_object_variable_; |
| 226 | 226 |
| 227 FunctionState** function_state_stack_; | 227 FunctionState** function_state_stack_; |
| 228 FunctionState* outer_function_state_; | 228 FunctionState* outer_function_state_; |
| 229 typename Traits::Type::Scope** scope_stack_; | 229 typename Traits::Type::Scope** scope_stack_; |
| 230 typename Traits::Type::Scope* outer_scope_; | 230 typename Traits::Type::Scope* outer_scope_; |
| 231 Isolate* isolate_; // Only used by ParserTraits. | |
| 232 int saved_ast_node_id_; // Only used by ParserTraits. | 231 int saved_ast_node_id_; // Only used by ParserTraits. |
| 232 typename Traits::Type::Zone* extra_param_; |
| 233 typename Traits::Type::Factory factory_; | 233 typename Traits::Type::Factory factory_; |
| 234 | 234 |
| 235 friend class ParserTraits; | 235 friend class ParserTraits; |
| 236 }; | 236 }; |
| 237 | 237 |
| 238 class ParsingModeScope BASE_EMBEDDED { | 238 class ParsingModeScope BASE_EMBEDDED { |
| 239 public: | 239 public: |
| 240 ParsingModeScope(ParserBase* parser, Mode mode) | 240 ParsingModeScope(ParserBase* parser, Mode mode) |
| 241 : parser_(parser), | 241 : parser_(parser), |
| 242 old_mode_(parser->mode()) { | 242 old_mode_(parser->mode()) { |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 typedef PreParserFactory Factory; | 822 typedef PreParserFactory Factory; |
| 823 }; | 823 }; |
| 824 | 824 |
| 825 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} | 825 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} |
| 826 | 826 |
| 827 // Custom operations executed when FunctionStates are created and | 827 // Custom operations executed when FunctionStates are created and |
| 828 // destructed. (The PreParser doesn't need to do anything.) | 828 // destructed. (The PreParser doesn't need to do anything.) |
| 829 template<typename FunctionState> | 829 template<typename FunctionState> |
| 830 static void SetUpFunctionState(FunctionState* function_state, void*) {} | 830 static void SetUpFunctionState(FunctionState* function_state, void*) {} |
| 831 template<typename FunctionState> | 831 template<typename FunctionState> |
| 832 static void TearDownFunctionState(FunctionState* function_state) {} | 832 static void TearDownFunctionState(FunctionState* function_state, void*) {} |
| 833 | 833 |
| 834 // Helper functions for recursive descent. | 834 // Helper functions for recursive descent. |
| 835 static bool IsEvalOrArguments(PreParserIdentifier identifier) { | 835 static bool IsEvalOrArguments(PreParserIdentifier identifier) { |
| 836 return identifier.IsEvalOrArguments(); | 836 return identifier.IsEvalOrArguments(); |
| 837 } | 837 } |
| 838 | 838 |
| 839 // Returns true if the expression is of type "this.foo". | 839 // Returns true if the expression is of type "this.foo". |
| 840 static bool IsThisProperty(PreParserExpression expression) { | 840 static bool IsThisProperty(PreParserExpression expression) { |
| 841 return expression.IsThisProperty(); | 841 return expression.IsThisProperty(); |
| 842 } | 842 } |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 typename Traits::Type::Zone* extra_param) | 1174 typename Traits::Type::Zone* extra_param) |
| 1175 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), | 1175 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), |
| 1176 next_handler_index_(0), | 1176 next_handler_index_(0), |
| 1177 expected_property_count_(0), | 1177 expected_property_count_(0), |
| 1178 is_generator_(false), | 1178 is_generator_(false), |
| 1179 generator_object_variable_(NULL), | 1179 generator_object_variable_(NULL), |
| 1180 function_state_stack_(function_state_stack), | 1180 function_state_stack_(function_state_stack), |
| 1181 outer_function_state_(*function_state_stack), | 1181 outer_function_state_(*function_state_stack), |
| 1182 scope_stack_(scope_stack), | 1182 scope_stack_(scope_stack), |
| 1183 outer_scope_(*scope_stack), | 1183 outer_scope_(*scope_stack), |
| 1184 isolate_(NULL), | |
| 1185 saved_ast_node_id_(0), | 1184 saved_ast_node_id_(0), |
| 1185 extra_param_(extra_param), |
| 1186 factory_(extra_param) { | 1186 factory_(extra_param) { |
| 1187 *scope_stack_ = scope; | 1187 *scope_stack_ = scope; |
| 1188 *function_state_stack = this; | 1188 *function_state_stack = this; |
| 1189 Traits::SetUpFunctionState(this, extra_param); | 1189 Traits::SetUpFunctionState(this, extra_param); |
| 1190 } | 1190 } |
| 1191 | 1191 |
| 1192 | 1192 |
| 1193 template<class Traits> | 1193 template<class Traits> |
| 1194 ParserBase<Traits>::FunctionState::~FunctionState() { | 1194 ParserBase<Traits>::FunctionState::~FunctionState() { |
| 1195 *scope_stack_ = outer_scope_; | 1195 *scope_stack_ = outer_scope_; |
| 1196 *function_state_stack_ = outer_function_state_; | 1196 *function_state_stack_ = outer_function_state_; |
| 1197 Traits::TearDownFunctionState(this); | 1197 Traits::TearDownFunctionState(this, extra_param_); |
| 1198 } | 1198 } |
| 1199 | 1199 |
| 1200 | 1200 |
| 1201 template<class Traits> | 1201 template<class Traits> |
| 1202 void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) { | 1202 void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) { |
| 1203 Scanner::Location source_location = scanner()->location(); | 1203 Scanner::Location source_location = scanner()->location(); |
| 1204 | 1204 |
| 1205 // Four of the tokens are treated specially | 1205 // Four of the tokens are treated specially |
| 1206 switch (token) { | 1206 switch (token) { |
| 1207 case Token::EOS: | 1207 case Token::EOS: |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2150 "accessor_get_set"); | 2150 "accessor_get_set"); |
| 2151 } | 2151 } |
| 2152 *ok = false; | 2152 *ok = false; |
| 2153 } | 2153 } |
| 2154 } | 2154 } |
| 2155 | 2155 |
| 2156 | 2156 |
| 2157 } } // v8::internal | 2157 } } // v8::internal |
| 2158 | 2158 |
| 2159 #endif // V8_PREPARSER_H | 2159 #endif // V8_PREPARSER_H |
| OLD | NEW |