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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 parent_(*variable) { | 316 parent_(*variable) { |
317 *variable = this; | 317 *variable = this; |
318 } | 318 } |
319 | 319 |
320 | 320 |
321 TemporaryScope::~TemporaryScope() { | 321 TemporaryScope::~TemporaryScope() { |
322 *variable_ = parent_; | 322 *variable_ = parent_; |
323 } | 323 } |
324 | 324 |
325 | 325 |
326 Handle<String> Parser::LookupSymbol(int symbol_id, | 326 Handle<String> Parser::LookupSymbol(int symbol_id) { |
327 Vector<const char> string) { | |
328 // Length of symbol cache is the number of identified symbols. | 327 // Length of symbol cache is the number of identified symbols. |
329 // If we are larger than that, or negative, it's not a cached symbol. | 328 // If we are larger than that, or negative, it's not a cached symbol. |
330 // This might also happen if there is no preparser symbol data, even | 329 // This might also happen if there is no preparser symbol data, even |
331 // if there is some preparser data. | 330 // if there is some preparser data. |
332 if (static_cast<unsigned>(symbol_id) | 331 if (static_cast<unsigned>(symbol_id) |
333 >= static_cast<unsigned>(symbol_cache_.length())) { | 332 >= static_cast<unsigned>(symbol_cache_.length())) { |
334 return Factory::LookupSymbol(string); | 333 if (scanner().is_literal_ascii()) { |
| 334 return Factory::LookupAsciiSymbol(scanner().literal_ascii_string()); |
| 335 } else { |
| 336 return Factory::LookupTwoByteSymbol(scanner().literal_uc16_string()); |
| 337 } |
335 } | 338 } |
336 return LookupCachedSymbol(symbol_id, string); | 339 return LookupCachedSymbol(symbol_id); |
337 } | 340 } |
338 | 341 |
339 | 342 |
340 Handle<String> Parser::LookupCachedSymbol(int symbol_id, | 343 Handle<String> Parser::LookupCachedSymbol(int symbol_id) { |
341 Vector<const char> string) { | |
342 // Make sure the cache is large enough to hold the symbol identifier. | 344 // Make sure the cache is large enough to hold the symbol identifier. |
343 if (symbol_cache_.length() <= symbol_id) { | 345 if (symbol_cache_.length() <= symbol_id) { |
344 // Increase length to index + 1. | 346 // Increase length to index + 1. |
345 symbol_cache_.AddBlock(Handle<String>::null(), | 347 symbol_cache_.AddBlock(Handle<String>::null(), |
346 symbol_id + 1 - symbol_cache_.length()); | 348 symbol_id + 1 - symbol_cache_.length()); |
347 } | 349 } |
348 Handle<String> result = symbol_cache_.at(symbol_id); | 350 Handle<String> result = symbol_cache_.at(symbol_id); |
349 if (result.is_null()) { | 351 if (result.is_null()) { |
350 result = Factory::LookupSymbol(string); | 352 if (scanner().is_literal_ascii()) { |
| 353 result = Factory::LookupAsciiSymbol(scanner().literal_ascii_string()); |
| 354 } else { |
| 355 result = Factory::LookupTwoByteSymbol(scanner().literal_uc16_string()); |
| 356 } |
351 symbol_cache_.at(symbol_id) = result; | 357 symbol_cache_.at(symbol_id) = result; |
352 return result; | 358 return result; |
353 } | 359 } |
354 Counters::total_preparse_symbols_skipped.Increment(); | 360 Counters::total_preparse_symbols_skipped.Increment(); |
355 return result; | 361 return result; |
356 } | 362 } |
357 | 363 |
358 | 364 |
359 FunctionEntry ScriptDataImpl::GetFunctionEntry(int start) { | 365 FunctionEntry ScriptDataImpl::GetFunctionEntry(int start) { |
360 // The current pre-data entry must be a FunctionEntry with the given | 366 // The current pre-data entry must be a FunctionEntry with the given |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 fni_ = new FuncNameInferrer(); | 614 fni_ = new FuncNameInferrer(); |
609 | 615 |
610 // Initialize parser state. | 616 // Initialize parser state. |
611 source->TryFlatten(); | 617 source->TryFlatten(); |
612 if (source->IsExternalTwoByteString()) { | 618 if (source->IsExternalTwoByteString()) { |
613 // Notice that the stream is destroyed at the end of the branch block. | 619 // Notice that the stream is destroyed at the end of the branch block. |
614 // The last line of the blocks can't be moved outside, even though they're | 620 // The last line of the blocks can't be moved outside, even though they're |
615 // identical calls. | 621 // identical calls. |
616 ExternalTwoByteStringUC16CharacterStream stream( | 622 ExternalTwoByteStringUC16CharacterStream stream( |
617 Handle<ExternalTwoByteString>::cast(source), 0, source->length()); | 623 Handle<ExternalTwoByteString>::cast(source), 0, source->length()); |
618 scanner_.Initialize(&stream, JavaScriptScanner::kAllLiterals); | 624 scanner_.Initialize(&stream); |
619 return DoParseProgram(source, in_global_context, &zone_scope); | 625 return DoParseProgram(source, in_global_context, &zone_scope); |
620 } else { | 626 } else { |
621 GenericStringUC16CharacterStream stream(source, 0, source->length()); | 627 GenericStringUC16CharacterStream stream(source, 0, source->length()); |
622 scanner_.Initialize(&stream, JavaScriptScanner::kAllLiterals); | 628 scanner_.Initialize(&stream); |
623 return DoParseProgram(source, in_global_context, &zone_scope); | 629 return DoParseProgram(source, in_global_context, &zone_scope); |
624 } | 630 } |
625 } | 631 } |
626 | 632 |
627 | 633 |
628 FunctionLiteral* Parser::DoParseProgram(Handle<String> source, | 634 FunctionLiteral* Parser::DoParseProgram(Handle<String> source, |
629 bool in_global_context, | 635 bool in_global_context, |
630 ZoneScope* zone_scope) { | 636 ZoneScope* zone_scope) { |
631 ASSERT(target_stack_ == NULL); | 637 ASSERT(target_stack_ == NULL); |
632 if (pre_data_ != NULL) pre_data_->Initialize(); | 638 if (pre_data_ != NULL) pre_data_->Initialize(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 info->end_position()); | 704 info->end_position()); |
699 FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope); | 705 FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope); |
700 return result; | 706 return result; |
701 } | 707 } |
702 } | 708 } |
703 | 709 |
704 | 710 |
705 FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info, | 711 FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info, |
706 UC16CharacterStream* source, | 712 UC16CharacterStream* source, |
707 ZoneScope* zone_scope) { | 713 ZoneScope* zone_scope) { |
708 scanner_.Initialize(source, JavaScriptScanner::kAllLiterals); | 714 scanner_.Initialize(source); |
709 ASSERT(target_stack_ == NULL); | 715 ASSERT(target_stack_ == NULL); |
710 | 716 |
711 Handle<String> name(String::cast(info->name())); | 717 Handle<String> name(String::cast(info->name())); |
712 fni_ = new FuncNameInferrer(); | 718 fni_ = new FuncNameInferrer(); |
713 fni_->PushEnclosingName(name); | 719 fni_->PushEnclosingName(name); |
714 | 720 |
715 mode_ = PARSE_EAGERLY; | 721 mode_ = PARSE_EAGERLY; |
716 | 722 |
717 // Place holder for the result. | 723 // Place holder for the result. |
718 FunctionLiteral* result = NULL; | 724 FunctionLiteral* result = NULL; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 } | 756 } |
751 return result; | 757 return result; |
752 } | 758 } |
753 | 759 |
754 | 760 |
755 Handle<String> Parser::GetSymbol(bool* ok) { | 761 Handle<String> Parser::GetSymbol(bool* ok) { |
756 int symbol_id = -1; | 762 int symbol_id = -1; |
757 if (pre_data() != NULL) { | 763 if (pre_data() != NULL) { |
758 symbol_id = pre_data()->GetSymbolIdentifier(); | 764 symbol_id = pre_data()->GetSymbolIdentifier(); |
759 } | 765 } |
760 return LookupSymbol(symbol_id, scanner().literal()); | 766 return LookupSymbol(symbol_id); |
761 } | 767 } |
762 | 768 |
763 | 769 |
764 void Parser::ReportMessage(const char* type, Vector<const char*> args) { | 770 void Parser::ReportMessage(const char* type, Vector<const char*> args) { |
765 Scanner::Location source_location = scanner().location(); | 771 Scanner::Location source_location = scanner().location(); |
766 ReportMessageAt(source_location, type, args); | 772 ReportMessageAt(source_location, type, args); |
767 } | 773 } |
768 | 774 |
769 | 775 |
770 void Parser::ReportMessageAt(Scanner::Location source_location, | 776 void Parser::ReportMessageAt(Scanner::Location source_location, |
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2708 | 2714 |
2709 case Token::IDENTIFIER: { | 2715 case Token::IDENTIFIER: { |
2710 Handle<String> name = ParseIdentifier(CHECK_OK); | 2716 Handle<String> name = ParseIdentifier(CHECK_OK); |
2711 if (fni_ != NULL) fni_->PushVariableName(name); | 2717 if (fni_ != NULL) fni_->PushVariableName(name); |
2712 result = top_scope_->NewUnresolved(name, inside_with()); | 2718 result = top_scope_->NewUnresolved(name, inside_with()); |
2713 break; | 2719 break; |
2714 } | 2720 } |
2715 | 2721 |
2716 case Token::NUMBER: { | 2722 case Token::NUMBER: { |
2717 Consume(Token::NUMBER); | 2723 Consume(Token::NUMBER); |
2718 double value = | 2724 ASSERT(scanner().is_literal_ascii()); |
2719 StringToDouble(scanner().literal(), ALLOW_HEX | ALLOW_OCTALS); | 2725 double value = StringToDouble(scanner().literal_ascii_string(), |
| 2726 ALLOW_HEX | ALLOW_OCTALS); |
2720 result = NewNumberLiteral(value); | 2727 result = NewNumberLiteral(value); |
2721 break; | 2728 break; |
2722 } | 2729 } |
2723 | 2730 |
2724 case Token::STRING: { | 2731 case Token::STRING: { |
2725 Consume(Token::STRING); | 2732 Consume(Token::STRING); |
2726 Handle<String> symbol = GetSymbol(CHECK_OK); | 2733 Handle<String> symbol = GetSymbol(CHECK_OK); |
2727 result = new Literal(symbol); | 2734 result = new Literal(symbol); |
2728 if (fni_ != NULL) fni_->PushLiteralName(symbol); | 2735 if (fni_ != NULL) fni_->PushLiteralName(symbol); |
2729 break; | 2736 break; |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3059 uint32_t index; | 3066 uint32_t index; |
3060 if (!string.is_null() && string->AsArrayIndex(&index)) { | 3067 if (!string.is_null() && string->AsArrayIndex(&index)) { |
3061 key = NewNumberLiteral(index); | 3068 key = NewNumberLiteral(index); |
3062 break; | 3069 break; |
3063 } | 3070 } |
3064 key = new Literal(string); | 3071 key = new Literal(string); |
3065 break; | 3072 break; |
3066 } | 3073 } |
3067 case Token::NUMBER: { | 3074 case Token::NUMBER: { |
3068 Consume(Token::NUMBER); | 3075 Consume(Token::NUMBER); |
3069 double value = | 3076 ASSERT(scanner().is_literal_ascii()); |
3070 StringToDouble(scanner().literal(), ALLOW_HEX | ALLOW_OCTALS); | 3077 double value = StringToDouble(scanner().literal_ascii_string(), |
| 3078 ALLOW_HEX | ALLOW_OCTALS); |
3071 key = NewNumberLiteral(value); | 3079 key = NewNumberLiteral(value); |
3072 break; | 3080 break; |
3073 } | 3081 } |
3074 default: | 3082 default: |
3075 if (Token::IsKeyword(next)) { | 3083 if (Token::IsKeyword(next)) { |
3076 Consume(next); | 3084 Consume(next); |
3077 Handle<String> string = GetSymbol(CHECK_OK); | 3085 Handle<String> string = GetSymbol(CHECK_OK); |
3078 key = new Literal(string); | 3086 key = new Literal(string); |
3079 } else { | 3087 } else { |
3080 // Unexpected token. | 3088 // Unexpected token. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3130 Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) { | 3138 Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) { |
3131 if (!scanner().ScanRegExpPattern(seen_equal)) { | 3139 if (!scanner().ScanRegExpPattern(seen_equal)) { |
3132 Next(); | 3140 Next(); |
3133 ReportMessage("unterminated_regexp", Vector<const char*>::empty()); | 3141 ReportMessage("unterminated_regexp", Vector<const char*>::empty()); |
3134 *ok = false; | 3142 *ok = false; |
3135 return NULL; | 3143 return NULL; |
3136 } | 3144 } |
3137 | 3145 |
3138 int literal_index = temp_scope_->NextMaterializedLiteralIndex(); | 3146 int literal_index = temp_scope_->NextMaterializedLiteralIndex(); |
3139 | 3147 |
3140 Handle<String> js_pattern = | 3148 Handle<String> js_pattern = NextLiteralString(TENURED); |
3141 Factory::NewStringFromUtf8(scanner().next_literal(), TENURED); | |
3142 scanner().ScanRegExpFlags(); | 3149 scanner().ScanRegExpFlags(); |
3143 Handle<String> js_flags = | 3150 Handle<String> js_flags = NextLiteralString(TENURED); |
3144 Factory::NewStringFromUtf8(scanner().next_literal(), TENURED); | |
3145 Next(); | 3151 Next(); |
3146 | 3152 |
3147 return new RegExpLiteral(js_pattern, js_flags, literal_index); | 3153 return new RegExpLiteral(js_pattern, js_flags, literal_index); |
3148 } | 3154 } |
3149 | 3155 |
3150 | 3156 |
3151 ZoneList<Expression*>* Parser::ParseArguments(bool* ok) { | 3157 ZoneList<Expression*>* Parser::ParseArguments(bool* ok) { |
3152 // Arguments :: | 3158 // Arguments :: |
3153 // '(' (AssignmentExpression)*[','] ')' | 3159 // '(' (AssignmentExpression)*[','] ')' |
3154 | 3160 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3416 | 3422 |
3417 // This function reads an identifier and determines whether or not it | 3423 // This function reads an identifier and determines whether or not it |
3418 // is 'get' or 'set'. The reason for not using ParseIdentifier and | 3424 // is 'get' or 'set'. The reason for not using ParseIdentifier and |
3419 // checking on the output is that this involves heap allocation which | 3425 // checking on the output is that this involves heap allocation which |
3420 // we can't do during preparsing. | 3426 // we can't do during preparsing. |
3421 Handle<String> Parser::ParseIdentifierOrGetOrSet(bool* is_get, | 3427 Handle<String> Parser::ParseIdentifierOrGetOrSet(bool* is_get, |
3422 bool* is_set, | 3428 bool* is_set, |
3423 bool* ok) { | 3429 bool* ok) { |
3424 Expect(Token::IDENTIFIER, ok); | 3430 Expect(Token::IDENTIFIER, ok); |
3425 if (!*ok) return Handle<String>(); | 3431 if (!*ok) return Handle<String>(); |
3426 if (scanner().literal_length() == 3) { | 3432 if (scanner().is_literal_ascii() && scanner().literal_length() == 3) { |
3427 const char* token = scanner().literal_string(); | 3433 const char* token = scanner().literal_ascii_string().start(); |
3428 *is_get = strcmp(token, "get") == 0; | 3434 *is_get = strncmp(token, "get", 3) == 0; |
3429 *is_set = !*is_get && strcmp(token, "set") == 0; | 3435 *is_set = !*is_get && strncmp(token, "set", 3) == 0; |
3430 } | 3436 } |
3431 return GetSymbol(ok); | 3437 return GetSymbol(ok); |
3432 } | 3438 } |
3433 | 3439 |
3434 | 3440 |
3435 // ---------------------------------------------------------------------------- | 3441 // ---------------------------------------------------------------------------- |
3436 // Parser support | 3442 // Parser support |
3437 | 3443 |
3438 | 3444 |
3439 bool Parser::TargetStackContainsLabel(Handle<String> label) { | 3445 bool Parser::TargetStackContainsLabel(Handle<String> label) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3597 } | 3603 } |
3598 return result; | 3604 return result; |
3599 } | 3605 } |
3600 | 3606 |
3601 | 3607 |
3602 Handle<String> JsonParser::GetString() { | 3608 Handle<String> JsonParser::GetString() { |
3603 int literal_length = scanner_.literal_length(); | 3609 int literal_length = scanner_.literal_length(); |
3604 if (literal_length == 0) { | 3610 if (literal_length == 0) { |
3605 return Factory::empty_string(); | 3611 return Factory::empty_string(); |
3606 } | 3612 } |
3607 const char* literal_string = scanner_.literal_string(); | 3613 if (scanner_.is_literal_ascii()) { |
3608 Vector<const char> literal(literal_string, literal_length); | 3614 return Factory::NewStringFromAscii(scanner_.literal_ascii_string()); |
3609 return Factory::NewStringFromUtf8(literal); | 3615 } else { |
| 3616 return Factory::NewStringFromTwoByte(scanner_.literal_uc16_string()); |
| 3617 } |
3610 } | 3618 } |
3611 | 3619 |
3612 | 3620 |
3613 // Parse any JSON value. | 3621 // Parse any JSON value. |
3614 Handle<Object> JsonParser::ParseJsonValue() { | 3622 Handle<Object> JsonParser::ParseJsonValue() { |
3615 Token::Value token = scanner_.Next(); | 3623 Token::Value token = scanner_.Next(); |
3616 switch (token) { | 3624 switch (token) { |
3617 case Token::STRING: { | 3625 case Token::STRING: { |
3618 return GetString(); | 3626 return GetString(); |
3619 } | 3627 } |
3620 case Token::NUMBER: { | 3628 case Token::NUMBER: { |
3621 double value = StringToDouble(scanner_.literal(), | 3629 ASSERT(scanner_.is_literal_ascii()); |
| 3630 double value = StringToDouble(scanner_.literal_ascii_string(), |
3622 NO_FLAGS, // Hex, octal or trailing junk. | 3631 NO_FLAGS, // Hex, octal or trailing junk. |
3623 OS::nan_value()); | 3632 OS::nan_value()); |
3624 return Factory::NewNumber(value); | 3633 return Factory::NewNumber(value); |
3625 } | 3634 } |
3626 case Token::FALSE_LITERAL: | 3635 case Token::FALSE_LITERAL: |
3627 return Factory::false_value(); | 3636 return Factory::false_value(); |
3628 case Token::TRUE_LITERAL: | 3637 case Token::TRUE_LITERAL: |
3629 return Factory::true_value(); | 3638 return Factory::true_value(); |
3630 case Token::NULL_LITERAL: | 3639 case Token::NULL_LITERAL: |
3631 return Factory::null_value(); | 3640 return Factory::null_value(); |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4590 data++; | 4599 data++; |
4591 } | 4600 } |
4592 *source = data; | 4601 *source = data; |
4593 return result; | 4602 return result; |
4594 } | 4603 } |
4595 | 4604 |
4596 | 4605 |
4597 // Create a Scanner for the preparser to use as input, and preparse the source. | 4606 // Create a Scanner for the preparser to use as input, and preparse the source. |
4598 static ScriptDataImpl* DoPreParse(UC16CharacterStream* source, | 4607 static ScriptDataImpl* DoPreParse(UC16CharacterStream* source, |
4599 bool allow_lazy, | 4608 bool allow_lazy, |
4600 ParserRecorder* recorder, | 4609 ParserRecorder* recorder) { |
4601 int literal_flags) { | |
4602 V8JavaScriptScanner scanner; | 4610 V8JavaScriptScanner scanner; |
4603 scanner.Initialize(source, literal_flags); | 4611 scanner.Initialize(source); |
4604 intptr_t stack_limit = StackGuard::real_climit(); | 4612 intptr_t stack_limit = StackGuard::real_climit(); |
4605 if (!preparser::PreParser::PreParseProgram(&scanner, | 4613 if (!preparser::PreParser::PreParseProgram(&scanner, |
4606 recorder, | 4614 recorder, |
4607 allow_lazy, | 4615 allow_lazy, |
4608 stack_limit)) { | 4616 stack_limit)) { |
4609 Top::StackOverflow(); | 4617 Top::StackOverflow(); |
4610 return NULL; | 4618 return NULL; |
4611 } | 4619 } |
4612 | 4620 |
4613 // Extract the accumulated data from the recorder as a single | 4621 // Extract the accumulated data from the recorder as a single |
4614 // contiguous vector that we are responsible for disposing. | 4622 // contiguous vector that we are responsible for disposing. |
4615 Vector<unsigned> store = recorder->ExtractData(); | 4623 Vector<unsigned> store = recorder->ExtractData(); |
4616 return new ScriptDataImpl(store); | 4624 return new ScriptDataImpl(store); |
4617 } | 4625 } |
4618 | 4626 |
4619 | 4627 |
4620 // Preparse, but only collect data that is immediately useful, | 4628 // Preparse, but only collect data that is immediately useful, |
4621 // even if the preparser data is only used once. | 4629 // even if the preparser data is only used once. |
4622 ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source, | 4630 ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source, |
4623 v8::Extension* extension) { | 4631 v8::Extension* extension) { |
4624 bool allow_lazy = FLAG_lazy && (extension == NULL); | 4632 bool allow_lazy = FLAG_lazy && (extension == NULL); |
4625 if (!allow_lazy) { | 4633 if (!allow_lazy) { |
4626 // Partial preparsing is only about lazily compiled functions. | 4634 // Partial preparsing is only about lazily compiled functions. |
4627 // If we don't allow lazy compilation, the log data will be empty. | 4635 // If we don't allow lazy compilation, the log data will be empty. |
4628 return NULL; | 4636 return NULL; |
4629 } | 4637 } |
4630 PartialParserRecorder recorder; | 4638 PartialParserRecorder recorder; |
4631 return DoPreParse(source, allow_lazy, &recorder, | 4639 return DoPreParse(source, allow_lazy, &recorder); |
4632 JavaScriptScanner::kNoLiterals); | |
4633 } | 4640 } |
4634 | 4641 |
4635 | 4642 |
4636 ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source, | 4643 ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source, |
4637 v8::Extension* extension) { | 4644 v8::Extension* extension) { |
4638 Handle<Script> no_script; | 4645 Handle<Script> no_script; |
4639 bool allow_lazy = FLAG_lazy && (extension == NULL); | 4646 bool allow_lazy = FLAG_lazy && (extension == NULL); |
4640 CompleteParserRecorder recorder; | 4647 CompleteParserRecorder recorder; |
4641 int kPreParseLiteralsFlags = | 4648 return DoPreParse(source, allow_lazy, &recorder); |
4642 JavaScriptScanner::kLiteralString | JavaScriptScanner::kLiteralIdentifier; | |
4643 return DoPreParse(source, allow_lazy, &recorder, kPreParseLiteralsFlags); | |
4644 } | 4649 } |
4645 | 4650 |
4646 | 4651 |
4647 bool RegExpParser::ParseRegExp(FlatStringReader* input, | 4652 bool RegExpParser::ParseRegExp(FlatStringReader* input, |
4648 bool multiline, | 4653 bool multiline, |
4649 RegExpCompileData* result) { | 4654 RegExpCompileData* result) { |
4650 ASSERT(result != NULL); | 4655 ASSERT(result != NULL); |
4651 RegExpParser parser(input, &result->error, multiline); | 4656 RegExpParser parser(input, &result->error, multiline); |
4652 RegExpTree* tree = parser.ParsePattern(); | 4657 RegExpTree* tree = parser.ParsePattern(); |
4653 if (parser.failed()) { | 4658 if (parser.failed()) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4693 Handle<String> source = Handle<String>(String::cast(script->source())); | 4698 Handle<String> source = Handle<String>(String::cast(script->source())); |
4694 result = parser.ParseProgram(source, info->is_global()); | 4699 result = parser.ParseProgram(source, info->is_global()); |
4695 } | 4700 } |
4696 } | 4701 } |
4697 | 4702 |
4698 info->SetFunction(result); | 4703 info->SetFunction(result); |
4699 return (result != NULL); | 4704 return (result != NULL); |
4700 } | 4705 } |
4701 | 4706 |
4702 } } // namespace v8::internal | 4707 } } // namespace v8::internal |
OLD | NEW |