| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 v8::HandleScope scope; | 56 v8::HandleScope scope; |
| 57 env->Enter(); | 57 env->Enter(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 static void CheckFunctionName(v8::Handle<v8::Script> script, | 61 static void CheckFunctionName(v8::Handle<v8::Script> script, |
| 62 const char* func_pos_src, | 62 const char* func_pos_src, |
| 63 const char* ref_inferred_name) { | 63 const char* ref_inferred_name) { |
| 64 // Get script source. | 64 // Get script source. |
| 65 Handle<JSFunction> fun = v8::Utils::OpenHandle(*script); | 65 Handle<Object> obj = v8::Utils::OpenHandle(*script); |
| 66 Handle<Script> i_script(Script::cast(fun->shared()->script())); | 66 Handle<SharedFunctionInfo> shared_function; |
| 67 if (obj->IsSharedFunctionInfo()) { |
| 68 shared_function = |
| 69 Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(*obj)); |
| 70 } else { |
| 71 shared_function = |
| 72 Handle<SharedFunctionInfo>(JSFunction::cast(*obj)->shared()); |
| 73 } |
| 74 Handle<Script> i_script(Script::cast(shared_function->script())); |
| 67 CHECK(i_script->source()->IsString()); | 75 CHECK(i_script->source()->IsString()); |
| 68 Handle<String> script_src(String::cast(i_script->source())); | 76 Handle<String> script_src(String::cast(i_script->source())); |
| 69 | 77 |
| 70 // Find the position of a given func source substring in the source. | 78 // Find the position of a given func source substring in the source. |
| 71 Handle<String> func_pos_str = | 79 Handle<String> func_pos_str = |
| 72 Factory::NewStringFromAscii(CStrVector(func_pos_src)); | 80 Factory::NewStringFromAscii(CStrVector(func_pos_src)); |
| 73 int func_pos = Runtime::StringMatch(script_src, func_pos_str, 0); | 81 int func_pos = Runtime::StringMatch(script_src, func_pos_str, 0); |
| 74 CHECK_NE(0, func_pos); | 82 CHECK_NE(0, func_pos); |
| 75 | 83 |
| 76 // Obtain SharedFunctionInfo for the function. | 84 // Obtain SharedFunctionInfo for the function. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 InitializeVM(); | 266 InitializeVM(); |
| 259 v8::HandleScope scope; | 267 v8::HandleScope scope; |
| 260 | 268 |
| 261 v8::Handle<v8::Script> script = Compile( | 269 v8::Handle<v8::Script> script = Compile( |
| 262 "function a() {\n" | 270 "function a() {\n" |
| 263 "var result = function(p,a,c,k,e,d)" | 271 "var result = function(p,a,c,k,e,d)" |
| 264 "{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n" | 272 "{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n" |
| 265 "}"); | 273 "}"); |
| 266 CheckFunctionName(script, "return p", ""); | 274 CheckFunctionName(script, "return p", ""); |
| 267 } | 275 } |
| OLD | NEW |