vm_types.h

Go to the documentation of this file.
00001 /* TinyaML
00002  * Copyright (C) 2007 Damien Leroux
00003  *
00004  * This program is free software;
00005  * you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation;
00008  * either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY;
00013  * 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 this program;
00019  * if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021  */
00022 
00023 
00024 #ifndef _BML_VM_TYPES_H_
00025 #define _BML_VM_TYPES_H_
00026 
00027 #if defined(__GNUC__)
00028 #define _VM_CALL __attribute__((fastcall))
00029 #elif defined(WIN32)||defined(__MSVC__)
00030 #define _VM_CALL __fastcall
00031 #else
00032 #warning "using cdecl"
00033 #define _VM_CALL
00034 #endif
00035 
00040 typedef struct _vm_t* vm_t;
00047 typedef struct _opcode_t* opcode_t;
00054 typedef struct _program_t* program_t;
00062 typedef unsigned long int word_t;
00066 typedef word_t value_t;
00070 
00075 typedef struct _vm_obj_t* vm_obj_t;
00081 typedef struct _vm_dyn_env_t* vm_dyn_env_t;
00087 typedef struct _vm_dyn_func_t* vm_dyn_func_t;
00095 typedef struct _dynarray_t* dynarray_t;
00097 typedef word_t dynarray_index_t;
00099 typedef word_t dynarray_value_t;
00106 typedef struct _generic_stack_t* generic_stack_t;
00113 typedef dynarray_t code_seg_t;
00120 typedef struct _text_seg_t* text_seg_t;
00127 typedef enum {
00128         OpcodeNoArg=0,          
00129         OpcodeArgInt,           
00130         OpcodeArgFloat,         
00131         OpcodeArgPtr,           
00132         OpcodeArgLabel,         
00133         OpcodeArgString,        
00134         OpcodeArgEnvSym,        
00135         OpcodeTypeMax           
00136 } opcode_arg_t;
00143 typedef enum {
00144         ThreadBlocked,
00145         ThreadReady,
00146         ThreadRunning,
00147         ThreadDying,
00148         ThreadZombie,
00149         ThreadStateMax          
00150 } thread_state_t;
00156 typedef struct _mutex_t* mutex_t;
00161 typedef struct _thread_t* thread_t;
00168 typedef enum {
00169         SchedulerIdle=0,
00170         SchedulerMonoThread,
00171         SchedulerRoundRobin,
00172 
00173         SchedulerAlgoMax
00174 } scheduler_algorithm_t;
00180 typedef struct _vm_engine_t* vm_engine_t;
00186 typedef struct _opcode_dict_t* opcode_dict_t;
00192 typedef enum {
00193         DataInt=0,                      
00194         DataFloat=1,                    
00195         DataString=OpcodeArgString,     
00197         DataManagedObjectFlag=0x100,    
00198         DataObjStr,                     
00199         DataObjSymTab,                  
00200         DataObjMutex,                   
00201         DataObjThread,                  
00202         DataObjArray,                   
00203         DataObjEnv,                     
00204         DataObjStack,                   
00205         DataObjFun,                     
00206         DataObjVObj,                    
00207         DataObjUser,                    
00209         DataTypeMax,                    
00210 } vm_data_type_t;
00217 typedef struct _slist_t* opcode_chain_t;
00219 typedef struct _opcode_chain_node_t* opcode_chain_node_t;
00221 typedef enum {
00222         NodeOpcode,     
00223         NodeLangDef,    
00224         NodeLangPlug,   
00225         NodeData,       
00226         NodeLabel       
00227 } opcode_chain_node_type_t;
00235 typedef generic_stack_t vm_blocker_t;
00242 typedef struct _data_stack_entry_t* vm_data_t;
00248 typedef struct _call_stack_entry_t* call_stack_entry_t;
00254 typedef struct _call_stack_entry_t* catch_stack_entry_t;
00261 typedef void _VM_CALL (*opcode_stub_t) (vm_t, word_t t);
00265 #define _WC_ARGTYPE_BSZ 4
00266 
00268 #define _WC_OP_BSZ (32-_WC_ARGTYPE_BSZ)
00269 
00270 #define _WC_OP_MASK ((1<<_WC_OP_BSZ)-1)
00271 
00272 #define _WC_ARGTYPE_SHIFT _WC_OP_BSZ
00273 
00275 #define WC_GET_OP(_wc) (((word_t)(_wc))&_WC_OP_MASK)
00276 
00277 #define WC_GET_ARGTYPE(_wc) (((word_t)(_wc))>>_WC_ARGTYPE_SHIFT)
00278 
00280 #define MAKE_WC(_a,_op) (((_a)<<_WC_ARGTYPE_SHIFT)|(_op))
00281 
00282 
00283 #endif
00284 

Generated on Wed Feb 6 14:46:04 2008 for TinyaML by  doxygen 1.5.3