Coverage for tests/codegen/generated/records/__init__.py: 98%

96 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-02-20 16:25 +0000

1from .exports import e 

2from .imports import RootImports, host 

3from .intrinsics import _clamp, _store 

4import ctypes 

5import importlib_resources 

6import pathlib 

7import wasmtime 

8 

9class Root: 

10 

11 def __init__(self, store: wasmtime.Store, import_object: RootImports) -> None: 

12 file = importlib_resources.files() / ('root.core0.wasm') 

13 if isinstance(file, pathlib.Path): 

14 module = wasmtime.Module.from_file(store.engine, file) 

15 else: 

16 module = wasmtime.Module(store.engine, file.read_bytes()) 

17 instance0 = wasmtime.Instance(store, module, []).exports(store) 

18 def lowering0_callee(caller: wasmtime.Caller, arg0: int) -> int: 

19 ret = import_object.host.roundtrip_flag1(host.Flag1(arg0)) 

20 return (ret).value 

21 lowering0_ty = wasmtime.FuncType([wasmtime.ValType.i32(), ], [wasmtime.ValType.i32(), ]) 

22 trampoline0 = wasmtime.Func(store, lowering0_ty, lowering0_callee, access_caller = True) 

23 def lowering1_callee(caller: wasmtime.Caller, arg0: int) -> int: 

24 ret = import_object.host.roundtrip_flag2(host.Flag2(arg0)) 

25 return (ret).value 

26 lowering1_ty = wasmtime.FuncType([wasmtime.ValType.i32(), ], [wasmtime.ValType.i32(), ]) 

27 trampoline1 = wasmtime.Func(store, lowering1_ty, lowering1_callee, access_caller = True) 

28 def lowering2_callee(caller: wasmtime.Caller, arg0: int) -> int: 

29 ret = import_object.host.roundtrip_flag8(host.Flag8(arg0)) 

30 return (ret).value 

31 lowering2_ty = wasmtime.FuncType([wasmtime.ValType.i32(), ], [wasmtime.ValType.i32(), ]) 

32 trampoline2 = wasmtime.Func(store, lowering2_ty, lowering2_callee, access_caller = True) 

33 def lowering3_callee(caller: wasmtime.Caller, arg0: int) -> int: 

34 ret = import_object.host.roundtrip_flag16(host.Flag16(arg0)) 

35 return (ret).value 

36 lowering3_ty = wasmtime.FuncType([wasmtime.ValType.i32(), ], [wasmtime.ValType.i32(), ]) 

37 trampoline3 = wasmtime.Func(store, lowering3_ty, lowering3_callee, access_caller = True) 

38 def lowering4_callee(caller: wasmtime.Caller, arg0: int) -> int: 

39 ret = import_object.host.roundtrip_flag32(host.Flag32(arg0)) 

40 return (ret).value 

41 lowering4_ty = wasmtime.FuncType([wasmtime.ValType.i32(), ], [wasmtime.ValType.i32(), ]) 

42 trampoline4 = wasmtime.Func(store, lowering4_ty, lowering4_callee, access_caller = True) 

43 def lowering5_callee(caller: wasmtime.Caller, arg0: int) -> None: 

44 ret = import_object.host.multiple_results() 

45 (tuplei,tuplei0,) = ret 

46 _store(ctypes.c_uint8, self._core_memory0, caller, arg0, 0, _clamp(tuplei, 0, 255)) 

47 _store(ctypes.c_uint16, self._core_memory0, caller, arg0, 2, _clamp(tuplei0, 0, 65535)) 

48 lowering5_ty = wasmtime.FuncType([wasmtime.ValType.i32(), ], []) 

49 trampoline5 = wasmtime.Func(store, lowering5_ty, lowering5_callee, access_caller = True) 

50 core_memory0 = instance0["mem"] 

51 assert(isinstance(core_memory0, wasmtime.Memory)) 

52 self._core_memory0 = core_memory0 

53 def lowering6_callee(caller: wasmtime.Caller, arg0: int, arg1: int, arg2: int) -> None: 

54 ret = import_object.host.swap((_clamp(arg0, 0, 255), arg1 & 0xffffffff,)) 

55 (tuplei,tuplei0,) = ret 

56 _store(ctypes.c_uint8, self._core_memory0, caller, arg2, 0, _clamp(tuplei, 0, 255)) 

57 _store(ctypes.c_uint32, self._core_memory0, caller, arg2, 4, _clamp(tuplei0, 0, 4294967295)) 

58 lowering6_ty = wasmtime.FuncType([wasmtime.ValType.i32(), wasmtime.ValType.i32(), wasmtime.ValType.i32(), ], []) 

59 trampoline6 = wasmtime.Func(store, lowering6_ty, lowering6_callee, access_caller = True) 

60 def lowering7_callee(caller: wasmtime.Caller, arg0: int, arg1: int, arg2: int) -> None: 

61 ret = import_object.host.roundtrip_r1(host.R1(_clamp(arg0, 0, 255), host.Flag1(arg1))) 

62 record = ret 

63 field = record.a 

64 field0 = record.b 

65 _store(ctypes.c_uint8, self._core_memory0, caller, arg2, 0, _clamp(field, 0, 255)) 

66 _store(ctypes.c_uint8, self._core_memory0, caller, arg2, 1, (field0).value) 

67 lowering7_ty = wasmtime.FuncType([wasmtime.ValType.i32(), wasmtime.ValType.i32(), wasmtime.ValType.i32(), ], []) 

68 trampoline7 = wasmtime.Func(store, lowering7_ty, lowering7_callee, access_caller = True) 

69 file = importlib_resources.files() / ('root.core1.wasm') 

70 if isinstance(file, pathlib.Path): 

71 module = wasmtime.Module.from_file(store.engine, file) 

72 else: 

73 module = wasmtime.Module(store.engine, file.read_bytes()) 

74 instance1 = wasmtime.Instance(store, module, [ 

75 trampoline0, 

76 trampoline1, 

77 trampoline2, 

78 trampoline3, 

79 trampoline4, 

80 trampoline5, 

81 trampoline6, 

82 trampoline7, 

83 instance0["mem"], 

84 ]).exports(store) 

85 lift_callee0 = instance1["multi"] 

86 assert(isinstance(lift_callee0, wasmtime.Func)) 

87 self.lift_callee0 = lift_callee0 

88 lift_callee1 = instance1["r-flag2"] 

89 assert(isinstance(lift_callee1, wasmtime.Func)) 

90 self.lift_callee1 = lift_callee1 

91 lift_callee2 = instance1["r-flag8"] 

92 assert(isinstance(lift_callee2, wasmtime.Func)) 

93 self.lift_callee2 = lift_callee2 

94 lift_callee3 = instance1["r-flag1"] 

95 assert(isinstance(lift_callee3, wasmtime.Func)) 

96 self.lift_callee3 = lift_callee3 

97 lift_callee4 = instance1["r-flag16"] 

98 assert(isinstance(lift_callee4, wasmtime.Func)) 

99 self.lift_callee4 = lift_callee4 

100 lift_callee5 = instance1["r-r1"] 

101 assert(isinstance(lift_callee5, wasmtime.Func)) 

102 self.lift_callee5 = lift_callee5 

103 lift_callee6 = instance1["r-flag32"] 

104 assert(isinstance(lift_callee6, wasmtime.Func)) 

105 self.lift_callee6 = lift_callee6 

106 lift_callee7 = instance1["swap"] 

107 assert(isinstance(lift_callee7, wasmtime.Func)) 

108 self.lift_callee7 = lift_callee7 

109 def e(self) -> e.E: 

110 return e.E(self)