OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 "runtime.h" | 31 #include "runtime.h" |
32 #include "cctest.h" | 32 #include "cctest.h" |
33 | 33 |
34 | 34 |
35 using ::v8::internal::CStrVector; | 35 using ::v8::internal::CStrVector; |
36 using ::v8::internal::Factory; | 36 using ::v8::internal::Factory; |
37 using ::v8::internal::Handle; | 37 using ::v8::internal::Handle; |
38 using ::v8::internal::Heap; | 38 using ::v8::internal::Heap; |
| 39 using ::v8::internal::Isolate; |
39 using ::v8::internal::JSFunction; | 40 using ::v8::internal::JSFunction; |
40 using ::v8::internal::Object; | 41 using ::v8::internal::Object; |
41 using ::v8::internal::Runtime; | 42 using ::v8::internal::Runtime; |
42 using ::v8::internal::Script; | 43 using ::v8::internal::Script; |
43 using ::v8::internal::SmartPointer; | 44 using ::v8::internal::SmartPointer; |
44 using ::v8::internal::SharedFunctionInfo; | 45 using ::v8::internal::SharedFunctionInfo; |
45 using ::v8::internal::String; | 46 using ::v8::internal::String; |
46 | 47 |
47 | 48 |
48 static v8::Persistent<v8::Context> env; | 49 static v8::Persistent<v8::Context> env; |
(...skipping 21 matching lines...) Expand all Loading... |
70 } else { | 71 } else { |
71 shared_function = | 72 shared_function = |
72 Handle<SharedFunctionInfo>(JSFunction::cast(*obj)->shared()); | 73 Handle<SharedFunctionInfo>(JSFunction::cast(*obj)->shared()); |
73 } | 74 } |
74 Handle<Script> i_script(Script::cast(shared_function->script())); | 75 Handle<Script> i_script(Script::cast(shared_function->script())); |
75 CHECK(i_script->source()->IsString()); | 76 CHECK(i_script->source()->IsString()); |
76 Handle<String> script_src(String::cast(i_script->source())); | 77 Handle<String> script_src(String::cast(i_script->source())); |
77 | 78 |
78 // Find the position of a given func source substring in the source. | 79 // Find the position of a given func source substring in the source. |
79 Handle<String> func_pos_str = | 80 Handle<String> func_pos_str = |
80 Factory::NewStringFromAscii(CStrVector(func_pos_src)); | 81 FACTORY->NewStringFromAscii(CStrVector(func_pos_src)); |
81 int func_pos = Runtime::StringMatch(script_src, func_pos_str, 0); | 82 int func_pos = Runtime::StringMatch(Isolate::Current(), |
| 83 script_src, |
| 84 func_pos_str, |
| 85 0); |
82 CHECK_NE(0, func_pos); | 86 CHECK_NE(0, func_pos); |
83 | 87 |
84 #ifdef ENABLE_DEBUGGER_SUPPORT | 88 #ifdef ENABLE_DEBUGGER_SUPPORT |
85 // Obtain SharedFunctionInfo for the function. | 89 // Obtain SharedFunctionInfo for the function. |
86 Object* shared_func_info_ptr = | 90 Object* shared_func_info_ptr = |
87 Runtime::FindSharedFunctionInfoInScript(i_script, func_pos); | 91 Runtime::FindSharedFunctionInfoInScript(Isolate::Current(), |
88 CHECK(shared_func_info_ptr != Heap::undefined_value()); | 92 i_script, |
| 93 func_pos); |
| 94 CHECK(shared_func_info_ptr != HEAP->undefined_value()); |
89 Handle<SharedFunctionInfo> shared_func_info( | 95 Handle<SharedFunctionInfo> shared_func_info( |
90 SharedFunctionInfo::cast(shared_func_info_ptr)); | 96 SharedFunctionInfo::cast(shared_func_info_ptr)); |
91 | 97 |
92 // Verify inferred function name. | 98 // Verify inferred function name. |
93 SmartPointer<char> inferred_name = | 99 SmartPointer<char> inferred_name = |
94 shared_func_info->inferred_name()->ToCString(); | 100 shared_func_info->inferred_name()->ToCString(); |
95 CHECK_EQ(ref_inferred_name, *inferred_name); | 101 CHECK_EQ(ref_inferred_name, *inferred_name); |
96 #endif // ENABLE_DEBUGGER_SUPPORT | 102 #endif // ENABLE_DEBUGGER_SUPPORT |
97 } | 103 } |
98 | 104 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 InitializeVM(); | 274 InitializeVM(); |
269 v8::HandleScope scope; | 275 v8::HandleScope scope; |
270 | 276 |
271 v8::Handle<v8::Script> script = Compile( | 277 v8::Handle<v8::Script> script = Compile( |
272 "function a() {\n" | 278 "function a() {\n" |
273 "var result = function(p,a,c,k,e,d)" | 279 "var result = function(p,a,c,k,e,d)" |
274 "{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n" | 280 "{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n" |
275 "}"); | 281 "}"); |
276 CheckFunctionName(script, "return p", ""); | 282 CheckFunctionName(script, "return p", ""); |
277 } | 283 } |
OLD | NEW |