6 #include <sun/vm/instruction.h>
12 typedef struct SVMVM SVMVM
;
14 typedef struct SVMModule SVMModule
;
15 typedef struct SVMModuleInstance SVMModuleInstance
;
17 typedef struct SVMModuleInstance SVMModuleInstance
;
19 typedef struct SVMPublic SVMPublic
;
21 typedef void *(*SVMCMallocCallback
)(size_t size
, void *userParameter
);
22 typedef void (*SVMFreeCallback
)(void *memory
, void *userParameter
);
24 typedef void (*SVMFunctionCallback
)(SVMModuleInstance
*instance
, int32_t parameterCount
, SVMOperand stack
[]);
25 typedef SVMFunctionCallback (*SVMFunctionLookupCallback
)(uint32_t nameCRC
, void *userParameter
);
27 typedef void (*SVMErrorCallback
)(SVMModuleInstance
*instance
, const char *errorString
, void *userParameter
);
29 //struct SVMVMConfiguration {
30 // SVMCMallocCallback malloc;
31 // SVMFreeCallback free;
32 // SVMCallFunctionCallback lookup;
33 // void *lookupUserParam;
35 //typedef struct SVMVMConfiguration SVMVMConfiguration;
39 SVMRunOutcomeSuspended
,
40 SVMRunOutcomeFinished
,
42 typedef enum SVMRunOutcome SVMRunOutcome
;
44 //extern SVMVM *svmCreateVM(const SVMVMConfiguration *configuration);
46 //extern SVMModuleInstance *svmCreateModuleInstance(SVMVM *vm, SVMModule *module, void *userParam); // fixme, add stack memory??
48 extern size_t svmGetModuleInstanceSize(SVMModule
*module
);
50 extern SVMModuleInstance
*svnResetModuleInstanceMemory(SVMModule
*module
, void *memory
, void *userParameter
, SVMFunctionLookupCallback lookupCallback
);
51 extern void *svmGetModuleInstanceUserParameter(SVMModuleInstance
*instance
);
53 extern SVMRunOutcome
svmRunModuleInstance(SVMModuleInstance
*instance
);
55 extern const char *svmGetString(SVMModuleInstance
*instance
, int32_t ptr
);
57 extern SVMPublic
*svmGetPublicReference(SVMModule
*instance
, const char *nameFmt
, ...);
58 extern SVMOperand
svmGetPublicValue(SVMModuleInstance
*instance
, int32_t ptr
);