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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include "api.h" | 30 #include "api.h" |
31 #include "ast.h" | 31 #include "ast.h" |
32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
33 #include "codegen.h" | 33 #include "codegen.h" |
34 #include "compiler.h" | 34 #include "compiler.h" |
35 #include "func-name-inferrer.h" | 35 #include "func-name-inferrer.h" |
36 #include "messages.h" | 36 #include "messages.h" |
37 #include "parser.h" | 37 #include "parser.h" |
38 #include "platform.h" | 38 #include "platform.h" |
39 #include "prescanner.h" | |
40 #include "preparser.h" | 39 #include "preparser.h" |
41 #include "runtime.h" | 40 #include "runtime.h" |
42 #include "scopeinfo.h" | 41 #include "scopeinfo.h" |
43 #include "string-stream.h" | 42 #include "string-stream.h" |
44 | 43 |
45 #include "ast-inl.h" | 44 #include "ast-inl.h" |
46 #include "jump-target-inl.h" | 45 #include "jump-target-inl.h" |
47 | 46 |
48 namespace v8 { | 47 namespace v8 { |
49 namespace internal { | 48 namespace internal { |
(...skipping 4611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4661 // contiguous vector that we are responsible for disposing. | 4660 // contiguous vector that we are responsible for disposing. |
4662 Vector<unsigned> store = recorder.ExtractData(); | 4661 Vector<unsigned> store = recorder.ExtractData(); |
4663 return new ScriptDataImpl(store); | 4662 return new ScriptDataImpl(store); |
4664 } | 4663 } |
4665 | 4664 |
4666 | 4665 |
4667 ScriptDataImpl* ParserApi::PreParse(Handle<String> source, | 4666 ScriptDataImpl* ParserApi::PreParse(Handle<String> source, |
4668 unibrow::CharacterStream* stream, | 4667 unibrow::CharacterStream* stream, |
4669 v8::Extension* extension) { | 4668 v8::Extension* extension) { |
4670 Handle<Script> no_script; | 4669 Handle<Script> no_script; |
4671 int length = 0; | 4670 preparser::PreParser<Scanner, CompleteParserRecorder> parser; |
4672 SafeStringInputBuffer safe_stream; | 4671 Scanner scanner; |
4673 if (!source.is_null()) { | 4672 scanner.Initialize(source, stream, JAVASCRIPT); |
4674 length = source->length(); | |
4675 safe_stream.Reset(source.location()); | |
4676 stream = &safe_stream; | |
4677 } else { | |
4678 length = stream->Length(); | |
4679 } | |
4680 typedef preparser::Scanner<CharacterStreamUTF16Buffer, UTF8Buffer> PreScanner; | |
4681 preparser::PreParser<PreScanner, CompleteParserRecorder> parser; | |
4682 CharacterStreamUTF16Buffer buffer; | |
4683 buffer.Initialize(source, stream, 0, length); | |
4684 PreScanner scanner; | |
4685 scanner.Initialize(&buffer); | |
4686 bool allow_lazy = FLAG_lazy && (extension == NULL); | 4673 bool allow_lazy = FLAG_lazy && (extension == NULL); |
4687 CompleteParserRecorder recorder; | 4674 CompleteParserRecorder recorder; |
4688 if (!parser.PreParseProgram(&scanner, &recorder, allow_lazy)) { | 4675 if (!parser.PreParseProgram(&scanner, &recorder, allow_lazy)) { |
4689 Top::StackOverflow(); | 4676 Top::StackOverflow(); |
4690 return NULL; | 4677 return NULL; |
4691 } | 4678 } |
4692 // Extract the accumulated data from the recorder as a single | 4679 // Extract the accumulated data from the recorder as a single |
4693 // contiguous vector that we are responsible for disposing. | 4680 // contiguous vector that we are responsible for disposing. |
4694 Vector<unsigned> store = recorder.ExtractData(); | 4681 Vector<unsigned> store = recorder.ExtractData(); |
4695 return new ScriptDataImpl(store); | 4682 return new ScriptDataImpl(store); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4745 Handle<String> source = Handle<String>(String::cast(script->source())); | 4732 Handle<String> source = Handle<String>(String::cast(script->source())); |
4746 result = parser.ParseProgram(source, info->is_global()); | 4733 result = parser.ParseProgram(source, info->is_global()); |
4747 } | 4734 } |
4748 } | 4735 } |
4749 | 4736 |
4750 info->SetFunction(result); | 4737 info->SetFunction(result); |
4751 return (result != NULL); | 4738 return (result != NULL); |
4752 } | 4739 } |
4753 | 4740 |
4754 } } // namespace v8::internal | 4741 } } // namespace v8::internal |
OLD | NEW |