]>
Commit | Line | Data |
---|---|---|
9dae56ea A |
1 | /* |
2 | * Copyright (C) 2008 Apple Inc. All rights reserved. | |
3 | * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) | |
4 | * Copyright (C) 2001 Peter Kelly (pmk@post.com) | |
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 | #include "Interpreter.h" | |
27 | #include "Parser.h" | |
28 | ||
29 | namespace JSC { | |
30 | ||
31 | Debugger::Debugger() | |
32 | { | |
33 | } | |
34 | ||
35 | Debugger::~Debugger() | |
36 | { | |
37 | HashSet<JSGlobalObject*>::iterator end = m_globalObjects.end(); | |
38 | for (HashSet<JSGlobalObject*>::iterator it = m_globalObjects.begin(); it != end; ++it) | |
39 | (*it)->setDebugger(0); | |
40 | } | |
41 | ||
42 | void Debugger::attach(JSGlobalObject* globalObject) | |
43 | { | |
44 | ASSERT(!globalObject->debugger()); | |
45 | globalObject->setDebugger(this); | |
46 | m_globalObjects.add(globalObject); | |
47 | } | |
48 | ||
49 | void Debugger::detach(JSGlobalObject* globalObject) | |
50 | { | |
51 | ASSERT(m_globalObjects.contains(globalObject)); | |
52 | m_globalObjects.remove(globalObject); | |
53 | globalObject->setDebugger(0); | |
54 | } | |
55 | ||
ba379fdc | 56 | JSValue evaluateInGlobalCallFrame(const UString& script, JSValue& exception, JSGlobalObject* globalObject) |
9dae56ea A |
57 | { |
58 | CallFrame* globalCallFrame = globalObject->globalExec(); | |
59 | ||
60 | int errLine; | |
61 | UString errMsg; | |
62 | SourceCode source = makeSource(script); | |
63 | RefPtr<EvalNode> evalNode = globalObject->globalData()->parser->parse<EvalNode>(globalCallFrame, globalObject->debugger(), source, &errLine, &errMsg); | |
64 | if (!evalNode) | |
65 | return Error::create(globalCallFrame, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url()); | |
66 | ||
67 | return globalObject->globalData()->interpreter->execute(evalNode.get(), globalCallFrame, globalObject, globalCallFrame->scopeChain(), &exception); | |
68 | } | |
69 | ||
70 | } // namespace JSC |