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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 // the block could be lazily compiled, and an extra, unexpected, | 342 // the block could be lazily compiled, and an extra, unexpected, |
343 // entry was added to the data. | 343 // entry was added to the data. |
344 int marker; | 344 int marker; |
345 i::Isolate::Current()->stack_guard()->SetStackLimit( | 345 i::Isolate::Current()->stack_guard()->SetStackLimit( |
346 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | 346 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); |
347 | 347 |
348 const char* program = | 348 const char* program = |
349 "try { } catch (e) { var foo = function () { /* first */ } }" | 349 "try { } catch (e) { var foo = function () { /* first */ } }" |
350 "var bar = function () { /* second */ }"; | 350 "var bar = function () { /* second */ }"; |
351 | 351 |
352 i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), | 352 v8::HandleScope handles; |
353 static_cast<unsigned>(strlen(program))); | 353 i::Handle<i::String> source( |
354 i::ScriptDataImpl* data = | 354 FACTORY->NewStringFromAscii(i::CStrVector(program))); |
355 i::ParserApi::PartialPreParse(&stream, NULL, false); | 355 i::ScriptDataImpl* data = i::ParserApi::PartialPreParse(source, NULL, false); |
356 CHECK(!data->HasError()); | 356 CHECK(!data->HasError()); |
357 | 357 |
358 data->Initialize(); | 358 data->Initialize(); |
359 | 359 |
360 int first_function = | 360 int first_function = |
361 static_cast<int>(strstr(program, "function") - program); | 361 static_cast<int>(strstr(program, "function") - program); |
362 int first_lbrace = first_function + static_cast<int>(strlen("function () ")); | 362 int first_lbrace = first_function + static_cast<int>(strlen("function () ")); |
363 CHECK_EQ('{', program[first_lbrace]); | 363 CHECK_EQ('{', program[first_lbrace]); |
364 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace); | 364 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace); |
365 CHECK(!entry1.is_valid()); | 365 CHECK(!entry1.is_valid()); |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 CHECK_EQ(scope->inner_scopes()->length(), 1); | 870 CHECK_EQ(scope->inner_scopes()->length(), 1); |
871 | 871 |
872 i::Scope* inner_scope = scope->inner_scopes()->at(0); | 872 i::Scope* inner_scope = scope->inner_scopes()->at(0); |
873 CHECK_EQ(inner_scope->type(), source_data[i].scope_type); | 873 CHECK_EQ(inner_scope->type(), source_data[i].scope_type); |
874 CHECK_EQ(inner_scope->start_position(), kPrefixLen); | 874 CHECK_EQ(inner_scope->start_position(), kPrefixLen); |
875 // The end position of a token is one position after the last | 875 // The end position of a token is one position after the last |
876 // character belonging to that token. | 876 // character belonging to that token. |
877 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); | 877 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); |
878 } | 878 } |
879 } | 879 } |
OLD | NEW |