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 23 matching lines...) Expand all Loading... |
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::Isolate; |
40 using ::v8::internal::JSFunction; | 40 using ::v8::internal::JSFunction; |
41 using ::v8::internal::Object; | 41 using ::v8::internal::Object; |
42 using ::v8::internal::Runtime; | 42 using ::v8::internal::Runtime; |
43 using ::v8::internal::Script; | 43 using ::v8::internal::Script; |
44 using ::v8::internal::SmartPointer; | 44 using ::v8::internal::SmartArrayPointer; |
45 using ::v8::internal::SharedFunctionInfo; | 45 using ::v8::internal::SharedFunctionInfo; |
46 using ::v8::internal::String; | 46 using ::v8::internal::String; |
47 | 47 |
48 | 48 |
49 static v8::Persistent<v8::Context> env; | 49 static v8::Persistent<v8::Context> env; |
50 | 50 |
51 | 51 |
52 static void InitializeVM() { | 52 static void InitializeVM() { |
53 if (env.IsEmpty()) { | 53 if (env.IsEmpty()) { |
54 v8::HandleScope scope; | 54 v8::HandleScope scope; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Obtain SharedFunctionInfo for the function. | 89 // Obtain SharedFunctionInfo for the function. |
90 Object* shared_func_info_ptr = | 90 Object* shared_func_info_ptr = |
91 Runtime::FindSharedFunctionInfoInScript(Isolate::Current(), | 91 Runtime::FindSharedFunctionInfoInScript(Isolate::Current(), |
92 i_script, | 92 i_script, |
93 func_pos); | 93 func_pos); |
94 CHECK(shared_func_info_ptr != HEAP->undefined_value()); | 94 CHECK(shared_func_info_ptr != HEAP->undefined_value()); |
95 Handle<SharedFunctionInfo> shared_func_info( | 95 Handle<SharedFunctionInfo> shared_func_info( |
96 SharedFunctionInfo::cast(shared_func_info_ptr)); | 96 SharedFunctionInfo::cast(shared_func_info_ptr)); |
97 | 97 |
98 // Verify inferred function name. | 98 // Verify inferred function name. |
99 SmartPointer<char> inferred_name = | 99 SmartArrayPointer<char> inferred_name = |
100 shared_func_info->inferred_name()->ToCString(); | 100 shared_func_info->inferred_name()->ToCString(); |
101 CHECK_EQ(ref_inferred_name, *inferred_name); | 101 CHECK_EQ(ref_inferred_name, *inferred_name); |
102 #endif // ENABLE_DEBUGGER_SUPPORT | 102 #endif // ENABLE_DEBUGGER_SUPPORT |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 static v8::Handle<v8::Script> Compile(const char* src) { | 106 static v8::Handle<v8::Script> Compile(const char* src) { |
107 return v8::Script::Compile(v8::String::New(src)); | 107 return v8::Script::Compile(v8::String::New(src)); |
108 } | 108 } |
109 | 109 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 v8::Handle<v8::Script> script = Compile( | 355 v8::Handle<v8::Script> script = Compile( |
356 "function createMyObj() {\n" | 356 "function createMyObj() {\n" |
357 " var obj = {};\n" | 357 " var obj = {};\n" |
358 " obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n" | 358 " obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n" |
359 " return obj;\n" | 359 " return obj;\n" |
360 "}"); | 360 "}"); |
361 // Can't infer the function name statically. | 361 // Can't infer the function name statically. |
362 CheckFunctionName(script, "return 1", "obj.(anonymous function)"); | 362 CheckFunctionName(script, "return 1", "obj.(anonymous function)"); |
363 } | 363 } |
OLD | NEW |