code()->ShortPrint(out);
if (HasSourceCode()) {
PrintF(out, "\n - source code = ");
- GetSourceCode()->ShortPrint(out);
+ String* source = String::cast(Script::cast(script())->source());
+ int start = start_position();
+ int length = end_position() - start;
+ SmartArrayPointer<char> source_string =
+ source->ToCString(DISALLOW_NULLS,
+ FAST_STRING_TRAVERSAL,
+ start, length, NULL);
+ PrintF(out, "%s", *source_string);
}
// Script files are often large, hard to read.
// PrintF(out, "\n - script =");
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString());
}
+
+
+#ifdef OBJECT_PRINT
+TEST(PrintSharedFunctionInfo) {
+ InitializeVM();
+ v8::HandleScope scope;
+ const char* source = "f = function() { return 987654321; }\n"
+ "g = function() { return 123456789; }\n";
+ CompileRun(source);
+ Handle<JSFunction> g =
+ v8::Utils::OpenHandle(
+ *v8::Handle<v8::Function>::Cast(
+ v8::Context::GetCurrent()->Global()->Get(v8_str("g"))));
+
+ AssertNoAllocation no_alloc;
+ g->shared()->PrintLn();
+}
+#endif // OBJECT_PRINT