OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 | 810 |
811 virtual Handle<String> LookupSymbol(const char* string, int length) { | 811 virtual Handle<String> LookupSymbol(const char* string, int length) { |
812 return Handle<String>(); | 812 return Handle<String>(); |
813 } | 813 } |
814 | 814 |
815 virtual Handle<String> EmptySymbol() { | 815 virtual Handle<String> EmptySymbol() { |
816 return Handle<String>(); | 816 return Handle<String>(); |
817 } | 817 } |
818 | 818 |
819 virtual Expression* NewProperty(Expression* obj, Expression* key, int pos) { | 819 virtual Expression* NewProperty(Expression* obj, Expression* key, int pos) { |
820 if (obj == VariableProxySentinel::this_proxy()) { | 820 Isolate* isolate = Isolate::Current(); |
821 return Property::this_property(); | 821 if (obj == isolate->ast_sentinels()->this_proxy()) { |
| 822 return isolate->ast_sentinels()->this_property(); |
822 } else { | 823 } else { |
823 return ValidLeftHandSideSentinel::instance(); | 824 return isolate->ast_sentinels()->valid_left_hand_side_sentinel(); |
824 } | 825 } |
825 } | 826 } |
826 | 827 |
827 virtual Expression* NewCall(Expression* expression, | 828 virtual Expression* NewCall(Expression* expression, |
828 ZoneList<Expression*>* arguments, | 829 ZoneList<Expression*>* arguments, |
829 int pos) { | 830 int pos) { |
830 return Call::sentinel(); | 831 return Isolate::Current()->ast_sentinels()->call_sentinel(); |
831 } | 832 } |
832 | 833 |
833 virtual Statement* EmptyStatement() { | 834 virtual Statement* EmptyStatement() { |
834 return NULL; | 835 return NULL; |
835 } | 836 } |
836 | 837 |
837 template <typename T> ZoneListWrapper<T> NewList(int size) { | 838 template <typename T> ZoneListWrapper<T> NewList(int size) { |
838 return is_pre_parsing_ ? ZoneListWrapper<T>() : ZoneListWrapper<T>(size); | 839 return is_pre_parsing_ ? ZoneListWrapper<T>() : ZoneListWrapper<T>(size); |
839 } | 840 } |
840 | 841 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 virtual Expression* NewProperty(Expression* obj, Expression* key, int pos) { | 874 virtual Expression* NewProperty(Expression* obj, Expression* key, int pos) { |
874 return new Property(obj, key, pos); | 875 return new Property(obj, key, pos); |
875 } | 876 } |
876 | 877 |
877 virtual Expression* NewCall(Expression* expression, | 878 virtual Expression* NewCall(Expression* expression, |
878 ZoneList<Expression*>* arguments, | 879 ZoneList<Expression*>* arguments, |
879 int pos) { | 880 int pos) { |
880 return new Call(expression, arguments, pos); | 881 return new Call(expression, arguments, pos); |
881 } | 882 } |
882 | 883 |
883 virtual Statement* EmptyStatement(); | 884 virtual Statement* EmptyStatement() { |
| 885 return Isolate::Current()->ast_sentinels()->empty_statement(); |
| 886 } |
884 }; | 887 }; |
885 | 888 |
886 | 889 |
887 class ParserRecorder: public ParserLog { | 890 class ParserRecorder: public ParserLog { |
888 public: | 891 public: |
889 ParserRecorder(); | 892 ParserRecorder(); |
890 virtual FunctionEntry LogFunction(int start); | 893 virtual FunctionEntry LogFunction(int start); |
891 virtual void LogError() { } | 894 virtual void LogError() { } |
892 virtual void LogMessage(Scanner::Location loc, | 895 virtual void LogMessage(Scanner::Location loc, |
893 const char* message, | 896 const char* message, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 | 1069 |
1067 | 1070 |
1068 Scope* AstBuildingParserFactory::NewScope(Scope* parent, Scope::Type type, | 1071 Scope* AstBuildingParserFactory::NewScope(Scope* parent, Scope::Type type, |
1069 bool inside_with) { | 1072 bool inside_with) { |
1070 Scope* result = new Scope(parent, type); | 1073 Scope* result = new Scope(parent, type); |
1071 result->Initialize(inside_with); | 1074 result->Initialize(inside_with); |
1072 return result; | 1075 return result; |
1073 } | 1076 } |
1074 | 1077 |
1075 | 1078 |
1076 Statement* AstBuildingParserFactory::EmptyStatement() { | |
1077 // Use a statically allocated empty statement singleton to avoid | |
1078 // allocating lots and lots of empty statements. | |
1079 static v8::internal::EmptyStatement empty; | |
1080 return ∅ | |
1081 } | |
1082 | |
1083 | |
1084 Scope* ParserFactory::NewScope(Scope* parent, Scope::Type type, | 1079 Scope* ParserFactory::NewScope(Scope* parent, Scope::Type type, |
1085 bool inside_with) { | 1080 bool inside_with) { |
1086 ASSERT(parent != NULL); | 1081 ASSERT(parent != NULL); |
1087 parent->type_ = type; | 1082 parent->type_ = type; |
1088 return parent; | 1083 return parent; |
1089 } | 1084 } |
1090 | 1085 |
1091 | 1086 |
1092 VariableProxy* PreParser::Declare(Handle<String> name, Variable::Mode mode, | 1087 VariableProxy* PreParser::Declare(Handle<String> name, Variable::Mode mode, |
1093 FunctionLiteral* fun, bool resolve, | 1088 FunctionLiteral* fun, bool resolve, |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2036 | 2031 |
2037 | 2032 |
2038 // If the variable declaration declares exactly one non-const | 2033 // If the variable declaration declares exactly one non-const |
2039 // variable, then *var is set to that variable. In all other cases, | 2034 // variable, then *var is set to that variable. In all other cases, |
2040 // *var is untouched; in particular, it is the caller's responsibility | 2035 // *var is untouched; in particular, it is the caller's responsibility |
2041 // to initialize it properly. This mechanism is used for the parsing | 2036 // to initialize it properly. This mechanism is used for the parsing |
2042 // of 'for-in' loops. | 2037 // of 'for-in' loops. |
2043 Block* Parser::ParseVariableDeclarations(bool accept_IN, | 2038 Block* Parser::ParseVariableDeclarations(bool accept_IN, |
2044 Expression** var, | 2039 Expression** var, |
2045 bool* ok) { | 2040 bool* ok) { |
| 2041 Isolate* isolate = Isolate::Current(); |
2046 // VariableDeclarations :: | 2042 // VariableDeclarations :: |
2047 // ('var' | 'const') (Identifier ('=' AssignmentExpression)?)+[','] | 2043 // ('var' | 'const') (Identifier ('=' AssignmentExpression)?)+[','] |
2048 | 2044 |
2049 Variable::Mode mode = Variable::VAR; | 2045 Variable::Mode mode = Variable::VAR; |
2050 bool is_const = false; | 2046 bool is_const = false; |
2051 if (peek() == Token::VAR) { | 2047 if (peek() == Token::VAR) { |
2052 Consume(Token::VAR); | 2048 Consume(Token::VAR); |
2053 } else if (peek() == Token::CONST) { | 2049 } else if (peek() == Token::CONST) { |
2054 Consume(Token::CONST); | 2050 Consume(Token::CONST); |
2055 mode = Variable::CONST; | 2051 mode = Variable::CONST; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2205 Assignment* assignment = NEW(Assignment(op, last_var, value, position)); | 2201 Assignment* assignment = NEW(Assignment(op, last_var, value, position)); |
2206 if (block) block->AddStatement(NEW(ExpressionStatement(assignment))); | 2202 if (block) block->AddStatement(NEW(ExpressionStatement(assignment))); |
2207 } | 2203 } |
2208 } while (peek() == Token::COMMA); | 2204 } while (peek() == Token::COMMA); |
2209 | 2205 |
2210 if (!is_const && nvars == 1) { | 2206 if (!is_const && nvars == 1) { |
2211 // We have a single, non-const variable. | 2207 // We have a single, non-const variable. |
2212 if (is_pre_parsing_) { | 2208 if (is_pre_parsing_) { |
2213 // If we're preparsing then we need to set the var to something | 2209 // If we're preparsing then we need to set the var to something |
2214 // in order for for-in loops to parse correctly. | 2210 // in order for for-in loops to parse correctly. |
2215 *var = ValidLeftHandSideSentinel::instance(); | 2211 *var = isolate->ast_sentinels()->valid_left_hand_side_sentinel(); |
2216 } else { | 2212 } else { |
2217 ASSERT(last_var != NULL); | 2213 ASSERT(last_var != NULL); |
2218 *var = last_var; | 2214 *var = last_var; |
2219 } | 2215 } |
2220 } | 2216 } |
2221 | 2217 |
2222 return block; | 2218 return block; |
2223 } | 2219 } |
2224 | 2220 |
2225 | 2221 |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3257 Vector<const char*>::empty()); | 3253 Vector<const char*>::empty()); |
3258 default: | 3254 default: |
3259 const char* name = Token::String(token); | 3255 const char* name = Token::String(token); |
3260 ASSERT(name != NULL); | 3256 ASSERT(name != NULL); |
3261 ReportMessage("unexpected_token", Vector<const char*>(&name, 1)); | 3257 ReportMessage("unexpected_token", Vector<const char*>(&name, 1)); |
3262 } | 3258 } |
3263 } | 3259 } |
3264 | 3260 |
3265 | 3261 |
3266 Expression* Parser::ParsePrimaryExpression(bool* ok) { | 3262 Expression* Parser::ParsePrimaryExpression(bool* ok) { |
| 3263 Isolate* isolate = Isolate::Current(); |
3267 // PrimaryExpression :: | 3264 // PrimaryExpression :: |
3268 // 'this' | 3265 // 'this' |
3269 // 'null' | 3266 // 'null' |
3270 // 'true' | 3267 // 'true' |
3271 // 'false' | 3268 // 'false' |
3272 // Identifier | 3269 // Identifier |
3273 // Number | 3270 // Number |
3274 // String | 3271 // String |
3275 // ArrayLiteral | 3272 // ArrayLiteral |
3276 // ObjectLiteral | 3273 // ObjectLiteral |
3277 // RegExpLiteral | 3274 // RegExpLiteral |
3278 // '(' Expression ')' | 3275 // '(' Expression ')' |
3279 | 3276 |
3280 Expression* result = NULL; | 3277 Expression* result = NULL; |
3281 switch (peek()) { | 3278 switch (peek()) { |
3282 case Token::THIS: { | 3279 case Token::THIS: { |
3283 Consume(Token::THIS); | 3280 Consume(Token::THIS); |
3284 if (is_pre_parsing_) { | 3281 if (is_pre_parsing_) { |
3285 result = VariableProxySentinel::this_proxy(); | 3282 result = isolate->ast_sentinels()->this_proxy(); |
3286 } else { | 3283 } else { |
3287 VariableProxy* recv = top_scope_->receiver(); | 3284 VariableProxy* recv = top_scope_->receiver(); |
3288 result = recv; | 3285 result = recv; |
3289 } | 3286 } |
3290 break; | 3287 break; |
3291 } | 3288 } |
3292 | 3289 |
3293 case Token::NULL_LITERAL: | 3290 case Token::NULL_LITERAL: |
3294 Consume(Token::NULL_LITERAL); | 3291 Consume(Token::NULL_LITERAL); |
3295 result = NEW(Literal(Factory::null_value())); | 3292 result = NEW(Literal(Factory::null_value())); |
3296 break; | 3293 break; |
3297 | 3294 |
3298 case Token::TRUE_LITERAL: | 3295 case Token::TRUE_LITERAL: |
3299 Consume(Token::TRUE_LITERAL); | 3296 Consume(Token::TRUE_LITERAL); |
3300 result = NEW(Literal(Factory::true_value())); | 3297 result = NEW(Literal(Factory::true_value())); |
3301 break; | 3298 break; |
3302 | 3299 |
3303 case Token::FALSE_LITERAL: | 3300 case Token::FALSE_LITERAL: |
3304 Consume(Token::FALSE_LITERAL); | 3301 Consume(Token::FALSE_LITERAL); |
3305 result = NEW(Literal(Factory::false_value())); | 3302 result = NEW(Literal(Factory::false_value())); |
3306 break; | 3303 break; |
3307 | 3304 |
3308 case Token::IDENTIFIER: { | 3305 case Token::IDENTIFIER: { |
3309 Handle<String> name = ParseIdentifier(CHECK_OK); | 3306 Handle<String> name = ParseIdentifier(CHECK_OK); |
3310 if (is_pre_parsing_) { | 3307 if (is_pre_parsing_) { |
3311 result = VariableProxySentinel::identifier_proxy(); | 3308 result = isolate->ast_sentinels()->identifier_proxy(); |
3312 } else { | 3309 } else { |
3313 result = top_scope_->NewUnresolved(name, inside_with()); | 3310 result = top_scope_->NewUnresolved(name, inside_with()); |
3314 } | 3311 } |
3315 break; | 3312 break; |
3316 } | 3313 } |
3317 | 3314 |
3318 case Token::NUMBER: { | 3315 case Token::NUMBER: { |
3319 Consume(Token::NUMBER); | 3316 Consume(Token::NUMBER); |
3320 double value = | 3317 double value = |
3321 StringToDouble(scanner_.literal_string(), ALLOW_HEX | ALLOW_OCTALS); | 3318 StringToDouble(scanner_.literal_string(), ALLOW_HEX | ALLOW_OCTALS); |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3861 } | 3858 } |
3862 } | 3859 } |
3863 | 3860 |
3864 | 3861 |
3865 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 3862 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
3866 // CallRuntime :: | 3863 // CallRuntime :: |
3867 // '%' Identifier Arguments | 3864 // '%' Identifier Arguments |
3868 | 3865 |
3869 Expect(Token::MOD, CHECK_OK); | 3866 Expect(Token::MOD, CHECK_OK); |
3870 Handle<String> name = ParseIdentifier(CHECK_OK); | 3867 Handle<String> name = ParseIdentifier(CHECK_OK); |
3871 Runtime::Function* function = | 3868 const Runtime::Function* function = |
3872 Runtime::FunctionForName(scanner_.literal_string()); | 3869 Runtime::FunctionForName(scanner_.literal_string()); |
3873 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); | 3870 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); |
3874 if (function == NULL && extension_ != NULL) { | 3871 if (function == NULL && extension_ != NULL) { |
3875 // The extension structures are only accessible while parsing the | 3872 // The extension structures are only accessible while parsing the |
3876 // very first time not when reparsing because of lazy compilation. | 3873 // very first time not when reparsing because of lazy compilation. |
3877 top_scope_->ForceEagerCompilation(); | 3874 top_scope_->ForceEagerCompilation(); |
3878 } | 3875 } |
3879 | 3876 |
3880 // Check for built-in macros. | 3877 // Check for built-in macros. |
3881 if (!is_pre_parsing_) { | 3878 if (!is_pre_parsing_) { |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4660 Advance(); | 4657 Advance(); |
4661 } else if (FLAG_regexp_possessive_quantifier && current() == '+') { | 4658 } else if (FLAG_regexp_possessive_quantifier && current() == '+') { |
4662 // FLAG_regexp_possessive_quantifier is a debug-only flag. | 4659 // FLAG_regexp_possessive_quantifier is a debug-only flag. |
4663 type = RegExpQuantifier::POSSESSIVE; | 4660 type = RegExpQuantifier::POSSESSIVE; |
4664 Advance(); | 4661 Advance(); |
4665 } | 4662 } |
4666 builder->AddQuantifierToAtom(min, max, type); | 4663 builder->AddQuantifierToAtom(min, max, type); |
4667 } | 4664 } |
4668 } | 4665 } |
4669 | 4666 |
4670 class SourceCharacter { | |
4671 public: | |
4672 static bool Is(uc32 c) { | |
4673 switch (c) { | |
4674 // case ']': case '}': | |
4675 // In spidermonkey and jsc these are treated as source characters | |
4676 // so we do too. | |
4677 case '^': case '$': case '\\': case '.': case '*': case '+': | |
4678 case '?': case '(': case ')': case '[': case '{': case '|': | |
4679 case RegExpParser::kEndMarker: | |
4680 return false; | |
4681 default: | |
4682 return true; | |
4683 } | |
4684 } | |
4685 }; | |
4686 | |
4687 | |
4688 static unibrow::Predicate<SourceCharacter> source_character; | |
4689 | |
4690 | |
4691 static inline bool IsSourceCharacter(uc32 c) { | |
4692 return source_character.get(c); | |
4693 } | |
4694 | 4667 |
4695 #ifdef DEBUG | 4668 #ifdef DEBUG |
4696 // Currently only used in an ASSERT. | 4669 // Currently only used in an ASSERT. |
4697 static bool IsSpecialClassEscape(uc32 c) { | 4670 static bool IsSpecialClassEscape(uc32 c) { |
4698 switch (c) { | 4671 switch (c) { |
4699 case 'd': case 'D': | 4672 case 'd': case 'D': |
4700 case 's': case 'S': | 4673 case 's': case 'S': |
4701 case 'w': case 'W': | 4674 case 'w': case 'W': |
4702 return true; | 4675 return true; |
4703 default: | 4676 default: |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5053 return new RegExpCharacterClass(ranges, is_negated); | 5026 return new RegExpCharacterClass(ranges, is_negated); |
5054 } | 5027 } |
5055 | 5028 |
5056 | 5029 |
5057 // ---------------------------------------------------------------------------- | 5030 // ---------------------------------------------------------------------------- |
5058 // The Parser interface. | 5031 // The Parser interface. |
5059 | 5032 |
5060 // MakeAST() is just a wrapper for the corresponding Parser calls | 5033 // MakeAST() is just a wrapper for the corresponding Parser calls |
5061 // so we don't have to expose the entire Parser class in the .h file. | 5034 // so we don't have to expose the entire Parser class in the .h file. |
5062 | 5035 |
5063 static bool always_allow_natives_syntax = false; | |
5064 | |
5065 | 5036 |
5066 ParserMessage::~ParserMessage() { | 5037 ParserMessage::~ParserMessage() { |
5067 for (int i = 0; i < args().length(); i++) | 5038 for (int i = 0; i < args().length(); i++) |
5068 DeleteArray(args()[i]); | 5039 DeleteArray(args()[i]); |
5069 DeleteArray(args().start()); | 5040 DeleteArray(args().start()); |
5070 } | 5041 } |
5071 | 5042 |
5072 | 5043 |
5073 ScriptDataImpl::~ScriptDataImpl() { | 5044 ScriptDataImpl::~ScriptDataImpl() { |
5074 store_.Dispose(); | 5045 store_.Dispose(); |
(...skipping 13 matching lines...) Expand all Loading... |
5088 bool ScriptDataImpl::HasError() { | 5059 bool ScriptDataImpl::HasError() { |
5089 return has_error(); | 5060 return has_error(); |
5090 } | 5061 } |
5091 | 5062 |
5092 | 5063 |
5093 ScriptDataImpl* PreParse(Handle<String> source, | 5064 ScriptDataImpl* PreParse(Handle<String> source, |
5094 unibrow::CharacterStream* stream, | 5065 unibrow::CharacterStream* stream, |
5095 v8::Extension* extension) { | 5066 v8::Extension* extension) { |
5096 Handle<Script> no_script; | 5067 Handle<Script> no_script; |
5097 bool allow_natives_syntax = | 5068 bool allow_natives_syntax = |
5098 always_allow_natives_syntax || | 5069 Isolate::Current()->always_allow_natives_syntax() || |
5099 FLAG_allow_natives_syntax || | 5070 FLAG_allow_natives_syntax || |
5100 Isolate::Current()->bootstrapper()->IsActive(); | 5071 Isolate::Current()->bootstrapper()->IsActive(); |
5101 PreParser parser(no_script, allow_natives_syntax, extension); | 5072 PreParser parser(no_script, allow_natives_syntax, extension); |
5102 if (!parser.PreParseProgram(source, stream)) return NULL; | 5073 if (!parser.PreParseProgram(source, stream)) return NULL; |
5103 // The list owns the backing store so we need to clone the vector. | 5074 // The list owns the backing store so we need to clone the vector. |
5104 // That way, the result will be exactly the right size rather than | 5075 // That way, the result will be exactly the right size rather than |
5105 // the expected 50% too large. | 5076 // the expected 50% too large. |
5106 Vector<unsigned> store = parser.recorder()->store()->ToVector().Clone(); | 5077 Vector<unsigned> store = parser.recorder()->store()->ToVector().Clone(); |
5107 return new ScriptDataImpl(store); | 5078 return new ScriptDataImpl(store); |
5108 } | 5079 } |
(...skipping 20 matching lines...) Expand all Loading... |
5129 return !parser.failed(); | 5100 return !parser.failed(); |
5130 } | 5101 } |
5131 | 5102 |
5132 | 5103 |
5133 FunctionLiteral* MakeAST(bool compile_in_global_context, | 5104 FunctionLiteral* MakeAST(bool compile_in_global_context, |
5134 Handle<Script> script, | 5105 Handle<Script> script, |
5135 v8::Extension* extension, | 5106 v8::Extension* extension, |
5136 ScriptDataImpl* pre_data, | 5107 ScriptDataImpl* pre_data, |
5137 bool is_json) { | 5108 bool is_json) { |
5138 bool allow_natives_syntax = | 5109 bool allow_natives_syntax = |
5139 always_allow_natives_syntax || | 5110 Isolate::Current()->always_allow_natives_syntax() || |
5140 FLAG_allow_natives_syntax || | 5111 FLAG_allow_natives_syntax || |
5141 Isolate::Current()->bootstrapper()->IsActive(); | 5112 Isolate::Current()->bootstrapper()->IsActive(); |
5142 AstBuildingParser parser(script, allow_natives_syntax, extension, pre_data); | 5113 AstBuildingParser parser(script, allow_natives_syntax, extension, pre_data); |
5143 if (pre_data != NULL && pre_data->has_error()) { | 5114 if (pre_data != NULL && pre_data->has_error()) { |
5144 Scanner::Location loc = pre_data->MessageLocation(); | 5115 Scanner::Location loc = pre_data->MessageLocation(); |
5145 const char* message = pre_data->BuildMessage(); | 5116 const char* message = pre_data->BuildMessage(); |
5146 Vector<const char*> args = pre_data->BuildArgs(); | 5117 Vector<const char*> args = pre_data->BuildArgs(); |
5147 parser.ReportMessageAt(loc, message, args); | 5118 parser.ReportMessageAt(loc, message, args); |
5148 DeleteArray(message); | 5119 DeleteArray(message); |
5149 for (int i = 0; i < args.length(); i++) { | 5120 for (int i = 0; i < args.length(); i++) { |
(...skipping 12 matching lines...) Expand all Loading... |
5162 } | 5133 } |
5163 return result; | 5134 return result; |
5164 } | 5135 } |
5165 | 5136 |
5166 | 5137 |
5167 FunctionLiteral* MakeLazyAST(Handle<Script> script, | 5138 FunctionLiteral* MakeLazyAST(Handle<Script> script, |
5168 Handle<String> name, | 5139 Handle<String> name, |
5169 int start_position, | 5140 int start_position, |
5170 int end_position, | 5141 int end_position, |
5171 bool is_expression) { | 5142 bool is_expression) { |
5172 bool allow_natives_syntax_before = always_allow_natives_syntax; | 5143 bool allow_natives_syntax_before = |
5173 always_allow_natives_syntax = true; | 5144 Isolate::Current()->always_allow_natives_syntax(); |
| 5145 Isolate::Current()->set_always_allow_natives_syntax(true); |
5174 AstBuildingParser parser(script, true, NULL, NULL); // always allow | 5146 AstBuildingParser parser(script, true, NULL, NULL); // always allow |
5175 always_allow_natives_syntax = allow_natives_syntax_before; | 5147 Isolate::Current()->set_always_allow_natives_syntax( |
| 5148 allow_natives_syntax_before); |
5176 // Parse the function by pointing to the function source in the script source. | 5149 // Parse the function by pointing to the function source in the script source. |
5177 Handle<String> script_source(String::cast(script->source())); | 5150 Handle<String> script_source(String::cast(script->source())); |
5178 FunctionLiteral* result = | 5151 FunctionLiteral* result = |
5179 parser.ParseLazy(script_source, name, | 5152 parser.ParseLazy(script_source, name, |
5180 start_position, end_position, is_expression); | 5153 start_position, end_position, is_expression); |
5181 return result; | 5154 return result; |
5182 } | 5155 } |
5183 | 5156 |
5184 | 5157 |
5185 #undef NEW | 5158 #undef NEW |
5186 | 5159 |
5187 | 5160 |
5188 } } // namespace v8::internal | 5161 } } // namespace v8::internal |
OLD | NEW |