source: webkit/trunk/JavaScriptCore/kjs/interpreter.cpp@ 2821

Last change on this file since 2821 was 2821, checked in by darin, 23 years ago

top level:

  • Site/Internal/Design/CFURL.rtf: Added.

Tools:

  • Scripts/last-update: Added. Script for Trey that tells you when you last did a cvs update, based on most-recently updated ChangeLog.

JavaScriptCore:

  • stop garbage collecting the ActivationImp objects, gets 3% on iBench
  • pave the way to separate the argument lists from scope chains
  • kjs/context.h: Added. Moved ContextImp here so it can use things defined in function.h
  • kjs/scope_chain.h: Added. Starting as a copy of List, to be improved.
  • kjs/scope_chain.cpp: Added. Starting as a copy of List, to be improved.
  • JavaScriptCore.pbproj/project.pbxproj: Rearranged things, added context.h.
  • kjs/function.cpp: (FunctionImp::call): Pass InterpreterImp, not ExecState, to ContextImp. (DeclaredFunctionImp::DeclaredFunctionImp): List -> ScopeChain. (ActivationImp::createArgumentsObject): ArgumentList -> List. (GlobalFuncImp::call): Pass InterpreterImp, not an ExecState, to ContextImp.
  • kjs/function.h: List -> ScopeChain.
  • kjs/function_object.cpp: (FunctionObjectImp::construct): List -> ScopeChain.
  • kjs/internal.cpp: (ContextImp::ContextImp): Set the context in the interpreter. (ContextImp::~ContextImp): Set the context in the interpreter to the caller. (ContextImp::mark): Mark all the activation objects. (InterpreterImp::InterpreterImp): Initialize context to 0. (InterpreterImp::mark): Mark the top context. (InterpreterImp::evaluate): Pass InterpreterImp to ContextImp.
  • kjs/internal.h: Move ContextImp to its own header. Add setContext to InterpreterImp.
  • kjs/interpreter.cpp: (Context::scopeChain): List -> ScopeChain.
  • kjs/interpreter.h: List -> ScopeChain.
  • kjs/nodes.cpp: (ResolveNode::evaluateReference): List -> ScopeChain. (FuncDeclNode::processFuncDecl): List -> ScopeChain. (FuncExprNode::evaluate): List -> ScopeChain.
  • kjs/object.cpp: List -> ScopeChain.
  • kjs/object.h: List -> ScopeChain.
  • kjs/types.h: Remove needsMarking features from List.
  • kjs/types.cpp: Ditto.

WebCore:

  • khtml/ecma/kjs_dom.cpp: (DOMNode::eventHandlerScope): List -> ScopeChain.
  • khtml/ecma/kjs_dom.h: List -> ScopeChain.
  • khtml/ecma/kjs_events.cpp: (JSEventListener::handleEvent): List -> ScopeChain.
  • khtml/ecma/kjs_html.cpp: (KJS::HTMLElement::eventHandlerScope): List -> ScopeChain.
  • khtml/ecma/kjs_html.h: List -> ScopeChain.
  • force-js-clean-timestamp: Not sure this is required, but better safe than sorry.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2001 Harri Porten ([email protected])
