| 79 | } |
| 80 | |
| 81 | WasmEdge_ModuleInstanceContext *createSpecTestModule(void) { |
| 82 | WasmEdge_String HostName; |
| 83 | WasmEdge_ModuleInstanceContext *HostMod = NULL; |
| 84 | WasmEdge_FunctionTypeContext *HostFType = NULL; |
| 85 | WasmEdge_TableTypeContext *HostTType = NULL; |
| 86 | WasmEdge_MemoryTypeContext *HostMType = NULL; |
| 87 | WasmEdge_GlobalTypeContext *HostGType = NULL; |
| 88 | WasmEdge_FunctionInstanceContext *HostFunc = NULL; |
| 89 | WasmEdge_TableInstanceContext *HostTable = NULL; |
| 90 | WasmEdge_MemoryInstanceContext *HostMemory = NULL; |
| 91 | WasmEdge_GlobalInstanceContext *HostGlobal = NULL; |
| 92 | WasmEdge_LimitContext *TabLimit = NULL; |
| 93 | WasmEdge_LimitContext *MemLimit = NULL; |
| 94 | WasmEdge_ValType Param[2]; |
| 95 | |
| 96 | HostName = WasmEdge_StringCreateByCString("spectest"); |
| 97 | HostMod = WasmEdge_ModuleInstanceCreate(HostName); |
| 98 | WasmEdge_StringDelete(HostName); |
| 99 | |
| 100 | // Add host function "print": {} -> {} |
| 101 | HostFType = WasmEdge_FunctionTypeCreate(NULL, 0, NULL, 0); |
| 102 | HostFunc = WasmEdge_FunctionInstanceCreate(HostFType, SpecTestPrint, NULL, 0); |
| 103 | WasmEdge_FunctionTypeDelete(HostFType); |
| 104 | HostName = WasmEdge_StringCreateByCString("print"); |
| 105 | WasmEdge_ModuleInstanceAddFunction(HostMod, HostName, HostFunc); |
| 106 | WasmEdge_StringDelete(HostName); |
| 107 | |
| 108 | // Add host function "print_i32": {i32} -> {} |
| 109 | Param[0] = WasmEdge_ValTypeGenI32(); |
| 110 | HostFType = WasmEdge_FunctionTypeCreate(Param, 1, NULL, 0); |
| 111 | HostFunc = |
| 112 | WasmEdge_FunctionInstanceCreate(HostFType, SpecTestPrintI32, NULL, 0); |
| 113 | WasmEdge_FunctionTypeDelete(HostFType); |
| 114 | HostName = WasmEdge_StringCreateByCString("print_i32"); |
| 115 | WasmEdge_ModuleInstanceAddFunction(HostMod, HostName, HostFunc); |
| 116 | WasmEdge_StringDelete(HostName); |
| 117 | |
| 118 | // Add host function "print_i64": {i64} -> {} |
| 119 | Param[0] = WasmEdge_ValTypeGenI64(); |
| 120 | HostFType = WasmEdge_FunctionTypeCreate(Param, 1, NULL, 0); |
| 121 | HostFunc = |
| 122 | WasmEdge_FunctionInstanceCreate(HostFType, SpecTestPrintI64, NULL, 0); |
| 123 | WasmEdge_FunctionTypeDelete(HostFType); |
| 124 | HostName = WasmEdge_StringCreateByCString("print_i64"); |
| 125 | WasmEdge_ModuleInstanceAddFunction(HostMod, HostName, HostFunc); |
| 126 | WasmEdge_StringDelete(HostName); |
| 127 | |
| 128 | // Add host function "print_f32": {f32} -> {} |
| 129 | Param[0] = WasmEdge_ValTypeGenF32(); |
| 130 | HostFType = WasmEdge_FunctionTypeCreate(Param, 1, NULL, 0); |
| 131 | HostFunc = |
| 132 | WasmEdge_FunctionInstanceCreate(HostFType, SpecTestPrintF32, NULL, 0); |
| 133 | WasmEdge_FunctionTypeDelete(HostFType); |
| 134 | HostName = WasmEdge_StringCreateByCString("print_f32"); |
| 135 | WasmEdge_ModuleInstanceAddFunction(HostMod, HostName, HostFunc); |
| 136 | WasmEdge_StringDelete(HostName); |
| 137 | |
| 138 | // Add host function "print_f64": {f64} -> {} |