}
-static StaticResource<SafeStringInputBuffer> safe_string_input_buffer;
-
-
Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
Handle<Object> script_name,
int line_offset,
// No cache entry found. Do pre-parsing and compile the script.
ScriptDataImpl* pre_data = input_pre_data;
if (pre_data == NULL && source_length >= FLAG_min_preparse_length) {
- Access<SafeStringInputBuffer> buf(&safe_string_input_buffer);
- buf->Reset(source.location());
- pre_data = PreParse(source, buf.value(), extension);
+ pre_data = PreParse(source, NULL, extension);
}
// Create a script object describing the script to be compiled.
void Scanner::Initialize(Handle<String> source,
ParserLanguage language) {
- safe_string_input_buffer_.Reset(source.location());
- Init(source, &safe_string_input_buffer_, 0, source->length(), language);
+ Init(source, NULL, 0, source->length(), language);
}
int start_position,
int end_position,
ParserLanguage language) {
- safe_string_input_buffer_.Reset(source.location());
- Init(source, &safe_string_input_buffer_,
- start_position, end_position, language);
+ Init(source, NULL, start_position, end_position, language);
}
int start_position,
int end_position,
ParserLanguage language) {
+ // Either initialize the scanner from a character stream or from a
+ // string.
+ ASSERT(source.is_null() || stream == NULL);
+
// Initialize the source buffer.
if (!source.is_null() && StringShape(*source).IsExternalTwoByte()) {
two_byte_string_buffer_.Initialize(
end_position);
source_ = &ascii_string_buffer_;
} else {
+ if (!source.is_null()) {
+ safe_string_input_buffer_.Reset(source.location());
+ stream = &safe_string_input_buffer_;
+ }
char_stream_buffer_.Initialize(source,
stream,
start_position,
v8::HandleScope scope;
const char* cstring = "function foo(a) { return a+1; }";
+
v8::ScriptData* sd_from_cstring =
v8::ScriptData::PreCompile(cstring, i::StrLength(cstring));
TestAsciiResource* resource = new TestAsciiResource(cstring);
- v8::ScriptData* sd_from_istring = v8::ScriptData::PreCompile(
+ v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile(
v8::String::NewExternal(resource));
- CHECK_EQ(sd_from_cstring->Length(), sd_from_istring->Length());
+ v8::ScriptData* sd_from_string = v8::ScriptData::PreCompile(
+ v8::String::New(cstring));
+
+ CHECK_EQ(sd_from_cstring->Length(), sd_from_external_string->Length());
+ CHECK_EQ(0, memcmp(sd_from_cstring->Data(),
+ sd_from_external_string->Data(),
+ sd_from_cstring->Length()));
+
+ CHECK_EQ(sd_from_cstring->Length(), sd_from_string->Length());
CHECK_EQ(0, memcmp(sd_from_cstring->Data(),
- sd_from_istring->Data(),
+ sd_from_string->Data(),
sd_from_cstring->Length()));
+
delete sd_from_cstring;
- delete sd_from_istring;
+ delete sd_from_external_string;
+ delete sd_from_string;
}