5 * Copyright (C) 2001 Peter Kelly ([email protected])
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 *
22 */
23
24#include "value.h"
25#include "object.h"
26#include "types.h"
27#include "interpreter.h"
28
29#include <assert.h>
30#include <math.h>
31#include <stdio.h>
32
33#include "internal.h"
34#include "collector.h"
35#include "operations.h"
36#include "error_object.h"
37#include "nodes.h"
38#include "context.h"
39
40using namespace KJS;
41
42// ------------------------------ Context --------------------------------------
43
44Context::Context(ContextImp *c)
45{
46 rep = c;
47}
48
49Context::Context(const Context &c)
50{
51 rep = c.rep;
52}
53
54Context& Context::operator=(const Context &c)
55{
56 rep = c.rep;
57 return *this;
58}
59
60Context::~Context()
61{
62}
63
64bool Context::isNull() const
65{
66 return (rep == 0);
67}
68
69ContextImp *Context::imp() const
70{
71 return rep;
72}
73
74const ScopeChain Context::scopeChain() const
75{
76 return rep->scopeChain();
77}
78
79Object Context::variableObject() const
80{
81 return rep->variableObject();
82}
83
84Object Context::thisValue() const
85{
86 return rep->thisValue();
87}
88
89const Context Context::callingContext() const
90{
91 return rep->callingContext();
92}
93
94// ------------------------------ Interpreter ----------------------------------
95
96Interpreter::Interpreter(const Object &global) : rep(0)
97{
98 rep = new InterpreterImp(this,global);
99}
100
101Interpreter::Interpreter()
102{
103 Object global(new ObjectImp());
104 rep = new InterpreterImp(this,global);
105}
106
107Interpreter::~Interpreter()
108{
109 delete rep;
110}
111
112Object &Interpreter::globalObject() const
113{
114 return rep->globalObject();
115}
116
117void Interpreter::initGlobalObject()
118{
119 rep->initGlobalObject();
120}
121
122ExecState *Interpreter::globalExec()
123{
124 return rep->globalExec();
125}
126
127bool Interpreter::checkSyntax(const UString &code)
128{
129 return rep->checkSyntax(code);
130}
131
132Completion Interpreter::evaluate(const UString &code, const Value &thisV)
133{
134 return rep->evaluate(code,thisV);
135}
136
137InterpreterImp *Interpreter::imp()
138{
139 return rep;
140}
141
142Object Interpreter::builtinObject() const
143{
144 return rep->builtinObject();
145}
146
147Object Interpreter::builtinFunction() const
148{
149 return rep->builtinFunction();
150}
151
152Object Interpreter::builtinArray() const
153{
154 return rep->builtinArray();
155}
156
157Object Interpreter::builtinBoolean() const
158{
159 return rep->builtinBoolean();
160}
161
162Object Interpreter::builtinString() const
163{
164 return rep->builtinString();
165}
166
167Object Interpreter::builtinNumber() const
168{
169 return rep->builtinNumber();
170}
171
172Object Interpreter::builtinDate() const
173{
174 return rep->builtinDate();
175}
176
177Object Interpreter::builtinRegExp() const
178{
179 return rep->builtinRegExp();
180}
181
182Object Interpreter::builtinError() const
183{
184 return rep->builtinError();
185}
186
187Object Interpreter::builtinObjectPrototype() const
188{
189 return rep->builtinObjectPrototype();
190}
191
192Object Interpreter::builtinFunctionPrototype() const
193{
194 return rep->builtinFunctionPrototype();
195}
196
197Object Interpreter::builtinArrayPrototype() const
198{
199 return rep->builtinArrayPrototype();
200}
201
202Object Interpreter::builtinBooleanPrototype() const
203{
204 return rep->builtinBooleanPrototype();
205}
206
207Object Interpreter::builtinStringPrototype() const
208{
209 return rep->builtinStringPrototype();
210}
211
212Object Interpreter::builtinNumberPrototype() const
213{
214 return rep->builtinNumberPrototype();
215}
216
217Object Interpreter::builtinDatePrototype() const
218{
219 return rep->builtinDatePrototype();
220}
221
222Object Interpreter::builtinRegExpPrototype() const
223{
224 return rep->builtinRegExpPrototype();
225}
226
227Object Interpreter::builtinErrorPrototype() const
228{
229 return rep->builtinErrorPrototype();
230}
231
232Object Interpreter::builtinEvalError() const
233{
234 return rep->builtinEvalError();
235}
236
237Object Interpreter::builtinRangeError() const
238{
239 return rep->builtinRangeError();
240}
241
242Object Interpreter::builtinReferenceError() const
243{
244 return rep->builtinReferenceError();
245}
246
247Object Interpreter::builtinSyntaxError() const
248{
249 return rep->builtinSyntaxError();
250}
251
252Object Interpreter::builtinTypeError() const
253{
254 return rep->builtinTypeError();
255}
256
257Object Interpreter::builtinURIError() const
258{
259 return rep->builtinURIError();
260}
261
262Object Interpreter::builtinEvalErrorPrototype() const
263{
264 return rep->builtinEvalErrorPrototype();
265}
266
267Object Interpreter::builtinRangeErrorPrototype() const
268{
269 return rep->builtinRangeErrorPrototype();
270}
271
272Object Interpreter::builtinReferenceErrorPrototype() const
273{
274 return rep->builtinReferenceErrorPrototype();
275}
276
277Object Interpreter::builtinSyntaxErrorPrototype() const
278{
279 return rep->builtinSyntaxErrorPrototype();
280}
281
282Object Interpreter::builtinTypeErrorPrototype() const
283{
284 return rep->builtinTypeErrorPrototype();
285}
286
287Object Interpreter::builtinURIErrorPrototype() const
288{
289 return rep->builtinURIErrorPrototype();
290}
291
292void Interpreter::setCompatMode(CompatMode mode)
293{
294 rep->setCompatMode(mode);
295}
296
297Interpreter::CompatMode Interpreter::compatMode() const
298{
299 return rep->compatMode();
300}
301
302#ifdef KJS_DEBUG_MEM
303#include "lexer.h"
304void Interpreter::finalCheck()
305{
306 fprintf(stderr,"Interpreter::finalCheck()\n");
307 // Garbage collect - as many times as necessary
308 // (we could delete an object which was holding another object, so
309 // the deref() will happen too late for deleting the impl of the 2nd object).
310 while( Collector::collect() )
311 ;
312
313 Node::finalCheck();
314 Collector::finalCheck();
315 Lexer::globalClear();
316 UString::globalClear();
317}
318#endif
319
320void Interpreter::virtual_hook( int, void* )
321{ /*BASE::virtual_hook( id, data );*/ }
Note: See TracBrowser for help on using the repository browser.