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 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1923 | 1923 |
1924 if (result != NULL) { | 1924 if (result != NULL) { |
1925 result->AddStatement(new(zone()) WithEnterStatement(obj)); | 1925 result->AddStatement(new(zone()) WithEnterStatement(obj)); |
1926 | 1926 |
1927 // Create body block. | 1927 // Create body block. |
1928 Block* body = new(zone()) Block(NULL, 1, false); | 1928 Block* body = new(zone()) Block(NULL, 1, false); |
1929 body->AddStatement(stat); | 1929 body->AddStatement(stat); |
1930 | 1930 |
1931 // Create exit block. | 1931 // Create exit block. |
1932 Block* exit = new(zone()) Block(NULL, 1, false); | 1932 Block* exit = new(zone()) Block(NULL, 1, false); |
1933 exit->AddStatement(new(zone()) WithExitStatement()); | 1933 exit->AddStatement(new(zone()) ContextExitStatement()); |
1934 | 1934 |
1935 // Return a try-finally statement. | 1935 // Return a try-finally statement. |
1936 TryFinallyStatement* wrapper = new(zone()) TryFinallyStatement(body, exit); | 1936 TryFinallyStatement* wrapper = new(zone()) TryFinallyStatement(body, exit); |
1937 wrapper->set_escaping_targets(collector.targets()); | 1937 wrapper->set_escaping_targets(collector.targets()); |
1938 result->AddStatement(wrapper); | 1938 result->AddStatement(wrapper); |
1939 } | 1939 } |
1940 return result; | 1940 return result; |
1941 } | 1941 } |
1942 | 1942 |
1943 | 1943 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2082 | 2082 |
2083 if (top_scope_->is_strict_mode() && IsEvalOrArguments(name)) { | 2083 if (top_scope_->is_strict_mode() && IsEvalOrArguments(name)) { |
2084 ReportMessage("strict_catch_variable", Vector<const char*>::empty()); | 2084 ReportMessage("strict_catch_variable", Vector<const char*>::empty()); |
2085 *ok = false; | 2085 *ok = false; |
2086 return NULL; | 2086 return NULL; |
2087 } | 2087 } |
2088 | 2088 |
2089 Expect(Token::RPAREN, CHECK_OK); | 2089 Expect(Token::RPAREN, CHECK_OK); |
2090 | 2090 |
2091 if (peek() == Token::LBRACE) { | 2091 if (peek() == Token::LBRACE) { |
2092 // Rewrite the catch body B to a single statement block | 2092 // Rewrite the catch body B to a single statement block |
2093 // { try B finally { PopContext }}. | 2093 // { try B finally { PopContext }}. |
2094 Block* inner_body; | 2094 Block* inner_body; |
2095 // We need to collect escapes from the body for both the inner | 2095 // We need to collect escapes from the body for both the inner |
2096 // try/finally used to pop the catch context and any possible outer | 2096 // try/finally used to pop the catch context and any possible outer |
2097 // try/finally. | 2097 // try/finally. |
2098 TargetCollector inner_collector; | 2098 TargetCollector inner_collector; |
2099 { Target target(&this->target_stack_, &catch_collector); | 2099 { Target target(&this->target_stack_, &catch_collector); |
2100 { Target target(&this->target_stack_, &inner_collector); | 2100 { Target target(&this->target_stack_, &inner_collector); |
2101 ++with_nesting_level_; | 2101 ++with_nesting_level_; |
2102 top_scope_->RecordWithStatement(); | 2102 top_scope_->RecordWithStatement(); |
2103 inner_body = ParseBlock(NULL, CHECK_OK); | 2103 inner_body = ParseBlock(NULL, CHECK_OK); |
2104 --with_nesting_level_; | 2104 --with_nesting_level_; |
2105 } | 2105 } |
2106 } | 2106 } |
2107 | 2107 |
2108 // Create exit block. | 2108 // Create exit block. |
2109 Block* inner_finally = new(zone()) Block(NULL, 1, false); | 2109 Block* inner_finally = new(zone()) Block(NULL, 1, false); |
2110 inner_finally->AddStatement(new(zone()) WithExitStatement()); | 2110 inner_finally->AddStatement(new(zone()) ContextExitStatement()); |
2111 | 2111 |
2112 // Create a try/finally statement. | 2112 // Create a try/finally statement. |
2113 TryFinallyStatement* inner_try_finally = | 2113 TryFinallyStatement* inner_try_finally = |
2114 new(zone()) TryFinallyStatement(inner_body, inner_finally); | 2114 new(zone()) TryFinallyStatement(inner_body, inner_finally); |
2115 inner_try_finally->set_escaping_targets(inner_collector.targets()); | 2115 inner_try_finally->set_escaping_targets(inner_collector.targets()); |
2116 | 2116 |
2117 catch_block = new(zone()) Block(NULL, 1, false); | 2117 catch_block = new(zone()) Block(NULL, 1, false); |
2118 catch_block->AddStatement(inner_try_finally); | 2118 catch_block->AddStatement(inner_try_finally); |
2119 } else { | 2119 } else { |
2120 Expect(Token::LBRACE, CHECK_OK); | 2120 Expect(Token::LBRACE, CHECK_OK); |
(...skipping 2869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4990 info->is_global(), | 4990 info->is_global(), |
4991 info->StrictMode()); | 4991 info->StrictMode()); |
4992 } | 4992 } |
4993 } | 4993 } |
4994 | 4994 |
4995 info->SetFunction(result); | 4995 info->SetFunction(result); |
4996 return (result != NULL); | 4996 return (result != NULL); |
4997 } | 4997 } |
4998 | 4998 |
4999 } } // namespace v8::internal | 4999 } } // namespace v8::internal |
OLD | NEW |