diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-11 13:45:28 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-11 13:45:28 +0200 |
commit | d6a599dbc9d824a462b2b206316e102bf8136446 (patch) | |
tree | ecb257a5e55b2239d74b90fdad62fccd661cf286 /Source/JavaScriptCore/interpreter/Interpreter.h | |
parent | 3ccc3a85f09a83557b391aae380d3bf5f81a2911 (diff) | |
download | qtwebkit-d6a599dbc9d824a462b2b206316e102bf8136446.tar.gz |
Imported WebKit commit 8ff1f22783a32de82fee915abd55bd1b298f2644 (http://svn.webkit.org/repository/webkit/trunk@122325)
New snapshot that should work with the latest Qt build system changes
Diffstat (limited to 'Source/JavaScriptCore/interpreter/Interpreter.h')
-rw-r--r-- | Source/JavaScriptCore/interpreter/Interpreter.h | 78 |
1 files changed, 49 insertions, 29 deletions
diff --git a/Source/JavaScriptCore/interpreter/Interpreter.h b/Source/JavaScriptCore/interpreter/Interpreter.h index adb23f237..ba2f4fac4 100644 --- a/Source/JavaScriptCore/interpreter/Interpreter.h +++ b/Source/JavaScriptCore/interpreter/Interpreter.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2012 Research In Motion Limited. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,6 +40,7 @@ #include "RegisterFile.h" #include <wtf/HashMap.h> +#include <wtf/text/StringBuilder.h> namespace JSC { @@ -80,45 +82,63 @@ namespace JSC { UString sourceURL; UString toString(CallFrame* callFrame) const { - bool hasSourceURLInfo = !sourceURL.isNull() && !sourceURL.isEmpty(); - bool hasLineInfo = line > -1; + StringBuilder traceBuild; + String functionName = friendlyFunctionName(callFrame); + String sourceURL = friendlySourceURL(); + traceBuild.append(functionName); + if (!sourceURL.isEmpty()) { + if (!functionName.isEmpty()) + traceBuild.append('@'); + traceBuild.append(sourceURL); + if (line > -1) { + traceBuild.append(':'); + traceBuild.append(String::number(line)); + } + } + return traceBuild.toString().impl(); + } + String friendlySourceURL() const + { String traceLine; - JSObject* stackFrameCallee = callee.get(); switch (codeType) { case StackFrameEvalCode: - if (hasSourceURLInfo) { - traceLine = hasLineInfo ? String::format("eval code@%s:%d", sourceURL.ascii().data(), line) - : String::format("eval code@%s", sourceURL.ascii().data()); - } else - traceLine = String::format("eval code"); + case StackFrameFunctionCode: + case StackFrameGlobalCode: + if (!sourceURL.isEmpty()) + traceLine = sourceURL.impl(); break; - case StackFrameNativeCode: { - if (callee) { - UString functionName = getCalculatedDisplayName(callFrame, stackFrameCallee); - traceLine = String::format("%s@[native code]", functionName.ascii().data()); - } else - traceLine = "[native code]"; + case StackFrameNativeCode: + traceLine = "[native code]"; break; } - case StackFrameFunctionCode: { - UString functionName = getCalculatedDisplayName(callFrame, stackFrameCallee); - if (hasSourceURLInfo) { - traceLine = hasLineInfo ? String::format("%s@%s:%d", functionName.ascii().data(), sourceURL.ascii().data(), line) - : String::format("%s@%s", functionName.ascii().data(), sourceURL.ascii().data()); - } else - traceLine = String::format("%s\n", functionName.ascii().data()); + return traceLine.isNull() ? emptyString() : traceLine; + } + String friendlyFunctionName(CallFrame* callFrame) const + { + String traceLine; + JSObject* stackFrameCallee = callee.get(); + + switch (codeType) { + case StackFrameEvalCode: + traceLine = "eval code"; + break; + case StackFrameNativeCode: + if (callee) + traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl(); + break; + case StackFrameFunctionCode: + traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl(); break; - } case StackFrameGlobalCode: - if (hasSourceURLInfo) { - traceLine = hasLineInfo ? String::format("global code@%s:%d", sourceURL.ascii().data(), line) - : String::format("global code@%s", sourceURL.ascii().data()); - } else - traceLine = String::format("global code"); - + traceLine = "global code"; + break; } - return traceLine.impl(); + return traceLine.isNull() ? emptyString() : traceLine; + } + unsigned friendlyLineNumber() const + { + return line > -1 ? line : 0; } }; |