1 | /*
|
---|
2 | * Copyright (C) 2008 Apple Inc. All rights reserved.
|
---|
3 | * Copyright (C) 1999-2001 Harri Porten ([email protected])
|
---|
4 | * Copyright (C) 2001 Peter Kelly ([email protected])
|
---|
5 | *
|
---|
6 | * This library is free software; you can redistribute it and/or
|
---|
7 | * modify it under the terms of the GNU Lesser General Public
|
---|
8 | * License as published by the Free Software Foundation; either
|
---|
9 | * version 2 of the License, or (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This library is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | * Lesser General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU Lesser General Public
|
---|
17 | * License along with this library; if not, write to the Free Software
|
---|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
19 | *
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "config.h"
|
---|
23 | #include "Debugger.h"
|
---|
24 |
|
---|
25 | #include "JSGlobalObject.h"
|
---|
26 |
|
---|
27 | namespace JSC {
|
---|
28 |
|
---|
29 | Debugger::Debugger()
|
---|
30 | {
|
---|
31 | }
|
---|
32 |
|
---|
33 | Debugger::~Debugger()
|
---|
34 | {
|
---|
35 | HashSet<JSGlobalObject*>::iterator end = m_globalObjects.end();
|
---|
36 | for (HashSet<JSGlobalObject*>::iterator it = m_globalObjects.begin(); it != end; ++it)
|
---|
37 | (*it)->setDebugger(0);
|
---|
38 | }
|
---|
39 |
|
---|
40 | void Debugger::attach(JSGlobalObject* globalObject)
|
---|
41 | {
|
---|
42 | ASSERT(!globalObject->debugger());
|
---|
43 | globalObject->setDebugger(this);
|
---|
44 | m_globalObjects.add(globalObject);
|
---|
45 | }
|
---|
46 |
|
---|
47 | void Debugger::detach(JSGlobalObject* globalObject)
|
---|
48 | {
|
---|
49 | ASSERT(m_globalObjects.contains(globalObject));
|
---|
50 | m_globalObjects.remove(globalObject);
|
---|
51 | globalObject->setDebugger(0);
|
---|
52 | }
|
---|
53 |
|
---|
54 | JSValuePtr evaluateInGlobalCallFrame(const UString& script, JSValuePtr& exception, JSGlobalObject* globalObject)
|
---|
55 | {
|
---|
56 | CallFrame* globalCallFrame = globalObject->globalExec();
|
---|
57 |
|
---|
58 | int errLine;
|
---|
59 | UString errMsg;
|
---|
60 | SourceCode source = makeSource(script);
|
---|
61 | RefPtr<EvalNode> evalNode = globalObject->globalData()->parser->parse<EvalNode>(globalCallFrame, globalObject->debugger(), source, &errLine, &errMsg);
|
---|
62 | if (!evalNode)
|
---|
63 | return Error::create(globalCallFrame, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url());
|
---|
64 |
|
---|
65 | return globalObject->globalData()->interpreter->execute(evalNode.get(), globalCallFrame, globalObject, globalCallFrame->scopeChain(), &exception);
|
---|
66 | }
|
---|
67 |
|
---|
68 | } // namespace JSC
|
---|