| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/char-predicates-inl.h" | 10 #include "src/char-predicates-inl.h" |
| (...skipping 4775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4786 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0; | 4786 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0; |
| 4787 result->contains_anchor = parser.contains_anchor(); | 4787 result->contains_anchor = parser.contains_anchor(); |
| 4788 result->capture_count = capture_count; | 4788 result->capture_count = capture_count; |
| 4789 } | 4789 } |
| 4790 return !parser.failed(); | 4790 return !parser.failed(); |
| 4791 } | 4791 } |
| 4792 | 4792 |
| 4793 | 4793 |
| 4794 bool Parser::Parse() { | 4794 bool Parser::Parse() { |
| 4795 ASSERT(info()->function() == NULL); | 4795 ASSERT(info()->function() == NULL); |
| 4796 ASSERT(info()->ast_value_factory() == NULL); | |
| 4797 FunctionLiteral* result = NULL; | 4796 FunctionLiteral* result = NULL; |
| 4798 ast_value_factory_ = new AstValueFactory(zone()); | 4797 ast_value_factory_ = info()->ast_value_factory(); |
| 4798 if (ast_value_factory_ == NULL) { |
| 4799 ast_value_factory_ = new AstValueFactory(zone()); |
| 4800 } |
| 4799 if (allow_natives_syntax() || extension_ != NULL) { | 4801 if (allow_natives_syntax() || extension_ != NULL) { |
| 4800 // If intrinsics are allowed, the Parser cannot operate independent of the | 4802 // If intrinsics are allowed, the Parser cannot operate independent of the |
| 4801 // V8 heap because of Rumtime. Tell the string table to internalize strings | 4803 // V8 heap because of Rumtime. Tell the string table to internalize strings |
| 4802 // and values right after they're created. | 4804 // and values right after they're created. |
| 4803 ast_value_factory_->Internalize(isolate()); | 4805 ast_value_factory_->Internalize(isolate()); |
| 4804 } | 4806 } |
| 4805 | 4807 |
| 4806 if (info()->is_lazy()) { | 4808 if (info()->is_lazy()) { |
| 4807 ASSERT(!info()->is_eval()); | 4809 ASSERT(!info()->is_eval()); |
| 4808 if (info()->shared_info()->is_function()) { | 4810 if (info()->shared_info()->is_function()) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4823 DeleteArray(message); | 4825 DeleteArray(message); |
| 4824 DeleteArray(arg); | 4826 DeleteArray(arg); |
| 4825 ASSERT(info()->isolate()->has_pending_exception()); | 4827 ASSERT(info()->isolate()->has_pending_exception()); |
| 4826 } else { | 4828 } else { |
| 4827 result = ParseProgram(); | 4829 result = ParseProgram(); |
| 4828 } | 4830 } |
| 4829 } | 4831 } |
| 4830 info()->SetFunction(result); | 4832 info()->SetFunction(result); |
| 4831 ast_value_factory_->Internalize(isolate()); | 4833 ast_value_factory_->Internalize(isolate()); |
| 4832 // info takes ownership of ast_value_factory_. | 4834 // info takes ownership of ast_value_factory_. |
| 4833 info()->SetAstValueFactory(ast_value_factory_); | 4835 if (info()->ast_value_factory() == NULL) { |
| 4836 info()->SetAstValueFactory(ast_value_factory_); |
| 4837 } |
| 4834 ast_value_factory_ = NULL; | 4838 ast_value_factory_ = NULL; |
| 4835 return (result != NULL); | 4839 return (result != NULL); |
| 4836 } | 4840 } |
| 4837 | 4841 |
| 4838 } } // namespace v8::internal | 4842 } } // namespace v8::internal |
| OLD | NEW |