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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 // ---------------------------------------------------------------------------- | 569 // ---------------------------------------------------------------------------- |
570 // Implementation of Parser | 570 // Implementation of Parser |
571 | 571 |
572 Parser::Parser(Handle<Script> script, | 572 Parser::Parser(Handle<Script> script, |
573 bool allow_natives_syntax, | 573 bool allow_natives_syntax, |
574 v8::Extension* extension, | 574 v8::Extension* extension, |
575 ScriptDataImpl* pre_data) | 575 ScriptDataImpl* pre_data) |
576 : isolate_(script->GetIsolate()), | 576 : isolate_(script->GetIsolate()), |
577 symbol_cache_(pre_data ? pre_data->symbol_count() : 0), | 577 symbol_cache_(pre_data ? pre_data->symbol_count() : 0), |
578 script_(script), | 578 script_(script), |
579 scanner_(isolate_->scanner_constants()), | 579 scanner_(isolate_->unicode_cache()), |
580 top_scope_(NULL), | 580 top_scope_(NULL), |
581 with_nesting_level_(0), | 581 with_nesting_level_(0), |
582 lexical_scope_(NULL), | 582 lexical_scope_(NULL), |
583 target_stack_(NULL), | 583 target_stack_(NULL), |
584 allow_natives_syntax_(allow_natives_syntax), | 584 allow_natives_syntax_(allow_natives_syntax), |
585 extension_(extension), | 585 extension_(extension), |
586 pre_data_(pre_data), | 586 pre_data_(pre_data), |
587 fni_(NULL), | 587 fni_(NULL), |
588 stack_overflow_(false), | 588 stack_overflow_(false), |
589 parenthesized_function_(false) { | 589 parenthesized_function_(false) { |
(...skipping 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2887 if (fni_ != NULL) fni_->PushVariableName(name); | 2887 if (fni_ != NULL) fni_->PushVariableName(name); |
2888 result = top_scope_->NewUnresolved(name, | 2888 result = top_scope_->NewUnresolved(name, |
2889 inside_with(), | 2889 inside_with(), |
2890 scanner().location().beg_pos); | 2890 scanner().location().beg_pos); |
2891 break; | 2891 break; |
2892 } | 2892 } |
2893 | 2893 |
2894 case Token::NUMBER: { | 2894 case Token::NUMBER: { |
2895 Consume(Token::NUMBER); | 2895 Consume(Token::NUMBER); |
2896 ASSERT(scanner().is_literal_ascii()); | 2896 ASSERT(scanner().is_literal_ascii()); |
2897 double value = StringToDouble(scanner().literal_ascii_string(), | 2897 double value = StringToDouble(isolate()->unicode_cache(), |
| 2898 scanner().literal_ascii_string(), |
2898 ALLOW_HEX | ALLOW_OCTALS); | 2899 ALLOW_HEX | ALLOW_OCTALS); |
2899 result = NewNumberLiteral(value); | 2900 result = NewNumberLiteral(value); |
2900 break; | 2901 break; |
2901 } | 2902 } |
2902 | 2903 |
2903 case Token::STRING: { | 2904 case Token::STRING: { |
2904 Consume(Token::STRING); | 2905 Consume(Token::STRING); |
2905 Handle<String> symbol = GetSymbol(CHECK_OK); | 2906 Handle<String> symbol = GetSymbol(CHECK_OK); |
2906 result = new(zone()) Literal(symbol); | 2907 result = new(zone()) Literal(symbol); |
2907 if (fni_ != NULL) fni_->PushLiteralName(symbol); | 2908 if (fni_ != NULL) fni_->PushLiteralName(symbol); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3385 if (!string.is_null() && string->AsArrayIndex(&index)) { | 3386 if (!string.is_null() && string->AsArrayIndex(&index)) { |
3386 key = NewNumberLiteral(index); | 3387 key = NewNumberLiteral(index); |
3387 break; | 3388 break; |
3388 } | 3389 } |
3389 key = new(zone()) Literal(string); | 3390 key = new(zone()) Literal(string); |
3390 break; | 3391 break; |
3391 } | 3392 } |
3392 case Token::NUMBER: { | 3393 case Token::NUMBER: { |
3393 Consume(Token::NUMBER); | 3394 Consume(Token::NUMBER); |
3394 ASSERT(scanner().is_literal_ascii()); | 3395 ASSERT(scanner().is_literal_ascii()); |
3395 double value = StringToDouble(scanner().literal_ascii_string(), | 3396 double value = StringToDouble(isolate()->unicode_cache(), |
| 3397 scanner().literal_ascii_string(), |
3396 ALLOW_HEX | ALLOW_OCTALS); | 3398 ALLOW_HEX | ALLOW_OCTALS); |
3397 key = NewNumberLiteral(value); | 3399 key = NewNumberLiteral(value); |
3398 break; | 3400 break; |
3399 } | 3401 } |
3400 default: | 3402 default: |
3401 if (Token::IsKeyword(next)) { | 3403 if (Token::IsKeyword(next)) { |
3402 Consume(next); | 3404 Consume(next); |
3403 Handle<String> string = GetSymbol(CHECK_OK); | 3405 Handle<String> string = GetSymbol(CHECK_OK); |
3404 key = new(zone()) Literal(string); | 3406 key = new(zone()) Literal(string); |
3405 } else { | 3407 } else { |
(...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5049 *source = data; | 5051 *source = data; |
5050 return result; | 5052 return result; |
5051 } | 5053 } |
5052 | 5054 |
5053 | 5055 |
5054 // Create a Scanner for the preparser to use as input, and preparse the source. | 5056 // Create a Scanner for the preparser to use as input, and preparse the source. |
5055 static ScriptDataImpl* DoPreParse(UC16CharacterStream* source, | 5057 static ScriptDataImpl* DoPreParse(UC16CharacterStream* source, |
5056 bool allow_lazy, | 5058 bool allow_lazy, |
5057 ParserRecorder* recorder) { | 5059 ParserRecorder* recorder) { |
5058 Isolate* isolate = Isolate::Current(); | 5060 Isolate* isolate = Isolate::Current(); |
5059 V8JavaScriptScanner scanner(isolate->scanner_constants()); | 5061 V8JavaScriptScanner scanner(isolate->unicode_cache()); |
5060 scanner.Initialize(source); | 5062 scanner.Initialize(source); |
5061 intptr_t stack_limit = isolate->stack_guard()->real_climit(); | 5063 intptr_t stack_limit = isolate->stack_guard()->real_climit(); |
5062 if (!preparser::PreParser::PreParseProgram(&scanner, | 5064 if (!preparser::PreParser::PreParseProgram(&scanner, |
5063 recorder, | 5065 recorder, |
5064 allow_lazy, | 5066 allow_lazy, |
5065 stack_limit)) { | 5067 stack_limit)) { |
5066 isolate->StackOverflow(); | 5068 isolate->StackOverflow(); |
5067 return NULL; | 5069 return NULL; |
5068 } | 5070 } |
5069 | 5071 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5149 info->is_global(), | 5151 info->is_global(), |
5150 info->StrictMode()); | 5152 info->StrictMode()); |
5151 } | 5153 } |
5152 } | 5154 } |
5153 | 5155 |
5154 info->SetFunction(result); | 5156 info->SetFunction(result); |
5155 return (result != NULL); | 5157 return (result != NULL); |
5156 } | 5158 } |
5157 | 5159 |
5158 } } // namespace v8::internal | 5160 } } // namespace v8::internal |
OLD | NEW |