source: webkit/trunk/JavaScriptCore/kjs/DebuggerCallFrame.cpp@ 34634

Last change on this file since 34634 was 34634, checked in by [email protected], 17 years ago

Use accurate call frame title's based on the call frame type.
Added a type to DebuggerCallFrame so the under interface can
distinguish anonymous functions and program call frames.

JavaScriptCore:

2008-06-16 Timothy Hatcher <[email protected]>

Added a type to DebuggerCallFrame so the under interface can
distinguish anonymous functions and program call frames.

https://bugs.webkit.org/show_bug.cgi?id=19585

Reviewed by Geoff Garen.

  • JavaScriptCore.exp: Export the DebuggerCallFrame::type symbol.
  • kjs/DebuggerCallFrame.cpp: (KJS::DebuggerCallFrame::type): Added.
  • kjs/DebuggerCallFrame.h:

WebCore:

2008-06-16 Timothy Hatcher <[email protected]>

Use accurate call frame title's based on the call frame type.

https://bugs.webkit.org/show_bug.cgi?id=19585

Reviewed by Geoff Garen.

  • English.lproj/localizedStrings.js: Updated strings.
  • bindings/js/JSJavaScriptCallFrameCustom.cpp: (WebCore::JSJavaScriptCallFrame::evaluate): Removed the isValid() check since the evaluate() functiondoes the check already. (WebCore::JSJavaScriptCallFrame::thisObject): Removed the isValid() check, since thisObject() does the check and returns null if invalid. (WebCore::JSJavaScriptCallFrame::type): Return a string based on the enum value of the type. (WebCore::JSJavaScriptCallFrame::scopeChain): Removed the isValid() check, since scopeChain() does the check and returns null if invalid. So just null check scopeChain().
  • page/JavaScriptCallFrame.cpp: (WebCore::JavaScriptCallFrame::type): Return the DebuggerCallFrame::Type. Return DebuggerCallFrame::UnknownType if the call frame is invalid.
  • page/JavaScriptCallFrame.h:
  • page/JavaScriptCallFrame.idl: Add the type property.
  • page/inspector/CallStackSidebarPane.js: (WebInspector.CallStackSidebarPane.prototype.update): Check the type of the call frame to create the correct title.
  • page/inspector/ScriptsPanel.js: (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu): Use the "(program)" title for the file menu to match the call frames.
File size: 3.5 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include "config.h"
30#include "DebuggerCallFrame.h"
31
32#include "JSFunction.h"
33#include "CodeBlock.h"
34#include "Machine.h"
35#include "Parser.h"
36
37namespace KJS {
38
39const UString* DebuggerCallFrame::functionName() const
40{
41 if (!m_codeBlock)
42 return 0;
43
44 int callFrameOffset = m_registerOffset - m_codeBlock->numLocals - Machine::CallFrameHeaderSize;
45 if (callFrameOffset < 0)
46 return 0;
47
48 Register* callFrame = *m_registerBase + callFrameOffset;
49 JSFunction* function = static_cast<JSFunction*>(callFrame[Machine::Callee].u.jsValue);
50 if (!function)
51 return 0;
52 return &function->functionName().ustring();
53}
54
55DebuggerCallFrame::Type DebuggerCallFrame::type() const
56{
57 if (m_registerOffset == 0)
58 return ProgramType;
59
60 int callFrameOffset = m_registerOffset - m_codeBlock->numLocals - Machine::CallFrameHeaderSize;
61 ASSERT(callFrameOffset >= 0);
62
63 Register* callFrame = *m_registerBase + callFrameOffset;
64 if (callFrame[Machine::Callee].u.jsObject)
65 return FunctionType;
66
67 return ProgramType;
68}
69
70JSObject* DebuggerCallFrame::thisObject() const
71{
72 if (!m_codeBlock)
73 return 0;
74
75 return static_cast<JSObject*>((*m_registerBase + m_registerOffset)[m_codeBlock->thisRegister].u.jsValue);
76}
77
78JSValue* DebuggerCallFrame::evaluate(const UString& script, JSValue*& exception) const
79{
80 if (!m_codeBlock)
81 return 0;
82
83 JSObject* thisObject = this->thisObject();
84
85 ExecState newExec(m_scopeChain->globalObject(), thisObject, m_scopeChain);
86
87 int sourceId;
88 int errLine;
89 UString errMsg;
90
91 RefPtr<EvalNode> evalNode = newExec.parser()->parse<EvalNode>(&newExec, UString(), 1, UStringSourceProvider::create(script), &sourceId, &errLine, &errMsg);
92
93 if (!evalNode)
94 return Error::create(&newExec, SyntaxError, errMsg, errLine, sourceId, 0);
95
96 JSValue* result = machine().execute(evalNode.get(), &newExec, thisObject, &newExec.dynamicGlobalObject()->registerFileStack(), m_scopeChain, &exception);
97 return result;
98}
99
100} // namespace KJS
Note: See TracBrowser for help on using the repository browser.