Commit dec8c517 authored by timothy@apple.com's avatar timothy@apple.com

Adds a JavaScriptCallFrame object and JavaScript binding with an IDL.

This object will expose the stack to the Inspector's debugger.

Reviewed by Adam Roben.

* DerivedSources.make: Add JavaScriptCallFrame.
* bindings/js/JSJavaScriptCallFrameCustom.cpp: Added.
(WebCore::JSJavaScriptCallFrame::evaluate): Calls impl evaluate and returns the result.
(WebCore::JSJavaScriptCallFrame::scopeChain): Makes an array of the ScopeChain.
* page/JavaScriptCallFrame.cpp: Added.
(WebCore::JavaScriptCallFrame::JavaScriptCallFrame):
(WebCore::JavaScriptCallFrame::caller): Returns m_caller.
(WebCore::JavaScriptCallFrame::functionName): Returns the function
name from the ExecState if this is not global code or anonymous.
(WebCore::JavaScriptCallFrame::evaluate): Evaluates a script string
in the scope of the call frame.
* page/JavaScriptCallFrame.h: Added.
(WebCore::JavaScriptCallFrame::create): Call the ctor can return in a PassRefPtr.
(WebCore::JavaScriptCallFrame::invalidate): Sets m_mexec to 0. This prevents a
stale ExecState from being accessed after the lifetime of the ExecState.
(WebCore::JavaScriptCallFrame::isValid): Checks if m_exec is 0.
(WebCore::JavaScriptCallFrame::execState): Returns m_exec.
(WebCore::JavaScriptCallFrame::sourceIdentifier): Returns m_sourceID.
(WebCore::JavaScriptCallFrame::line): Returns m_line.
(WebCore::JavaScriptCallFrame::setLine): Sets m_line.
(WebCore::JavaScriptCallFrame::scopeChain): Returns by reference m_exec->scopeChain().
* page/JavaScriptCallFrame.idl: Added.
* WebCore.xcodeproj/project.pbxproj: Add new files.
* WebCore.vcproj/WebCore.vcproj: Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33397 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9dd70d13
2008-05-13 Timothy Hatcher <timothy@apple.com>
Adds a JavaScriptCallFrame object and JavaScript binding with an IDL.
This object will expose the stack to the Inspector's debugger.
Reviewed by Adam Roben.
* DerivedSources.make: Add JavaScriptCallFrame.
* bindings/js/JSJavaScriptCallFrameCustom.cpp: Added.
(WebCore::JSJavaScriptCallFrame::evaluate): Calls impl evaluate and returns the result.
(WebCore::JSJavaScriptCallFrame::scopeChain): Makes an array of the ScopeChain.
* page/JavaScriptCallFrame.cpp: Added.
(WebCore::JavaScriptCallFrame::JavaScriptCallFrame):
(WebCore::JavaScriptCallFrame::caller): Returns m_caller.
(WebCore::JavaScriptCallFrame::functionName): Returns the function
name from the ExecState if this is not global code or anonymous.
(WebCore::JavaScriptCallFrame::evaluate): Evaluates a script string
in the scope of the call frame.
* page/JavaScriptCallFrame.h: Added.
(WebCore::JavaScriptCallFrame::create): Call the ctor can return in a PassRefPtr.
(WebCore::JavaScriptCallFrame::invalidate): Sets m_mexec to 0. This prevents a
stale ExecState from being accessed after the lifetime of the ExecState.
(WebCore::JavaScriptCallFrame::isValid): Checks if m_exec is 0.
(WebCore::JavaScriptCallFrame::execState): Returns m_exec.
(WebCore::JavaScriptCallFrame::sourceIdentifier): Returns m_sourceID.
(WebCore::JavaScriptCallFrame::line): Returns m_line.
(WebCore::JavaScriptCallFrame::setLine): Sets m_line.
(WebCore::JavaScriptCallFrame::scopeChain): Returns by reference m_exec->scopeChain().
* page/JavaScriptCallFrame.idl: Added.
* WebCore.xcodeproj/project.pbxproj: Add new files.
* WebCore.vcproj/WebCore.vcproj: Ditto.
2008-05-13 Timothy Hatcher <timothy@apple.com>
Add a new WebInspector.Object base class that will be used for
......@@ -359,6 +359,8 @@ all : \
JSEventTargetBase.lut.h \
JSRGBColor.lut.h \
\
JSJavaScriptCallFrame.h \
\
JSHTMLInputElementBaseTable.cpp \
\
CSSGrammar.cpp \
......
......@@ -1419,6 +1419,14 @@
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSImageData.h"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSJavaScriptCallFrame.cpp"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSJavaScriptCallFrame.h"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSKeyboardEvent.cpp"
>
......@@ -3339,6 +3347,22 @@
RelativePath="..\page\InspectorController.h"
>
</File>
<File
RelativePath="..\page\JavaScriptCallFrame.cpp"
>
<FileConfiguration
Name="Release_PGO|Win32"
>
<Tool
Name="VCCLCompilerTool"
WholeProgramOptimization="true"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\page\JavaScriptCallFrame.h"
>
</File>
<File
RelativePath="..\page\JavaScriptDebugListener.h"
>
......@@ -13586,6 +13610,10 @@
RelativePath="..\bindings\js\JSInspectorCallbackWrapper.h"
>
</File>
<File
RelativePath="..\bindings\js\JSJavaScriptCallFrameCustom.cpp"
>
</File>
<File
RelativePath="..\bindings\js\JSLocationCustom.cpp"
>
......
......@@ -338,6 +338,11 @@
1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */; };
1C4C8F020AD85D87009475CE /* DeleteButtonController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4C8F000AD85D87009475CE /* DeleteButtonController.h */; };
1C4C8F660AD8655D009475CE /* DeleteButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4C8F640AD8655D009475CE /* DeleteButton.h */; };
1C5FAED10DCFD90100D58F78 /* JSJavaScriptCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C5FAECF0DCFD90100D58F78 /* JSJavaScriptCallFrame.cpp */; };
1C5FAED20DCFD90100D58F78 /* JSJavaScriptCallFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5FAED00DCFD90100D58F78 /* JSJavaScriptCallFrame.h */; };
1C5FAEE70DCFDA6800D58F78 /* JSJavaScriptCallFrameCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C5FAEE60DCFDA6800D58F78 /* JSJavaScriptCallFrameCustom.cpp */; };
1CA19CAE0DC1145F0065A994 /* JavaScriptCallFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA19CAC0DC1145F0065A994 /* JavaScriptCallFrame.h */; };
1CA19CAF0DC1145F0065A994 /* JavaScriptCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CA19CAD0DC1145F0065A994 /* JavaScriptCallFrame.cpp */; };
1CAF34810A6C405200ABE06E /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF347E0A6C405200ABE06E /* WebScriptObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
1CAF34820A6C405200ABE06E /* WebScriptObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF347F0A6C405200ABE06E /* WebScriptObject.mm */; };
1CAF34830A6C405200ABE06E /* WebScriptObjectPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF34800A6C405200ABE06E /* WebScriptObjectPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -4802,7 +4807,13 @@
1C4C8F000AD85D87009475CE /* DeleteButtonController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeleteButtonController.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C4C8F630AD8655D009475CE /* DeleteButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeleteButton.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C4C8F640AD8655D009475CE /* DeleteButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeleteButton.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C5FAE510DCFC7A300D58F78 /* JavaScriptCallFrame.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = JavaScriptCallFrame.idl; sourceTree = "<group>"; };
1C5FAECF0DCFD90100D58F78 /* JSJavaScriptCallFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSJavaScriptCallFrame.cpp; sourceTree = "<group>"; };
1C5FAED00DCFD90100D58F78 /* JSJavaScriptCallFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSJavaScriptCallFrame.h; sourceTree = "<group>"; };
1C5FAEE60DCFDA6800D58F78 /* JSJavaScriptCallFrameCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSJavaScriptCallFrameCustom.cpp; sourceTree = "<group>"; };
1C904DF90BA9D2C80081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
1CA19CAC0DC1145F0065A994 /* JavaScriptCallFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptCallFrame.h; sourceTree = "<group>"; };
1CA19CAD0DC1145F0065A994 /* JavaScriptCallFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JavaScriptCallFrame.cpp; sourceTree = "<group>"; };
1CAF347E0A6C405200ABE06E /* WebScriptObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObject.h; sourceTree = "<group>"; };
1CAF347F0A6C405200ABE06E /* WebScriptObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptObject.mm; sourceTree = "<group>"; };
1CAF34800A6C405200ABE06E /* WebScriptObjectPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObjectPrivate.h; sourceTree = "<group>"; };
......@@ -8474,6 +8485,7 @@
A83B790E0CCAFF97000B0825 /* CSS */,
A83B79120CCB003F000B0825 /* Events */,
A83B79080CCAFF2B000B0825 /* HTML */,
1C5FAECA0DCFD8C900D58F78 /* Inspector */,
1AC226020DB69EA70089B669 /* Offline */,
BC9854460CD3DA5F00069BC1 /* Ranges */,
A83B79150CCB0078000B0825 /* Storage */,
......@@ -8699,6 +8711,15 @@
tabWidth = 8;
usesTabs = 0;
};
1C5FAECA0DCFD8C900D58F78 /* Inspector */ = {
isa = PBXGroup;
children = (
1C5FAECF0DCFD90100D58F78 /* JSJavaScriptCallFrame.cpp */,
1C5FAED00DCFD90100D58F78 /* JSJavaScriptCallFrame.h */,
);
name = Inspector;
sourceTree = "<group>";
};
1CDD44660BA9C80000F90147 /* Configurations */ = {
isa = PBXGroup;
children = (
......@@ -9023,6 +9044,9 @@
06693DB70BFBA2F400216072 /* InspectorClient.h */,
06693DB80BFBA2F400216072 /* InspectorController.cpp */,
06693DB90BFBA2F400216072 /* InspectorController.h */,
1CA19CAD0DC1145F0065A994 /* JavaScriptCallFrame.cpp */,
1CA19CAC0DC1145F0065A994 /* JavaScriptCallFrame.h */,
1C5FAE510DCFC7A300D58F78 /* JavaScriptCallFrame.idl */,
C02B14BF0D81E02A00D8A970 /* JavaScriptDebugListener.h */,
C02B14C00D81E02A00D8A970 /* JavaScriptDebugServer.cpp */,
C02B14C10D81E02A00D8A970 /* JavaScriptDebugServer.h */,
......@@ -12214,6 +12238,7 @@
448AD27A0A4813790023D179 /* JSHTMLOptionsCollectionCustom.cpp */,
BC17F9650B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp */,
AB4CB4EA0B8BDA3D009F40B0 /* JSHTMLSelectElementCustom.h */,
1C5FAEE60DCFDA6800D58F78 /* JSJavaScriptCallFrameCustom.cpp */,
BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */,
A9C6E6460D7465CA006442E9 /* JSMimeTypeArrayCustom.cpp */,
BCD9C25F0C17AA67005C90A2 /* JSNamedNodeMapCustom.cpp */,
......@@ -15029,6 +15054,7 @@
F916C48E0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.h in Headers */,
BCD0FC4F0DBD720B00B2F630 /* DOMRGBColorInternal.h in Headers */,
BC99812E0DBE807A008CE9EF /* DOMAbstractViewFrame.h in Headers */,
1CA19CAE0DC1145F0065A994 /* JavaScriptCallFrame.h in Headers */,
511F23180DC160DA004F0032 /* LocalStorageTask.h in Headers */,
511F231A0DC160DA004F0032 /* LocalStorageThread.h in Headers */,
BC5A12E00DC0414800C9AFAD /* CSSReflectValue.h in Headers */,
......@@ -15039,6 +15065,7 @@
BCEFE1EB0DCA5F6400739219 /* JSXSLTProcessor.h in Headers */,
BCE99EC40DCA624100182683 /* JSXSLTProcessorConstructor.h in Headers */,
BCBFB53D0DCD29CF0019B3E5 /* JSDOMWindowShell.h in Headers */,
1C5FAED20DCFD90100D58F78 /* JSJavaScriptCallFrame.h in Headers */,
2999869E0DD0DEEA00F8D261 /* AccessibilityListBoxOption.h in Headers */,
299986A00DD0DEEA00F8D261 /* AccessibilityListBox.h in Headers */,
BC34C33B0DD607DE00090123 /* AccessControlList.h in Headers */,
......@@ -16740,6 +16767,7 @@
F9F0ED790DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.cpp in Sources */,
F916C48D0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.cpp in Sources */,
BCD0FBD00DBD625E00B2F630 /* DOMAbstractView.mm in Sources */,
1CA19CAF0DC1145F0065A994 /* JavaScriptCallFrame.cpp in Sources */,
511F23170DC160DA004F0032 /* LocalStorageTask.cpp in Sources */,
511F23190DC160DA004F0032 /* LocalStorageThread.cpp in Sources */,
BC5A12DF0DC0414800C9AFAD /* CSSReflectValue.cpp in Sources */,
......@@ -16750,6 +16778,8 @@
BCEFE1EA0DCA5F6400739219 /* JSXSLTProcessor.cpp in Sources */,
BCE99EC30DCA624100182683 /* JSXSLTProcessorConstructor.cpp in Sources */,
BCBFB53C0DCD29CF0019B3E5 /* JSDOMWindowShell.cpp in Sources */,
1C5FAED10DCFD90100D58F78 /* JSJavaScriptCallFrame.cpp in Sources */,
1C5FAEE70DCFDA6800D58F78 /* JSJavaScriptCallFrameCustom.cpp in Sources */,
2999869F0DD0DEEA00F8D261 /* AccessibilityListBoxOption.cpp in Sources */,
299986A10DD0DEEA00F8D261 /* AccessibilityListBox.cpp in Sources */,
BC34C33A0DD607DE00090123 /* AccessControlList.cpp in Sources */,
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "JSJavaScriptCallFrame.h"
#include "JavaScriptCallFrame.h"
#include <kjs/array_object.h>
using namespace KJS;
namespace WebCore {
JSValue* JSJavaScriptCallFrame::evaluate(ExecState* exec, const List& args)
{
if (!impl()->isValid())
return jsNull();
return impl()->evaluate(args[0]->toString(exec));
}
JSValue* JSJavaScriptCallFrame::scopeChain(ExecState* exec) const
{
if (!impl()->isValid())
return jsNull();
const ScopeChain& chain = impl()->scopeChain();
ScopeChainIterator iter = chain.begin();
ScopeChainIterator end = chain.end();
// we must always have something in the scope chain
ASSERT(iter != end);
List list;
do {
list.append(*iter);
++iter;
} while (iter != end);
return exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, list);
}
} // namespace WebCore
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "JavaScriptCallFrame.h"
#include "PlatformString.h"
#include <kjs/JSGlobalObject.h>
#include <kjs/interpreter.h>
#include <kjs/object.h>
#include <kjs/value.h>
using namespace KJS;
namespace WebCore {
JavaScriptCallFrame::JavaScriptCallFrame(ExecState* exec, PassRefPtr<JavaScriptCallFrame> caller, int sourceID, int line)
: m_exec(exec)
, m_caller(caller)
, m_sourceID(sourceID)
, m_line(line)
{
}
JavaScriptCallFrame* JavaScriptCallFrame::caller()
{
return m_caller.get();
}
String JavaScriptCallFrame::functionName() const
{
if (!m_exec || !m_exec->scopeNode())
return String();
FunctionImp* function = m_exec->function();
if (!function)
return String();
return String(function->functionName());
}
// Evaluate some JavaScript code in the context of this frame.
// The code is evaluated as if by "eval", and the result is returned.
// If there is an (uncaught) exception, it is returned as though _it_ were the result.
// FIXME: If "script" contains var declarations, the machinery to handle local variables
// efficiently in JavaScriptCore will not work properly. This could lead to crashes or
// incorrect variable values. So this is not appropriate for evaluating arbitrary scripts.
JSValue* JavaScriptCallFrame::evaluate(const UString& script) const
{
if (!m_exec)
return jsNull();
JSLock lock;
ExecState* exec = m_exec;
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
// find "eval"
JSObject* eval = 0;
if (exec->scopeNode()) { // "eval" won't work without context (i.e. at global scope)
JSValue* v = globalObject->get(exec, "eval");
if (v->isObject() && static_cast<JSObject*>(v)->implementsCall())
eval = static_cast<JSObject*>(v);
else
// no "eval" - fallback operates on global exec state
exec = globalObject->globalExec();
}
JSValue* savedException = exec->exception();
exec->clearException();
// evaluate
JSValue* result = 0;
if (eval) {
List args;
args.append(jsString(script));
result = eval->call(exec, 0, args);
} else
// no "eval", or no context (i.e. global scope) - use global fallback
result = Interpreter::evaluate(exec, UString(), 0, script.data(), script.size(), globalObject).value();
if (exec->hadException())
result = exec->exception(); // (may be redundant depending on which eval path was used)
exec->setException(savedException);
return result;
}
} // namespace WebCore
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef JavaScriptCallFrame_h
#define JavaScriptCallFrame_h
#include <kjs/ExecState.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace WebCore {
class String;
class JavaScriptCallFrame : public RefCounted<JavaScriptCallFrame> {
public:
static PassRefPtr<JavaScriptCallFrame> create(KJS::ExecState* exec, PassRefPtr<JavaScriptCallFrame> caller, int sourceID, int line) { return adoptRef(new JavaScriptCallFrame(exec, caller, sourceID, line)); }
void invalidate() { m_exec = 0; }
bool isValid() const { return !!m_exec; }
KJS::ExecState* execState() const { return m_exec; }
JavaScriptCallFrame* caller();
int sourceIdentifier() const { return m_sourceID; }
int line() const { return m_line; }
void setLine(int line) { m_line = line; }
String functionName() const;
const KJS::ScopeChain& scopeChain() const { return m_exec->scopeChain(); }
KJS::JSValue* evaluate(const KJS::UString& script) const;
private:
JavaScriptCallFrame(KJS::ExecState*, PassRefPtr<JavaScriptCallFrame> caller, int sourceID, int line);
KJS::ExecState* m_exec;
RefPtr<JavaScriptCallFrame> m_caller;
int m_sourceID;
int m_line;
};
} // namespace WebCore
#endif // JavaScriptCallFrame_h
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
module inspector {
interface JavaScriptCallFrame {
[Custom] void evaluate(in DOMString script);
readonly attribute JavaScriptCallFrame caller;
readonly attribute long sourceIdentifier;
readonly attribute long line;
readonly attribute [CustomGetter] Array scopeChain;
readonly attribute DOMString functionName;
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment