Search packages:      
 

Sourcecode and documentation for gambas version 1.0.18-2
show bar | Show file versions

gbx_exec.h

00001 /***************************************************************************
00002 
00003   exec.h
00004 
00005   Subroutines for the interpreter : executing methods, native methods,
00006   the NEW operator, the casting operator, etc.
00007 
00008   (c) 2000-2004 Benoît Minisini <gambas@users.sourceforge.net>
00009 
00010   This program is free software; you can redistribute it and/or modify
00011   it under the terms of the GNU General Public License as published by
00012   the Free Software Foundation; either version 1, or (at your option)
00013   any later version.
00014 
00015   This program is distributed in the hope that it will be useful,
00016   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018   GNU General Public License for more details.
00019 
00020   You should have received a copy of the GNU General Public License
00021   along with this program; if not, write to the Free Software
00022   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00023 
00024 ***************************************************************************/
00025 
00026 #ifndef __GBX_EXEC_H
00027 #define __GBX_EXEC_H
00028 
00029 #include "gb_alloc.h"
00030 #include "gb_error.h"
00031 #include "gbx_class.h"
00032 #include "gbx_value.h"
00033 #include "gb_pcode.h"
00034 #include "gbx_stack.h"
00035 
00036 #include "gbx_string.h"
00037 #include "gbx_object.h"
00038 #include "gbx_variant.h"
00039 #include "gbx_array.h"
00040 
00041 typedef
00042   void (*EXEC_FUNC)();
00043 
00044 typedef
00045   struct {
00046     CLASS *class;
00047     void *object;
00048     long index;
00049     //FUNCTION *func;
00050     CLASS_DESC_METHOD *desc;
00051     int nparam;
00052     int nparvar;
00053     bool drop;
00054     bool native;
00055     bool use_stack;
00056     bool property;
00057     }
00058   EXEC_FUNCTION;
00059 
00060 typedef
00061   struct {
00062     void (*main)();
00063     int (*loop)();
00064     void (*wait)();
00065     int (*message)();
00066     void (*beep)();
00067     void (*watch)();
00068     void (*post)();
00069     void (*quit)();
00070     void (*error)();
00071     }
00072   EXEC_HOOK;
00073 
00074 #ifndef __GBX_EXEC_C
00075 
00076 EXTERN STACK_CONTEXT EXEC_current;
00077 EXTERN PCODE EXEC_code;
00078 EXTERN VALUE *SP;
00079 EXTERN VALUE TEMP;
00080 EXTERN VALUE RET;
00081 EXTERN EXEC_FUNCTION EXEC;
00082 
00083 /*
00084 EXTERN boolean EXEC_stop_next;
00085 EXTERN boolean EXEC_stop_next_line;
00086 EXTERN FUNCTION *EXEC_stop_function;
00087 EXTERN PCODE *EXEC_begin_line;
00088 EXTERN PCODE *EXEC_end_line;
00089 */
00090 
00091 EXTERN bool EXEC_debug;
00092 EXTERN bool EXEC_arch;
00093 EXTERN bool EXEC_fifo;
00094 
00095 EXTERN EXEC_HOOK EXEC_Hook;
00096 
00097 EXTERN bool EXEC_enum_stop;
00098 EXTERN void *EXEC_enum_data;
00099 
00100 EXTERN bool EXEC_big_endian;
00101 
00102 /*EXTERN long EXEC_const[];*/
00103 
00104 #endif
00105 
00106 /* Pointeur de référence des variables locales */
00107 #define BP EXEC_current.bp
00108 /* Classe en cours */
00109 #define CP EXEC_current.cp
00110 /* Objet en cours */
00111 #define OP EXEC_current.op
00112 /* Pointeur de référence des paramètres */
00113 /*#define PP EXEC_current.pp*/
00114 /* Sauvegarde du pointeur de pile pour un TRY */
00115 #define EP EXEC_current.ep
00116 /* fonction en cours */
00117 #define FP EXEC_current.fp
00118 /* Pointeur de programme */
00119 #define PC EXEC_current.pc
00120 /* Emplacement où aller en cas d'erreur */
00121 #define EC EXEC_current.ec
00122 /* Emplacement de sauvegarde pour TRY */
00123 #define ET EXEC_current.et
00124 /* Valeur de retour d'une fonction */
00125 #define RP (&RET)
00126 
00127 #define HOOK(func) (!EXEC_Hook.func) ? 0 : (*EXEC_Hook.func)
00128 #define HOOK_DEFAULT(func, def) (*((!EXEC_Hook.func) ? def : EXEC_Hook.func))
00129 
00130 #define GET_NPARAM(var)         short var = *PC & 0x3F
00131 #define GET_PARAM(var, nparam)  VALUE *var = &SP[-nparam]
00132 
00133 /*
00134 #define EXEC_output_on_file(file) (EXEC_Output = (file), EXEC_OutputString = NULL)
00135 #define EXEC_output_on_string(str) (EXEC_Output = NULL, EXEC_OutputString = (str))
00136 */
00137 
00138 
00139 #define RELEASE_STRING(_value)
00140   /*
00141   if (value->type == T_STRING)
00142     STRING_unref(&value->_string.addr);
00143   else if ((value->type == T_VARIANT) && (value->_variant.vtype == T_STRING))
00144     STRING_unref((char **)value->_variant.value);
00145   */
00146 
00147 #define PUSH() (BORROW(SP), SP++)
00148 #define POP()  (SP--, RELEASE(SP))
00149 
00150 PUBLIC void EXEC_init(void);
00151 
00152 PUBLIC void EXEC_enter(void);
00153 PUBLIC void EXEC_leave(bool);
00154 PUBLIC void EXEC_loop(void);
00155 
00156 PUBLIC void EXEC_object(VALUE *SP, CLASS **class, OBJECT **object, boolean *defined);
00157 PUBLIC void *EXEC_auto_create(CLASS *class);
00158 
00159 PUBLIC bool EXEC_call_native(void (*exec)(), void *object, TYPE type, VALUE *param);
00160 PUBLIC void EXEC_native();
00161 PUBLIC void EXEC_function_real(bool keep_ret_value);
00162 
00163 #define EXEC_function() EXEC_function_real(FALSE)
00164 #define EXEC_function_keep() EXEC_function_real(TRUE)
00165 
00166 PUBLIC void EXEC_public(CLASS *class, void *object, const char *name, int nparam);
00167 
00168 PUBLIC boolean EXEC_spec(int spec, CLASS *class, void *object, int nparam, boolean drop);
00169 #define EXEC_special(_spec, _class, _object, _nparam, _drop) EXEC_spec(_spec, _class, _object, _nparam, _drop)
00170 /*#define EXEC_special_use_stack(_spec, _class, _object, _nparam, _drop) EXEC_spec(_spec, _class, _object, _nparam, _drop, TRUE)*/
00171 
00172 PUBLIC void EXEC_special_inheritance(int special, CLASS *class, OBJECT *object, int nparam, boolean drop);
00173 
00174 PUBLIC void EXEC_nop(void);
00175 PUBLIC void EXEC_ILLEGAL(void);
00176 
00177 PUBLIC void EXEC_push_unknown(void);
00178 PUBLIC void EXEC_push_array(void);
00179 PUBLIC void EXEC_push_special(void);
00180 
00181 PUBLIC void EXEC_pop_unknown(void);
00182 PUBLIC void EXEC_pop_array(void);
00183 
00184 PUBLIC void EXEC_enum_first(PCODE code);
00185 PUBLIC bool EXEC_enum_next(PCODE code);
00186 
00187 PUBLIC void EXEC_new(void);
00188 PUBLIC void EXEC_class(void);
00189 
00190 PUBLIC void BORROW(VALUE *val);
00191 PUBLIC void UNBORROW(VALUE *val);
00192 PUBLIC void RELEASE(VALUE *val);
00193 
00194 PUBLIC void EXEC_release_return_value(void);
00195 PUBLIC void EXEC_quit(void);
00196 
00197 #endif /* */

Generated by  Doxygen 1.5.1