/*
....[@@@..[@@@..............[@.................. MUD++ is a written from
....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and
....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++.
....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing
....[@......[@..[@@@@@..[@@@@@.................. development project. All
................................................ contributions are welcome.
....Copyright(C).1995.Melvin.Smith.............. Enjoy.
------------------------------------------------------------------------------
Melvin Smith (aka Fusion) msmith@hom.net
MUD++ development mailing list mudpp@van.ml.org
------------------------------------------------------------------------------
vmtypes.h
*/
#ifndef _VMTYPES_H
#define _VMTYPES_H
class VMObject;
class VMachine;
class String;
typedef s32 vmint;
typedef float vmfloat;
enum vmtype
{
VMT_NULL=0,
// Normal types
VMT_TOPOFSTACK, VMT_INT, VMT_FLOAT, VMT_STRING,
// has to be first VmObj type
VMT_VMOBJECT,
VMT_MUDOBJECT,VMT_THING, VMT_CHAR,
VMT_NPC, VMT_SHOPKEEPER, VMT_PC, VMT_ROOM,
VMT_EXIT, VMT_ACTION, VMT_AFFECT,VMT_REPOP, VMT_AREA, VMT_ATTACK,
VMT_OBJECT,
VMT_OBJ_TRASH, VMT_OBJ_JEWEL, VMT_OBJ_GOLD,
VMT_OBJ_CONTAINER,VMT_OBJ_LIQUID_CONTAINER, VMT_OBJ_ARMOR,
VMT_OBJ_CLOTH, VMT_OBJ_WEAPON, VMT_OBJ_WAND, VMT_OBJ_ORB,
VMT_OBJ_CORPSE,VMT_OBJ_ENERGY, VMT_OBJ_SCROLL, VMT_OBJ_POTION,
VMT_OBJ_FOOD, VMT_OBJ_KEY, VMT_OBJ_STAFF, VMT_OBJ_COMPASS,
VMT_MAX_OBJ,
// native arrays
VMT_ARRAY,
VMT_ARRAY_INT, VMT_ARRAY_FLOAT, VMT_ARRAY_STRING, VMT_ARRAY_VMOBJECT,
VMT_MAX_ARRAY,
// arrays are also vmobjects
VMT_MAX_VMOBJECT,
// Asm object file only
VMT_EXPORT_FUN, VMT_IMPORT_FUN, VMT_IMPORT_INTERFACE,
VMT_CONST_STRING, VMT_IMPORT_STATIC, VMT_FIELD_DATA,
VMT_CLASS_TYPE, VMT_IMPORT_FUN_OR_INTERFACE,
VMT_MAX_TYPE
};
#define IS_VMOBJ( type ) ((type >= VMT_VMOBJECT) && ( type < VMT_MAX_VMOBJECT))
#define IS_ARRAY( type ) ((type >= VMT_ARRAY) && (type < VMT_MAX_ARRAY))
typedef union
{
vmint i;
vmfloat f;
VMObject * o;
String * s;
} vmptr;
typedef struct
{
vmtype type;
vmptr val;
} vmstack;
typedef struct
{
const char * name;
int id;
} fieldmap;
struct s_vmtype_table
{
const char * name;
vmtype parent;
const char * (*setfield) (VMachine * vm, void * obj, int fieldnum, vmptr);
bool (*getfield) ( VMachine * vm, void * obj, int fieldnum);
fieldmap * fieldnames;
};
int vmtype_lookup( const char * );
int fieldname_lookup( vmtype, const char * );
extern struct s_vmtype_table vmtype_table[];
inline bool canCastTo( vmtype from, vmtype to )
{
for ( ; from != VMT_NULL; from = vmtype_table[from].parent)
if ( from == to )
return true;
return false;
}
#endif