Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 11114f9c04d007dc7c4309a23b43230135fbfedd..64a67ba134d2a541804a355f55d7498b7d14b45f 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -13361,6 +13361,10 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) { |
return NativeCodeFunctionSourceString(shared_info); |
} |
+ if (FLAG_harmony_function_tostring) { |
+ return Handle<String>::cast(shared_info->GetSourceCodeHarmony()); |
+ } |
+ |
IncrementalStringBuilder builder(isolate); |
FunctionKind kind = shared_info->kind(); |
if (!IsArrowFunction(kind)) { |
@@ -13799,6 +13803,15 @@ Handle<Object> SharedFunctionInfo::GetSourceCode() { |
source, start_position(), end_position()); |
} |
+Handle<Object> SharedFunctionInfo::GetSourceCodeHarmony() { |
+ Isolate* isolate = GetIsolate(); |
+ if (!HasSourceCode()) return isolate->factory()->undefined_value(); |
+ Handle<String> script_source(String::cast(Script::cast(script())->source())); |
+ int start_pos = function_token_position(); |
+ if (start_pos == kNoSourcePosition) start_pos = start_position(); |
+ return isolate->factory()->NewSubString(script_source, start_pos, |
+ end_position()); |
+} |
bool SharedFunctionInfo::IsInlineable() { |
// Check that the function has a script associated with it. |