OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 | 2209 |
2210 if (top_scope_->is_strict_mode() && IsEvalOrArguments(name)) { | 2210 if (top_scope_->is_strict_mode() && IsEvalOrArguments(name)) { |
2211 ReportMessage("strict_catch_variable", Vector<const char*>::empty()); | 2211 ReportMessage("strict_catch_variable", Vector<const char*>::empty()); |
2212 *ok = false; | 2212 *ok = false; |
2213 return NULL; | 2213 return NULL; |
2214 } | 2214 } |
2215 | 2215 |
2216 Expect(Token::RPAREN, CHECK_OK); | 2216 Expect(Token::RPAREN, CHECK_OK); |
2217 | 2217 |
2218 if (peek() == Token::LBRACE) { | 2218 if (peek() == Token::LBRACE) { |
2219 // Rewrite the catch body { B } to a block: | |
2220 // { { B } ExitContext; }. | |
2221 Target target(&this->target_stack_, &catch_collector); | 2219 Target target(&this->target_stack_, &catch_collector); |
2222 catch_scope = NewScope(top_scope_, Scope::CATCH_SCOPE, inside_with()); | 2220 catch_scope = NewScope(top_scope_, Scope::CATCH_SCOPE, inside_with()); |
2223 if (top_scope_->is_strict_mode()) { | 2221 if (top_scope_->is_strict_mode()) { |
2224 catch_scope->EnableStrictMode(); | 2222 catch_scope->EnableStrictMode(); |
2225 } | 2223 } |
2226 Variable::Mode mode = harmony_block_scoping_ | 2224 Variable::Mode mode = harmony_block_scoping_ |
2227 ? Variable::LET : Variable::VAR; | 2225 ? Variable::LET : Variable::VAR; |
2228 catch_variable = catch_scope->DeclareLocal(name, mode); | 2226 catch_variable = catch_scope->DeclareLocal(name, mode); |
2229 catch_block = new(zone()) Block(isolate(), NULL, 2, false); | |
2230 | 2227 |
2231 Scope* saved_scope = top_scope_; | 2228 Scope* saved_scope = top_scope_; |
2232 top_scope_ = catch_scope; | 2229 top_scope_ = catch_scope; |
2233 Block* catch_body = ParseBlock(NULL, CHECK_OK); | 2230 catch_block = ParseBlock(NULL, CHECK_OK); |
2234 top_scope_ = saved_scope; | 2231 top_scope_ = saved_scope; |
2235 catch_block->AddStatement(catch_body); | |
2236 catch_block->AddStatement(new(zone()) ExitContextStatement()); | |
2237 } else { | 2232 } else { |
2238 Expect(Token::LBRACE, CHECK_OK); | 2233 Expect(Token::LBRACE, CHECK_OK); |
2239 } | 2234 } |
2240 | 2235 |
2241 tok = peek(); | 2236 tok = peek(); |
2242 } | 2237 } |
2243 | 2238 |
2244 Block* finally_block = NULL; | 2239 Block* finally_block = NULL; |
2245 if (tok == Token::FINALLY || catch_block == NULL) { | 2240 if (tok == Token::FINALLY || catch_block == NULL) { |
2246 Consume(Token::FINALLY); | 2241 Consume(Token::FINALLY); |
(...skipping 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5227 result = parser.ParseProgram(source, | 5222 result = parser.ParseProgram(source, |
5228 info->is_global(), | 5223 info->is_global(), |
5229 info->StrictMode()); | 5224 info->StrictMode()); |
5230 } | 5225 } |
5231 } | 5226 } |
5232 info->SetFunction(result); | 5227 info->SetFunction(result); |
5233 return (result != NULL); | 5228 return (result != NULL); |
5234 } | 5229 } |
5235 | 5230 |
5236 } } // namespace v8::internal | 5231 } } // namespace v8::internal |
OLD | NEW |