MCPcopy Index your code
hub / github.com/endbasic/endbasic / RawValue

Interface RawValue

core/src/bytecode.rs:109–122  ·  view source on GitHub ↗

Conversions between a primitive type and a `u32` for insertion into an instruction.

Source from the content-addressed store, hash-verified

107
108/// Conversions between a primitive type and a `u32` for insertion into an instruction.
109trait RawValue: Sized {
110 /// Converts a `u32` to the primitive type `Self`.
111 ///
112 /// This operation is only performed to _parse_ bytecode and we assume that the bytecode is
113 /// correctly formed. As a result, this does not perform any range checks.
114 fn from_u32(v: u32) -> Self;
115
116 /// Converts the primitive type `Self` to a u32.
117 ///
118 /// This operation is only performed to _generate_ bytecode during compilation, and all
119 /// instruction definitions need to have fields that always fit in a u32. Consequently,
120 /// this operation is always safe.
121 fn to_u32(self) -> u32;
122}
123
124/// Implements `RawValue` for an unsigned primitive type that is narrower than `u32`.
125macro_rules! impl_raw_value {

Callers

nothing calls this directly

Implementers 1

bytecode.rscore/src/bytecode.rs

Calls

no outgoing calls

Tested by

no test coverage detected