]> git.bts.cx Git - sun.git/blob - runtime/src/sun/vm/vm.h
do not evaluate variables until they are used
[sun.git] / runtime / src / sun / vm / vm.h
1 #ifndef SUN_VM_VM_H
2 #define SUN_VM_VM_H
3
4 #include <stddef.h>
5 #include <stdint.h>
6 #include <sun/vm/instruction.h>
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 typedef struct SVMVM SVMVM;
13
14 typedef struct SVMModule SVMModule;
15 typedef struct SVMModuleInstance SVMModuleInstance;
16
17 typedef struct SVMModuleInstance SVMModuleInstance;
18
19 typedef struct SVMPublic SVMPublic;
20
21 typedef void *(*SVMCMallocCallback)(size_t size, void *userParameter);
22 typedef void (*SVMFreeCallback)(void *memory, void *userParameter);
23
24 typedef void (*SVMFunctionCallback)(SVMModuleInstance *instance, int32_t parameterCount, SVMOperand stack[]);
25 typedef SVMFunctionCallback (*SVMFunctionLookupCallback)(uint32_t nameCRC, void *userParameter);
26
27 typedef void (*SVMErrorCallback)(SVMModuleInstance *instance, const char *errorString, void *userParameter);
28
29 //struct SVMVMConfiguration {
30 // SVMCMallocCallback malloc;
31 // SVMFreeCallback free;
32 // SVMCallFunctionCallback lookup;
33 // void *lookupUserParam;
34 //};
35 //typedef struct SVMVMConfiguration SVMVMConfiguration;
36
37 enum SVMRunOutcome {
38 SVMRunOutcomeError,
39 SVMRunOutcomeSuspended,
40 SVMRunOutcomeFinished,
41 };
42 typedef enum SVMRunOutcome SVMRunOutcome;
43
44 //extern SVMVM *svmCreateVM(const SVMVMConfiguration *configuration);
45
46 //extern SVMModuleInstance *svmCreateModuleInstance(SVMVM *vm, SVMModule *module, void *userParam); // fixme, add stack memory??
47
48 extern size_t svmGetModuleInstanceSize(SVMModule *module);
49
50 extern SVMModuleInstance *svnResetModuleInstanceMemory(SVMModule *module, void *memory, void *userParameter, SVMFunctionLookupCallback lookupCallback);
51 extern void *svmGetModuleInstanceUserParameter(SVMModuleInstance *instance);
52
53 extern SVMRunOutcome svmRunModuleInstance(SVMModuleInstance *instance);
54
55 extern const char *svmGetString(SVMModuleInstance *instance, int32_t ptr);
56
57 extern SVMPublic *svmGetPublicReference(SVMModule *instance, const char *nameFmt, ...);
58 extern SVMOperand svmGetPublicValue(SVMModuleInstance *instance, int32_t ptr);
59
60 #ifdef __cplusplus
61 }
62 #endif
63
64 #endif