• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kjs
 

kjs

  • kjs
interpreter.h
1/*
2 * This file is part of the KDE libraries
3 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
4 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
5 * Copyright (C) 2003 Apple Computer, Inc.
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., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24#ifndef _KJS_INTERPRETER_H_
25#define _KJS_INTERPRETER_H_
26
27#include "value.h"
28#include "object.h"
29#include "types.h"
30
31namespace KJS {
32
33 class ContextImp;
34 class InterpreterImp;
35
48 enum CodeType {
49 GlobalCode = 0,
50 EvalCode = 1,
51 FunctionCode = 2
52 };
53
72 class KJS_EXPORT Context {
73 public:
74 Context(ContextImp *i) : rep(i) { }
75
76 ContextImp *imp() const { return rep; }
77
85 const ScopeChain &scopeChain() const;
86
93 Object variableObject() const;
94
110 Object thisValue() const;
111
120 const Context callingContext() const;
121
126 CodeType codeType() const;
127
132 int sourceId() const;
133
137 int curStmtFirstLine() const;
138
142 int curStmtLastLine() const;
143
147 Object function() const;
148
152 Identifier functionName() const;
153
157 List args() const;
158
159 private:
160 ContextImp *rep;
161 };
162
163 bool operator==(const Context &c1, const Context &c2);
164 bool operator!=(const Context &c1, const Context &c2);
165
172 class KJS_EXPORT Interpreter {
173 public:
190 Interpreter(const Object &global);
195 Interpreter();
196 virtual ~Interpreter();
197
202 Object &globalObject() const;
203
204 void initGlobalObject();
205
206 static void lock();
207 static void unlock();
208
220 ExecState *globalExec();
221
230 bool checkSyntax(const UString &code, int *errLine, UString *errMsg);
231
238 bool checkSyntax(const UString &code);
239
255 Completion evaluate(const UString &code, const Value &thisV = Value());
256
263 InterpreterImp *imp();
264
273 Object builtinObject() const;
274
278 Object builtinFunction() const;
279
283 Object builtinArray() const;
284
288 Object builtinBoolean() const;
289
293 Object builtinString() const;
294
298 Object builtinNumber() const;
299
303 Object builtinDate() const;
304
308 Object builtinRegExp() const;
309
313 Object builtinError() const;
314
318 Object builtinObjectPrototype() const;
319
323 Object builtinFunctionPrototype() const;
324
328 Object builtinArrayPrototype() const;
329
333 Object builtinBooleanPrototype() const;
334
338 Object builtinStringPrototype() const;
339
343 Object builtinNumberPrototype() const;
344
348 Object builtinDatePrototype() const;
349
353 Object builtinRegExpPrototype() const;
354
358 Object builtinErrorPrototype() const;
359
363 Object builtinEvalError() const;
364 Object builtinRangeError() const;
365 Object builtinReferenceError() const;
366 Object builtinSyntaxError() const;
367 Object builtinTypeError() const;
368 Object builtinURIError() const;
369
370 Object builtinEvalErrorPrototype() const;
371 Object builtinRangeErrorPrototype() const;
372 Object builtinReferenceErrorPrototype() const;
373 Object builtinSyntaxErrorPrototype() const;
374 Object builtinTypeErrorPrototype() const;
375 Object builtinURIErrorPrototype() const;
376
377 enum CompatMode { NativeMode, IECompat, NetscapeCompat };
384 void setCompatMode(CompatMode mode);
385 CompatMode compatMode() const;
386
391 static bool collect();
392
397 virtual void mark() {}
398
405 virtual int rtti() { return 0; }
406
407#ifdef KJS_DEBUG_MEM
411 static void finalCheck();
412#endif
413 private:
414 InterpreterImp *rep;
415
421 Interpreter(const Interpreter&);
422
428 Interpreter operator=(const Interpreter&);
429 protected:
430 virtual void virtual_hook( int id, void* data );
431 };
432
438 class KJS_EXPORT ExecState {
439 friend class InterpreterImp;
440 friend class FunctionImp;
441 friend class GlobalFuncImp;
442 friend class TryNode;
443 friend class VarDeclNode;
444 friend class FuncDeclNode;
445 public:
451 // ### make non-const or provide an overload pair
452 Interpreter *dynamicInterpreter() const { return _interpreter; }
453
454 // for compatibility
455 Interpreter *interpreter() const { return dynamicInterpreter(); }
456
463 Interpreter *lexicalInterpreter() const;
464
470 Context context() const { return _context; }
471
472 void setException(const Value &e);
473 void clearException();
474 Value exception() const { return _exception; }
475 // ### make const
476 bool hadException();
477
478 /*
479 * request for ending execution with an exception
480 */
481 static void requestTerminate() { terminate_request = true; }
482 /*
483 * optional confirmation for ending execution after requestTerminate()
484 */
485 static bool (*confirmTerminate)();
486 private:
487 ExecState(Interpreter *interp, ContextImp *con)
488 : _interpreter(interp), _context(con) { }
489 Interpreter *_interpreter;
490 ContextImp *_context;
491 Value _exception;
492 static bool terminate_request;
493 };
494
495} // namespace
496
497#endif // _KJS_INTERPRETER_H_
KJS::Completion
Completion objects are used to convey the return status and value from functions.
Definition: completion.h:48
KJS::ContextImp
Execution context.
Definition: context.h:34
KJS::Context
Represents an execution context, as specified by section 10 of the ECMA spec.
Definition: interpreter.h:72
KJS::ExecState
Represents the current state of script execution.
Definition: interpreter.h:438
KJS::ExecState::context
Context context() const
Returns the execution context associated with this execution state.
Definition: interpreter.h:470
KJS::ExecState::dynamicInterpreter
Interpreter * dynamicInterpreter() const
Returns the interpreter associated with this execution state.
Definition: interpreter.h:452
KJS::FunctionImp
Implementation class for functions implemented in JS.
Definition: internal.h:389
KJS::Identifier
Represents an Identifier for a Javascript object.
Definition: identifier.h:32
KJS::Interpreter
Interpreter objects can be used to evaluate ECMAScript code.
Definition: interpreter.h:172
KJS::Interpreter::rtti
virtual int rtti()
Provides a way to distinguish derived classes.
Definition: interpreter.h:405
KJS::Interpreter::mark
virtual void mark()
Called by InterpreterImp during the mark phase of the garbage collector Default implementation does n...
Definition: interpreter.h:397
KJS::List
Native list type.
Definition: list.h:48
KJS::Object
Represents an Object.
Definition: object.h:81
KJS::ScopeChain
A scope chain object.
Definition: scope_chain.h:47
KJS::UString
Unicode string class.
Definition: ustring.h:189
KJS::Value
Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents.
Definition: value.h:167

kjs

Skip menu "kjs"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kjs

Skip menu "kjs"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kjs by doxygen 1.9.4
This website is maintained by Timothy Pearson.