| 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 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) { | 1484 Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) { |
| 1485 // Block :: | 1485 // Block :: |
| 1486 // '{' Statement* '}' | 1486 // '{' Statement* '}' |
| 1487 | 1487 |
| 1488 // Note that a Block does not introduce a new execution scope! | 1488 // Note that a Block does not introduce a new execution scope! |
| 1489 // (ECMA-262, 3rd, 12.2) | 1489 // (ECMA-262, 3rd, 12.2) |
| 1490 // | 1490 // |
| 1491 // Construct block expecting 16 statements. | 1491 // Construct block expecting 16 statements. |
| 1492 Block* result = new(zone()) Block(isolate(), labels, 16, false); | 1492 Block* result = new(zone()) Block(isolate(), labels, 16, false); |
| 1493 Target target(&this->target_stack_, result); | 1493 Target target(&this->target_stack_, result); |
| 1494 result->SetSourceBegStatementPos(scanner().location().beg_pos); |
| 1494 Expect(Token::LBRACE, CHECK_OK); | 1495 Expect(Token::LBRACE, CHECK_OK); |
| 1495 InitializationBlockFinder block_finder(top_scope_, target_stack_); | 1496 InitializationBlockFinder block_finder(top_scope_, target_stack_); |
| 1496 while (peek() != Token::RBRACE) { | 1497 while (peek() != Token::RBRACE) { |
| 1497 Statement* stat = ParseStatement(NULL, CHECK_OK); | 1498 Statement* stat = ParseStatement(NULL, CHECK_OK); |
| 1498 if (stat && !stat->IsEmpty()) { | 1499 if (stat && !stat->IsEmpty()) { |
| 1499 result->AddStatement(stat); | 1500 result->AddStatement(stat); |
| 1500 block_finder.Update(stat); | 1501 block_finder.Update(stat); |
| 1501 } | 1502 } |
| 1502 } | 1503 } |
| 1504 result->SetSourceEndStatementPos(scanner().location().end_pos); |
| 1503 Expect(Token::RBRACE, CHECK_OK); | 1505 Expect(Token::RBRACE, CHECK_OK); |
| 1504 return result; | 1506 return result; |
| 1505 } | 1507 } |
| 1506 | 1508 |
| 1507 | 1509 |
| 1508 Block* Parser::ParseVariableStatement(bool* ok) { | 1510 Block* Parser::ParseVariableStatement(bool* ok) { |
| 1509 // VariableStatement :: | 1511 // VariableStatement :: |
| 1510 // VariableDeclarations ';' | 1512 // VariableDeclarations ';' |
| 1511 | 1513 |
| 1512 Handle<String> ignore; | 1514 Handle<String> ignore; |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 return new(zone()) ReturnStatement(expr); | 1952 return new(zone()) ReturnStatement(expr); |
| 1951 } | 1953 } |
| 1952 | 1954 |
| 1953 | 1955 |
| 1954 Block* Parser::WithHelper(Expression* obj, ZoneStringList* labels, bool* ok) { | 1956 Block* Parser::WithHelper(Expression* obj, ZoneStringList* labels, bool* ok) { |
| 1955 // Parse the statement and collect escaping labels. | 1957 // Parse the statement and collect escaping labels. |
| 1956 TargetCollector collector; | 1958 TargetCollector collector; |
| 1957 Statement* stat; | 1959 Statement* stat; |
| 1958 { Target target(&this->target_stack_, &collector); | 1960 { Target target(&this->target_stack_, &collector); |
| 1959 with_nesting_level_++; | 1961 with_nesting_level_++; |
| 1962 Scope* saved_scope = top_scope_; |
| 1963 Scope* with_scope = NewScope(top_scope_, Scope::WITH_SCOPE, true); |
| 1964 if (top_scope_->is_strict_mode()) { |
| 1965 with_scope->EnableStrictMode(); |
| 1966 } |
| 1960 top_scope_->DeclarationScope()->RecordWithStatement(); | 1967 top_scope_->DeclarationScope()->RecordWithStatement(); |
| 1968 top_scope_ = with_scope; |
| 1969 with_scope->SetSourceBegStatementPos(scanner().location().beg_pos); |
| 1961 stat = ParseStatement(labels, CHECK_OK); | 1970 stat = ParseStatement(labels, CHECK_OK); |
| 1971 with_scope->SetSourceEndStatementPos(scanner().location().end_pos); |
| 1972 top_scope_ = saved_scope; |
| 1973 if (with_scope->calls_eval()) top_scope_->RecordEvalCall(); |
| 1962 with_nesting_level_--; | 1974 with_nesting_level_--; |
| 1963 } | 1975 } |
| 1964 // Create resulting block with two statements. | 1976 // Create resulting block with two statements. |
| 1965 // 1: Evaluate the with expression. | 1977 // 1: Evaluate the with expression. |
| 1966 // 2: The try-finally block evaluating the body. | 1978 // 2: The try-finally block evaluating the body. |
| 1967 Block* result = new(zone()) Block(isolate(), NULL, 2, false); | 1979 Block* result = new(zone()) Block(isolate(), NULL, 2, false); |
| 1968 | 1980 |
| 1969 if (result != NULL) { | 1981 if (result != NULL) { |
| 1970 result->AddStatement(new(zone()) EnterWithContextStatement(obj)); | 1982 result->AddStatement(new(zone()) EnterWithContextStatement(obj)); |
| 1971 | 1983 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 { Target target(&this->target_stack_, &inner_collector); | 2160 { Target target(&this->target_stack_, &inner_collector); |
| 2149 catch_scope = NewScope(top_scope_, Scope::CATCH_SCOPE, inside_with()); | 2161 catch_scope = NewScope(top_scope_, Scope::CATCH_SCOPE, inside_with()); |
| 2150 if (top_scope_->is_strict_mode()) { | 2162 if (top_scope_->is_strict_mode()) { |
| 2151 catch_scope->EnableStrictMode(); | 2163 catch_scope->EnableStrictMode(); |
| 2152 } | 2164 } |
| 2153 catch_variable = catch_scope->DeclareLocal(name, Variable::VAR); | 2165 catch_variable = catch_scope->DeclareLocal(name, Variable::VAR); |
| 2154 | 2166 |
| 2155 Scope* saved_scope = top_scope_; | 2167 Scope* saved_scope = top_scope_; |
| 2156 top_scope_ = catch_scope; | 2168 top_scope_ = catch_scope; |
| 2157 inner_body = ParseBlock(NULL, CHECK_OK); | 2169 inner_body = ParseBlock(NULL, CHECK_OK); |
| 2170 catch_scope->SetSourceBegStatementPos( |
| 2171 inner_body->SourceBegStatementPos()); |
| 2172 catch_scope->SetSourceEndStatementPos( |
| 2173 inner_body->SourceEndStatementPos()); |
| 2158 top_scope_ = saved_scope; | 2174 top_scope_ = saved_scope; |
| 2175 if (catch_scope->calls_eval()) top_scope_->RecordEvalCall(); |
| 2159 } | 2176 } |
| 2160 } | 2177 } |
| 2161 | 2178 |
| 2162 // Create exit block. | 2179 // Create exit block. |
| 2163 Block* inner_finally = new(zone()) Block(isolate(), NULL, 1, false); | 2180 Block* inner_finally = new(zone()) Block(isolate(), NULL, 1, false); |
| 2164 inner_finally->AddStatement(new(zone()) ExitContextStatement()); | 2181 inner_finally->AddStatement(new(zone()) |
| 2182 ExitScopedBlockStatement(catch_scope)); |
| 2165 | 2183 |
| 2166 // Create a try/finally statement. | 2184 // Create a try/finally statement. |
| 2167 TryFinallyStatement* inner_try_finally = | 2185 TryFinallyStatement* inner_try_finally = |
| 2168 new(zone()) TryFinallyStatement(inner_body, inner_finally); | 2186 new(zone()) TryFinallyStatement(inner_body, inner_finally); |
| 2169 inner_try_finally->set_escaping_targets(inner_collector.targets()); | 2187 inner_try_finally->set_escaping_targets(inner_collector.targets()); |
| 2170 | 2188 |
| 2171 catch_block = new(zone()) Block(isolate(), NULL, 1, false); | 2189 catch_block = new(zone()) Block(isolate(), NULL, 1, false); |
| 2172 catch_block->AddStatement(inner_try_finally); | 2190 catch_block->AddStatement(inner_try_finally); |
| 2173 } else { | 2191 } else { |
| 2174 Expect(Token::LBRACE, CHECK_OK); | 2192 Expect(Token::LBRACE, CHECK_OK); |
| (...skipping 2936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5111 info->is_global(), | 5129 info->is_global(), |
| 5112 info->StrictMode()); | 5130 info->StrictMode()); |
| 5113 } | 5131 } |
| 5114 } | 5132 } |
| 5115 | 5133 |
| 5116 info->SetFunction(result); | 5134 info->SetFunction(result); |
| 5117 return (result != NULL); | 5135 return (result != NULL); |
| 5118 } | 5136 } |
| 5119 | 5137 |
| 5120 } } // namespace v8::internal | 5138 } } // namespace v8::internal |
| OLD | NEW |