Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

vm_local.h

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 #include "../game/q_shared.h"
00023 #include "qcommon.h"
00024 
00025 typedef enum {
00026     OP_UNDEF, 
00027 
00028     OP_IGNORE, 
00029 
00030     OP_BREAK,
00031 
00032     OP_ENTER,
00033     OP_LEAVE,
00034     OP_CALL,
00035     OP_PUSH,
00036     OP_POP,
00037 
00038     OP_CONST,
00039     OP_LOCAL,
00040 
00041     OP_JUMP,
00042 
00043     //-------------------
00044 
00045     OP_EQ,
00046     OP_NE,
00047 
00048     OP_LTI,
00049     OP_LEI,
00050     OP_GTI,
00051     OP_GEI,
00052 
00053     OP_LTU,
00054     OP_LEU,
00055     OP_GTU,
00056     OP_GEU,
00057 
00058     OP_EQF,
00059     OP_NEF,
00060 
00061     OP_LTF,
00062     OP_LEF,
00063     OP_GTF,
00064     OP_GEF,
00065 
00066     //-------------------
00067 
00068     OP_LOAD1,
00069     OP_LOAD2,
00070     OP_LOAD4,
00071     OP_STORE1,
00072     OP_STORE2,
00073     OP_STORE4,              // *(stack[top-1]) = stack[top]
00074     OP_ARG,
00075 
00076     OP_BLOCK_COPY,
00077 
00078     //-------------------
00079 
00080     OP_SEX8,
00081     OP_SEX16,
00082 
00083     OP_NEGI,
00084     OP_ADD,
00085     OP_SUB,
00086     OP_DIVI,
00087     OP_DIVU,
00088     OP_MODI,
00089     OP_MODU,
00090     OP_MULI,
00091     OP_MULU,
00092 
00093     OP_BAND,
00094     OP_BOR,
00095     OP_BXOR,
00096     OP_BCOM,
00097 
00098     OP_LSH,
00099     OP_RSHI,
00100     OP_RSHU,
00101 
00102     OP_NEGF,
00103     OP_ADDF,
00104     OP_SUBF,
00105     OP_DIVF,
00106     OP_MULF,
00107 
00108     OP_CVIF,
00109     OP_CVFI
00110 } opcode_t;
00111 
00112 
00113 
00114 typedef int vmptr_t;
00115 
00116 typedef struct vmSymbol_s {
00117     struct vmSymbol_s   *next;
00118     int     symValue;
00119     int     profileCount;
00120     char    symName[1];     // variable sized
00121 } vmSymbol_t;
00122 
00123 #define VM_OFFSET_PROGRAM_STACK     0
00124 #define VM_OFFSET_SYSTEM_CALL       4
00125 
00126 struct vm_s {
00127     // DO NOT MOVE OR CHANGE THESE WITHOUT CHANGING THE VM_OFFSET_* DEFINES
00128     // USED BY THE ASM CODE
00129     int         programStack;       // the vm may be recursively entered
00130     int         (*systemCall)( int *parms );
00131 
00132     //------------------------------------
00133    
00134     char        name[MAX_QPATH];
00135 
00136     // for dynamic linked modules
00137     void        *dllHandle;
00138     int         (QDECL *entryPoint)( int callNum, ... );
00139 
00140     // for interpreted modules
00141     qboolean    currentlyInterpreting;
00142 
00143     qboolean    compiled;
00144     byte        *codeBase;
00145     int         codeLength;
00146 
00147     int         *instructionPointers;
00148     int         instructionPointersLength;
00149 
00150     byte        *dataBase;
00151     int         dataMask;
00152 
00153     int         stackBottom;        // if programStack < stackBottom, error
00154 
00155     int         numSymbols;
00156     struct vmSymbol_s   *symbols;
00157 
00158     int         callLevel;          // for debug indenting
00159     int         breakFunction;      // increment breakCount on function entry to this
00160     int         breakCount;
00161 
00162 // fqpath member added 7/20/02 by T.Ray
00163     char        fqpath[MAX_QPATH+1] ;
00164 };
00165 
00166 
00167 extern  vm_t    *currentVM;
00168 extern  int     vm_debugLevel;
00169 
00170 void VM_Compile( vm_t *vm, vmHeader_t *header );
00171 int VM_CallCompiled( vm_t *vm, int *args );
00172 
00173 void VM_PrepareInterpreter( vm_t *vm, vmHeader_t *header );
00174 int VM_CallInterpreted( vm_t *vm, int *args );
00175 
00176 vmSymbol_t *VM_ValueToFunctionSymbol( vm_t *vm, int value );
00177 int VM_SymbolToValue( vm_t *vm, const char *symbol );
00178 const char *VM_ValueToSymbol( vm_t *vm, int value );
00179 void VM_LogSyscalls( int *args );
00180 

Generated on Thu Aug 25 12:37:49 2005 for Quake III Arena by  doxygen 1.3.9.1