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

Last change on this file since 2740 was 2738, checked in by darin, 23 years ago
  • simplified the ExecState class, which was showing up in profiles

Sped up JavaScript iBench by 6%.

  • kjs/interpreter.h: Removed the level of indirection, and made it all inline.
  • kjs/interpreter.cpp: Removed ExecState implementation from here altogether.
  • fixed an oversight in my sort speedup
  • kjs/array_object.h: Add pushUndefinedObjectsToEnd.
  • kjs/array_object.cpp: (ArrayInstanceImp::sort): Call pushUndefinedObjectsToEnd. (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added. Pushes all undefined to the end of the array.
  • 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
39using namespace KJS;
40
41// ------------------------------ Context --------------------------------------
42
43Context::Context(ContextImp *c)
44{
45 rep = c;
46}
47
48Context::Context(const Context &c)
49{
50 rep = c.rep;
51}
52
53Context& Context::operator=(const Context &c)
54{
55 rep = c.rep;
56 return *this;
57}
58
59Context::~Context()
60{
61}
62
63bool Context::isNull() const
64{
65 return (rep == 0);
66}
67
68ContextImp *Context::imp() const
69{
70 return rep;
71}
72
73const List Context::scopeChain() const
74{
75 return rep->scopeChain();
76}
77
78Object Context::variableObject() const
79{
80 return rep->variableObject();
81}
82
83Object Context::thisValue() const
84{
85 return rep->thisValue();
86}
87
88const Context Context::callingContext() const
89{
90 return rep->callingContext();
91}
92
93// ------------------------------ Interpreter ----------------------------------
94
95Interpreter::Interpreter(const Object &global) : rep(0)
96{
97 rep = new InterpreterImp(this,global);
98}
99
100Interpreter::Interpreter()
101{
102 Object global(new ObjectImp());
103 rep = new InterpreterImp(this,global);
104}
105
106Interpreter::~Interpreter()
107{
108 delete rep;
109}
110
111Object Interpreter::globalObject() const
112{
113 return rep->globalObject();
114}
115
116void Interpreter::initGlobalObject()
117{
118 rep->initGlobalObject();
119}
120
121ExecState *Interpreter::globalExec()
122{
123 return rep->globalExec();
124}
125
126bool Interpreter::checkSyntax(const UString &code)
127{
128 return rep->checkSyntax(code);
129}
130
131Completion Interpreter::evaluate(const UString &code, const Value &thisV)
132{
133 return rep->evaluate(code,thisV);
134}
135
136InterpreterImp *Interpreter::imp()
137{
138 return rep;
139}
140
141Object Interpreter::builtinObject() const
142{
143 return rep->builtinObject();
144}
145
146Object Interpreter::builtinFunction() const
147{
148 return rep->builtinFunction();
149}
150
151Object Interpreter::builtinArray() const
152{
153 return rep->builtinArray();
154}
155
156Object Interpreter::builtinBoolean() const
157{
158 return rep->builtinBoolean();
159}
160
161Object Interpreter::builtinString() const
162{
163 return rep->builtinString();
164}
165
166Object Interpreter::builtinNumber() const
167{
168 return rep->builtinNumber();
169}
170
171Object Interpreter::builtinDate() const
172{
173 return rep->builtinDate();
174}
175
176Object Interpreter::builtinRegExp() const
177{
178 return rep->builtinRegExp();
179}
180
181Object Interpreter::builtinError() const
182{
183 return rep->builtinError();
184}
185
186Object Interpreter::builtinObjectPrototype() const
187{
188 return rep->builtinObjectPrototype();
189}
190
191Object Interpreter::builtinFunctionPrototype() const
192{
193 return rep->builtinFunctionPrototype();
194}
195
196Object Interpreter::builtinArrayPrototype() const
197{
198 return rep->builtinArrayPrototype();
199}
200
201Object Interpreter::builtinBooleanPrototype() const
202{
203 return rep->builtinBooleanPrototype();
204}
205
206Object Interpreter::builtinStringPrototype() const
207{
208 return rep->builtinStringPrototype();
209}
210
211Object Interpreter::builtinNumberPrototype() const
212{
213 return rep->builtinNumberPrototype();
214}
215
216Object Interpreter::builtinDatePrototype() const
217{
218 return rep->builtinDatePrototype();
219}
220
221Object Interpreter::builtinRegExpPrototype() const
222{
223 return rep->builtinRegExpPrototype();
224}
225
226Object Interpreter::builtinErrorPrototype() const
227{
228 return rep->builtinErrorPrototype();
229}
230
231Object Interpreter::builtinEvalError() const
232{
233 return rep->builtinEvalError();
234}
235
236Object Interpreter::builtinRangeError() const
237{
238 return rep->builtinRangeError();
239}
240
241Object Interpreter::builtinReferenceError() const
242{
243 return rep->builtinReferenceError();
244}
245
246Object Interpreter::builtinSyntaxError() const
247{
248 return rep->builtinSyntaxError();
249}
250
251Object Interpreter::builtinTypeError() const
252{
253 return rep->builtinTypeError();
254}
255
256Object Interpreter::builtinURIError() const
257{
258 return rep->builtinURIError();
259}
260
261Object Interpreter::builtinEvalErrorPrototype() const
262{
263 return rep->builtinEvalErrorPrototype();
264}
265
266Object Interpreter::builtinRangeErrorPrototype() const
267{
268 return rep->builtinRangeErrorPrototype();
269}
270
271Object Interpreter::builtinReferenceErrorPrototype() const
272{
273 return rep->builtinReferenceErrorPrototype();
274}
275
276Object Interpreter::builtinSyntaxErrorPrototype() const
277{
278 return rep->builtinSyntaxErrorPrototype();
279}
280
281Object Interpreter::builtinTypeErrorPrototype() const
282{
283 return rep->builtinTypeErrorPrototype();
284}
285
286Object Interpreter::builtinURIErrorPrototype() const
287{
288 return rep->builtinURIErrorPrototype();
289}
290
291void Interpreter::setCompatMode(CompatMode mode)
292{
293 rep->setCompatMode(mode);
294}
295
296Interpreter::CompatMode Interpreter::compatMode() const
297{
298 return rep->compatMode();
299}
300
301#ifdef KJS_DEBUG_MEM
302#include "lexer.h"
303void Interpreter::finalCheck()
304{
305 fprintf(stderr,"Interpreter::finalCheck()\n");
306 // Garbage collect - as many times as necessary
307 // (we could delete an object which was holding another object, so
308 // the deref() will happen too late for deleting the impl of the 2nd object).
309 while( Collector::collect() )
310 ;
311
312 Node::finalCheck();
313 Collector::finalCheck();
314 Lexer::globalClear();
315 List::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.