Eneboo - Documentación para desarrolladores
src/qsa/src/engine/qsinternal.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qsinternal.h  1.1.5   edited 2006-02-23T15:39:57$
00003 **
00004 ** Copyright (C) 2001-2006 Trolltech AS.  All rights reserved.
00005 **
00006 ** This file is part of the Qt Script for Applications framework (QSA).
00007 **
00008 ** This file may be distributed and/or modified under the terms of the
00009 ** GNU General Public License version 2 as published by the Free Software
00010 ** Foundation and appearing in the file LICENSE.GPL included in the
00011 ** packaging of this file.
00012 **
00013 ** Licensees holding a valid Qt Script for Applications license may use
00014 ** this file in accordance with the Qt Script for Applications License
00015 ** Agreement provided with the Software.
00016 **
00017 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00018 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00019 **
00020 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00021 **   information about QSA Commercial License Agreements.
00022 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00023 **
00024 ** Contact info@trolltech.com if any conditions of this licensing are
00025 ** not clear to you.
00026 **
00027 *****************************************************************************/
00028 
00029 #ifndef QSINTERNAL_H
00030 #define QSINTERNAL_H
00031 
00032 #ifdef HAVE_CONFIG_H
00033 #include "config.h"
00034 #endif
00035 
00036 #include "qsengine.h"
00037 #include "qsobject.h"
00038 #include "qsfunction.h"
00039 #include "qsclass.h"
00040 #include <qstring.h>
00041 
00042 class QSNode;
00043 class QSFunctionBodyNode;
00044 class QSProgramNode;
00045 class QSClassClass;
00046 
00047 class Object;
00048 class RegExp;
00049 #ifdef QSDEBUGGER
00050 class Debugger;
00051 #endif
00052 
00056 class LabelStack
00057 {
00058 public:
00059   LabelStack(): tos(0L) {}
00060 
00061   ~LabelStack() {
00062     StackElm *prev;
00063     while (tos) {
00064       prev = tos->prev;
00065       delete tos;
00066       tos = prev;
00067     }
00068   }
00069 
00074   bool push(const QString &id) {
00075     if (id.isEmpty() || contains(id))
00076       return false;
00077 
00078     StackElm *newtos = new StackElm;
00079     newtos->id = id;
00080     newtos->prev = tos;
00081     tos = newtos;
00082     return true;
00083   }
00084 
00088   bool contains(const QString &id) const {
00089     if (id.isEmpty())
00090       return true;
00091 
00092     for (StackElm *curr = tos; curr; curr = curr->prev)
00093       if (curr->id == id)
00094         return true;
00095 
00096     return false;
00097   }
00098 
00102   void pop() {
00103     if (tos) {
00104       StackElm *prev = tos->prev;
00105       delete tos;
00106       tos = prev;
00107     }
00108   }
00109 
00110 private:
00111   struct StackElm {
00112     QString id;
00113     StackElm *prev;
00114   };
00115 
00116   StackElm *tos;
00117 };
00118 
00119 class FunctionImp;
00120 
00121 class QSArgumentsClass : public QSWritableClass
00122 {
00123 public:
00124   QSArgumentsClass(QSClass *b) : QSWritableClass(b) { }
00125   QString name() const {
00126     return QString::fromLatin1("Arguments");
00127   }
00128   QSObject construct(FunctionImp *func, const QSList *args) const;
00129 };
00130 
00131 class ExecutionStack;
00132 class QSEnv;
00133 
00134 class QSEngineImp
00135 {
00136 public:
00137   QSEngineImp(QSEngine *s);
00138   ~QSEngineImp();
00139 
00140   QSEngine *interpreter() const {
00141     return scr;
00142   }
00143   QSEnv *env() const {
00144     return en;
00145   }
00146 
00147 #ifdef QSDEBUGGER
00148 
00152   void attachDebugger(Debugger *d);
00153   Debugger *debugger() const {
00154     return dbg;
00155   }
00156   int sourceId() const {
00157     return sid;
00158   }
00159   void incrSourceId() {
00160     sid++;
00161   }
00162   void decrSourceId() {
00163     sid--;
00164   }
00165   bool setBreakpoint(int id, int line, bool set);
00166 #endif
00167 
00168 private:
00172   void init();
00173   void clear();
00178   void globalInit();
00183   void globalClear();
00184   bool evaluate(const QString &code, const QSObject *thisV = 0,
00185                 bool onlyCheckSyntax = FALSE, int checkMode = QSEngine::DisallowGlobal,
00186                 int lineZero = 0);
00187   bool call(QSObject *scope, const QString &func, const QSList &args);
00188 
00189 private:
00190   QSProgramNode *progNode() const;
00191   void setProgNode(QSProgramNode *p);
00192   QSNode *firstNode() const;
00193   void setFirstNode(QSNode *n);
00194 
00195   bool initialized;
00196   QSEngine *scr;
00197   QSEnv *en;
00198   Global *glob;
00199   int errType;
00200   QValueList<uint> errLines;
00201   QStringList errMsgs;
00202 #ifdef QSDEBUGGER
00203   Debugger *dbg;
00204   int sid;
00205 #endif
00206   QSObject retVal;
00207   ExecutionStack *stack;
00208   int recursion;
00209 
00210   static int instances; // total number of instances
00211 
00212   friend class QSEngine;
00213   friend class Global;
00214 };
00215 
00216 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'