nupp.runtime.representation.spi

Implementation interfaces consumed during ordinary module initialization. Discover with nupp.spi.load; the consumer chooses the unique highest priority. Omitted priority is zero. Importing these declarations loads no implementation.

Module contents

Types

TypeKindDescription
CastElementstypeCasts storage to elements of any supplied ctype.
CstorageProviderinterfaceOne coherent family of physical storage operations.
Int64Providerinterface64-bit signed and unsigned arithmetic for generated portable operations.
StructvalueProviderinterfaceStruct-value operations supplied as part of the storage family.
WasmProviderinterfaceOpaque linear-memory operations belonging to a storage implementation.

Types#

CastElementstype#

type CastElements = function<T>(element: ctype<T>, pointer: any): any

Casts storage to elements of any supplied ctype.

The implementation must remain generic in T and use the target's representation; accepting one particular element type is not sufficient.

CstorageProviderinterface#

interface CstorageProvider ...

One coherent family of physical storage operations.

representation is native for native pointers or linear32 for 32-bit linear memory. The facade checks it against the target before publishing this table. Linear32 implementations must also supply layout, reference, integers, structs, and host. Their structs must be reference-valued. The integer facade must use the exact integer provider attached to this storage family.

Allocation, descriptors, scalar codecs, and copies must agree on byte order, alignment, width, and pointer units. Decode inputs contain at least the scalar width in bytes. Borrowed views preserve source lifetimes; borrows, generic casts, and const views are part of the implementation contract. Opaque values in these signatures carry provider storage, not permission to change a compiled representation at runtime.

Members

NameKindDescription
priorityfield
boundedCountmethodReturns the requested count after any representation-specific extent check.
representationfieldTarget pointer/layout convention: native or linear32.
integersfieldInteger operations sharing this storage representation; required for linear32.
structsfieldStruct descriptors and row operations sharing this storage family.
hostfieldOpaque memory-host operations sharing these allocations and pointers.
layoutfieldReturns target layout facts for a type or descriptor; required for linear32.
scalarmethodReturns the canonical descriptor for a scalar kind within this provider.
descriptormethodReports layout and bounds for a provider value.
referencefieldCreates a deferred descriptor reference for recursive layouts.
allocateArraymethodAllocates count elements of the supplied descriptor.
allocateBytesmethodAllocates a writable byte region containing count bytes.
borrowStringmethodReturns a read-only byte view whose lifetime borrows the source string.
castBytesmethodReturns a read-only byte view borrowing the pointer owner.
castElementsfieldInterprets a pointer using any supplied element ctype.
copymethodCopies count bytes into destination without replacing its owner.
fillmethodFills count bytes in destination with the given byte value.
sizeOfmethodReturns the descriptor size in bytes.
stringmethodCopies count source bytes into an independent Lua string.
decodeUint8methodDecodes one unsigned 8-bit integer using the target storage byte order.
encodeUint8methodEncodes one unsigned 8-bit integer using the target storage byte order.
decodeInt8methodDecodes one signed 8-bit integer using the target storage byte order.
encodeInt8methodEncodes one signed 8-bit integer using the target storage byte order.
decodeUint16methodDecodes one unsigned 16-bit integer using the target storage byte order.
encodeUint16methodEncodes one unsigned 16-bit integer using the target storage byte order.
decodeInt16methodDecodes one signed 16-bit integer using the target storage byte order.
encodeInt16methodEncodes one signed 16-bit integer using the target storage byte order.
decodeUint32methodDecodes one unsigned 32-bit integer using the target storage byte order.
encodeUint32methodEncodes one unsigned 32-bit integer using the target storage byte order.
decodeInt32methodDecodes one signed 32-bit integer using the target storage byte order.
encodeInt32methodEncodes one signed 32-bit integer using the target storage byte order.
decodeUint64methodDecodes one unsigned 64-bit integer using the target storage byte order.
encodeUint64methodEncodes one unsigned 64-bit integer using the target storage byte order.
decodeInt64methodDecodes one signed 64-bit integer using the target storage byte order.
encodeInt64methodEncodes one signed 64-bit integer using the target storage byte order.
decodeFloat32methodDecodes one IEEE-754 binary32 value using the target storage byte order.
encodeFloat32methodEncodes one IEEE-754 binary32 value using the target storage byte order.
decodeFloat64methodDecodes one IEEE-754 binary64 value using the target storage byte order.
encodeFloat64methodEncodes one IEEE-754 binary64 value using the target storage byte order.

priorityfield#

priority: integer?
@readonly

boundedCountmethod#

boundedCount: function(borrows source: any, count: integer): integer
@readonly

Returns the requested count after any representation-specific extent check. Callers remain responsible for valid native pointer extents.

Arguments
NameTypeDescription
borrows sourceany
countinteger
Returns
TypeDescription
integer

representationfield#

representation: string
@readonly

Target pointer/layout convention: native or linear32.

integersfield#

@readonly

Integer operations sharing this storage representation; required for linear32.

structsfield#

@readonly

Struct descriptors and row operations sharing this storage family.

hostfield#

@readonly

Opaque memory-host operations sharing these allocations and pointers.

layoutfield#

layout: (function(subject: any): any)?
@readonly

Returns target layout facts for a type or descriptor; required for linear32.

scalarmethod#

scalar: function(kind: string): any
@readonly

Returns the canonical descriptor for a scalar kind within this provider.

Arguments
NameTypeDescription
kindstring
Returns
TypeDescription
any

descriptormethod#

descriptor: function(value: any): any
@readonly

Reports layout and bounds for a provider value.

Arguments
NameTypeDescription
valueany
Returns
TypeDescription
any

referencefield#

reference: (function(resolve: function(): any): any)?
@readonly

Creates a deferred descriptor reference for recursive layouts.

allocateArraymethod#

allocateArray: function(element: any, count: integer): any
@readonly

Allocates count elements of the supplied descriptor.

Arguments
NameTypeDescription
elementany
countinteger
Returns
TypeDescription
any

allocateBytesmethod#

allocateBytes: function(count: integer): uint8[?]
@readonly

Allocates a writable byte region containing count bytes.

Arguments
NameTypeDescription
countinteger
Returns
TypeDescription
uint8[?]

borrowStringmethod#

borrowString: function(borrows bytes: string): const uint8[?] borrows (bytes)
@readonly

Returns a read-only byte view whose lifetime borrows the source string.

Arguments
NameTypeDescription
borrows bytesstring
Returns
TypeDescription
const uint8[?] borrows (bytes)

castBytesmethod#

castBytes: function(borrows pointer: any): const uint8[?] borrows (pointer)
@readonly

Returns a read-only byte view borrowing the pointer owner.

Arguments
NameTypeDescription
borrows pointerany
Returns
TypeDescription
const uint8[?] borrows (pointer)

castElementsfield#

castElements: CastElements
@readonly

Interprets a pointer using any supplied element ctype.

copymethod#

copy: function(borrows destination: any, borrows source: any, count: integer): nil
@readonly

Copies count bytes into destination without replacing its owner.

Arguments
NameTypeDescription
borrows destinationany
borrows sourceany
countinteger
Returns
TypeDescription
nil

fillmethod#

fill: function(destination: any, count: integer, value: integer): nil
@readonly

Fills count bytes in destination with the given byte value.

Arguments
NameTypeDescription
destinationany
countinteger
valueinteger
Returns
TypeDescription
nil

sizeOfmethod#

sizeOf: function(element: any): integer
@readonly

Returns the descriptor size in bytes.

Arguments
NameTypeDescription
elementany
Returns
TypeDescription
integer

stringmethod#

string: function(borrows source: any, count: integer): string
@readonly

Copies count source bytes into an independent Lua string.

Arguments
NameTypeDescription
borrows sourceany
countinteger
Returns
TypeDescription
string

decodeUint8method#

decodeUint8: function(bytes: string): uint32
@readonly

Decodes one unsigned 8-bit integer using the target storage byte order.

Arguments
NameTypeDescription
bytesstring
Returns
TypeDescription
uint32

encodeUint8method#

encodeUint8: function(value: uint32): string
@readonly

Encodes one unsigned 8-bit integer using the target storage byte order.

Arguments
NameTypeDescription
valueuint32
Returns
TypeDescription
string

decodeInt8method#

decodeInt8: function(bytes: string): int32
@readonly

Decodes one signed 8-bit integer using the target storage byte order.

Arguments
NameTypeDescription
bytesstring
Returns
TypeDescription
int32

encodeInt8method#

encodeInt8: function(value: int32): string
@readonly

Encodes one signed 8-bit integer using the target storage byte order.

Arguments
NameTypeDescription
valueint32
Returns
TypeDescription
string

decodeUint16method#

decodeUint16: function(bytes: string): uint32
@readonly

Decodes one unsigned 16-bit integer using the target storage byte order.

Arguments
NameTypeDescription
bytesstring
Returns
TypeDescription
uint32

encodeUint16method#

encodeUint16: function(value: uint32): string
@readonly

Encodes one unsigned 16-bit integer using the target storage byte order.

Arguments
NameTypeDescription
valueuint32
Returns
TypeDescription
string

decodeInt16method#

decodeInt16: function(bytes: string): int32
@readonly

Decodes one signed 16-bit integer using the target storage byte order.

Arguments
NameTypeDescription
bytesstring
Returns
TypeDescription
int32

encodeInt16method#

encodeInt16: function(value: int32): string
@readonly

Encodes one signed 16-bit integer using the target storage byte order.

Arguments
NameTypeDescription
valueint32
Returns
TypeDescription
string

decodeUint32method#

decodeUint32: function(bytes: string): uint32
@readonly

Decodes one unsigned 32-bit integer using the target storage byte order.

Arguments
NameTypeDescription
bytesstring
Returns
TypeDescription
uint32

encodeUint32method#

encodeUint32: function(value: uint32): string
@readonly

Encodes one unsigned 32-bit integer using the target storage byte order.

Arguments
NameTypeDescription
valueuint32
Returns
TypeDescription
string

decodeInt32method#

decodeInt32: function(bytes: string): int32
@readonly

Decodes one signed 32-bit integer using the target storage byte order.

Arguments
NameTypeDescription
bytesstring
Returns
TypeDescription
int32

encodeInt32method#

encodeInt32: function(value: int32): string
@readonly

Encodes one signed 32-bit integer using the target storage byte order.

Arguments
NameTypeDescription
valueint32
Returns
TypeDescription
string

decodeUint64method#

decodeUint64: function(bytes: string): uint64
@readonly

Decodes one unsigned 64-bit integer using the target storage byte order.

Arguments
NameTypeDescription
bytesstring
Returns
TypeDescription
uint64

encodeUint64method#

encodeUint64: function(value: uint64): string
@readonly

Encodes one unsigned 64-bit integer using the target storage byte order.

Arguments
NameTypeDescription
valueuint64
Returns
TypeDescription
string

decodeInt64method#

decodeInt64: function(bytes: string): int64
@readonly

Decodes one signed 64-bit integer using the target storage byte order.

Arguments
NameTypeDescription
bytesstring
Returns
TypeDescription
int64

encodeInt64method#

encodeInt64: function(value: int64): string
@readonly

Encodes one signed 64-bit integer using the target storage byte order.

Arguments
NameTypeDescription
valueint64
Returns
TypeDescription
string

decodeFloat32method#

decodeFloat32: function(bytes: string): float
@readonly

Decodes one IEEE-754 binary32 value using the target storage byte order.

Arguments
NameTypeDescription
bytesstring
Returns
TypeDescription
float

encodeFloat32method#

encodeFloat32: function(value: number): string
@readonly

Encodes one IEEE-754 binary32 value using the target storage byte order.

Arguments
NameTypeDescription
valuenumber
Returns
TypeDescription
string

decodeFloat64method#

decodeFloat64: function(bytes: string): number
@readonly

Decodes one IEEE-754 binary64 value using the target storage byte order.

Arguments
NameTypeDescription
bytesstring
Returns
TypeDescription
number

encodeFloat64method#

encodeFloat64: function(value: number): string
@readonly

Encodes one IEEE-754 binary64 value using the target storage byte order.

Arguments
NameTypeDescription
valuenumber
Returns
TypeDescription
string

Int64Providerinterface#

interface Int64Provider ...

64-bit signed and unsigned arithmetic for generated portable operations.

Values must retain their full width rather than round through a Lua number. Arithmetic, comparisons, shifts, and conversions must agree with the signedness created by int64/uint64. toNumber is the explicit potentially inexact conversion. When physical storage supplies integers, this must be that same implementation.

Members

NameKindDescription
priorityfield
int64methodConstructs or converts a signed 64-bit value.
uint64methodConstructs or converts an unsigned 64-bit value.
addmethodAdds two full-width values.
submethodSubtracts the right operand.
mulmethodMultiplies full-width values.
divmethodDivides using the integer representation semantics.
modmethodComputes the corresponding integer remainder.
powmethodRaises to an integer power.
negmethodNegates the value.
bandmethodComputes 64-bit conjunction.
bormethodComputes 64-bit disjunction.
bxormethodComputes 64-bit exclusive-or.
bnotmethodInverts all 64 bits.
lshiftmethodShifts left within the 64-bit representation.
rshiftmethodShifts right with zero fill.
arshiftmethodShifts right with sign extension.
comparemethodReturns a negative number, zero, or a positive number for ordering.
toNumbermethodConverts to a Lua number, which may lose integer precision.
toStringmethodReturns an exact decimal representation.

priorityfield#

priority: integer?
@readonly

int64method#

int64: function(value: any): any
@readonly

Constructs or converts a signed 64-bit value.

Arguments
NameTypeDescription
valueany
Returns
TypeDescription
any

uint64method#

uint64: function(value: any): any
@readonly

Constructs or converts an unsigned 64-bit value.

Arguments
NameTypeDescription
valueany
Returns
TypeDescription
any

addmethod#

add: function(left: any, right: any): any
@readonly

Adds two full-width values.

Arguments
NameTypeDescription
leftany
rightany
Returns
TypeDescription
any

submethod#

sub: function(left: any, right: any): any
@readonly

Subtracts the right operand.

Arguments
NameTypeDescription
leftany
rightany
Returns
TypeDescription
any

mulmethod#

mul: function(left: any, right: any): any
@readonly

Multiplies full-width values.

Arguments
NameTypeDescription
leftany
rightany
Returns
TypeDescription
any

divmethod#

div: function(left: any, right: any): any
@readonly

Divides using the integer representation semantics.

Arguments
NameTypeDescription
leftany
rightany
Returns
TypeDescription
any

modmethod#

mod: function(left: any, right: any): any
@readonly

Computes the corresponding integer remainder.

Arguments
NameTypeDescription
leftany
rightany
Returns
TypeDescription
any

powmethod#

pow: function(left: any, right: any): any
@readonly

Raises to an integer power.

Arguments
NameTypeDescription
leftany
rightany
Returns
TypeDescription
any

negmethod#

neg: function(value: any): any
@readonly

Negates the value.

Arguments
NameTypeDescription
valueany
Returns
TypeDescription
any

bandmethod#

band: function(left: any, right: any): any
@readonly

Computes 64-bit conjunction.

Arguments
NameTypeDescription
leftany
rightany
Returns
TypeDescription
any

bormethod#

bor: function(left: any, right: any): any
@readonly

Computes 64-bit disjunction.

Arguments
NameTypeDescription
leftany
rightany
Returns
TypeDescription
any

bxormethod#

bxor: function(left: any, right: any): any
@readonly

Computes 64-bit exclusive-or.

Arguments
NameTypeDescription
leftany
rightany
Returns
TypeDescription
any

bnotmethod#

bnot: function(value: any): any
@readonly

Inverts all 64 bits.

Arguments
NameTypeDescription
valueany
Returns
TypeDescription
any

lshiftmethod#

lshift: function(value: any, count: number): any
@readonly

Shifts left within the 64-bit representation.

Arguments
NameTypeDescription
valueany
countnumber
Returns
TypeDescription
any

rshiftmethod#

rshift: function(value: any, count: number): any
@readonly

Shifts right with zero fill.

Arguments
NameTypeDescription
valueany
countnumber
Returns
TypeDescription
any

arshiftmethod#

arshift: function(value: any, count: number): any
@readonly

Shifts right with sign extension.

Arguments
NameTypeDescription
valueany
countnumber
Returns
TypeDescription
any

comparemethod#

compare: function(left: any, right: any): number
@readonly

Returns a negative number, zero, or a positive number for ordering.

Arguments
NameTypeDescription
leftany
rightany
Returns
TypeDescription
number

toNumbermethod#

toNumber: function(value: any): number
@readonly

Converts to a Lua number, which may lose integer precision.

Arguments
NameTypeDescription
valueany
Returns
TypeDescription
number

toStringmethod#

toString: function(value: any): string
@readonly

Returns an exact decimal representation.

Arguments
NameTypeDescription
valueany
Returns
TypeDescription
string

StructvalueProviderinterface#

interface StructvalueProvider ...

Struct-value operations supplied as part of the storage family.

Descriptors, arrays, and constructed values must agree with compiler layouts and canonical struct declarations. referenceValued reports whether a row reference addresses the underlying storage. The storage implementation supplies compatible struct operations as part of the same family.

Members

NameKindDescription
scalarmethodReturns a scalar descriptor accepted by define and array.
arraymethodAllocates count elements using this family's element descriptor.
definemethodConstructs a type descriptor from a compiler layout and method table.
referenceValuedfieldWhether row references address their underlying storage.

scalarmethod#

scalar: function(kind: string): any
@readonly

Returns a scalar descriptor accepted by define and array.

Arguments
NameTypeDescription
kindstring
Returns
TypeDescription
any

arraymethod#

array: function(element: any, count: integer): any
@readonly

Allocates count elements using this family's element descriptor.

Arguments
NameTypeDescription
elementany
countinteger
Returns
TypeDescription
any

definemethod#

define: function(layout: any, methods: table): any
@readonly

Constructs a type descriptor from a compiler layout and method table.

Arguments
NameTypeDescription
layoutany
methodstable
Returns
TypeDescription
any

referenceValuedfield#

referenceValued: boolean
@readonly

Whether row references address their underlying storage.

WasmProviderinterface#

interface WasmProvider ...

Opaque linear-memory operations belonging to a storage implementation.

Allocation and pointer values must refer to that implementation's memory host. Offsets and copy lengths are bytes; pointer's index/stride pair locates an element in an allocation. Loads and stores use the scalar kind's width and encoding. Bounds and owner lifetimes must remain valid across every operation. This interface is supplied through CstorageProvider.host, not a separate SPI.

Members

NameKindDescription
allocatemethodAllocates the requested number of bytes in this memory host.
pointermethodLocates a zero-based element using index and byte stride.
offsetmethodOffsets an existing pointer by count bytes.
loadmethodReads a scalar kind at a byte offset from the pointer.
storemethodWrites a scalar kind at a byte offset from the pointer.
copymethodCopies bytes between regions belonging to this host.
descriptormethodReturns bounds and layout information for a host value.

allocatemethod#

allocate: function(bytes: integer): any
@readonly

Allocates the requested number of bytes in this memory host.

Arguments
NameTypeDescription
bytesinteger
Returns
TypeDescription
any

pointermethod#

pointer: function(allocation: any, index: integer, stride: integer): any
@readonly

Locates a zero-based element using index and byte stride.

Arguments
NameTypeDescription
allocationany
indexinteger
strideinteger
Returns
TypeDescription
any

offsetmethod#

offset: function(pointer: any, count: integer): any
@readonly

Offsets an existing pointer by count bytes.

Arguments
NameTypeDescription
pointerany
countinteger
Returns
TypeDescription
any

loadmethod#

load: function(pointer: any, byteOffset: integer, kind: string): any
@readonly

Reads a scalar kind at a byte offset from the pointer.

Arguments
NameTypeDescription
pointerany
byteOffsetinteger
kindstring
Returns
TypeDescription
any

storemethod#

store: function(pointer: any, byteOffset: integer, kind: string, value: any): nil
@readonly

Writes a scalar kind at a byte offset from the pointer.

Arguments
NameTypeDescription
pointerany
byteOffsetinteger
kindstring
valueany
Returns
TypeDescription
nil

copymethod#

copy: function(destination: any, source: any, bytes: integer): nil
@readonly

Copies bytes between regions belonging to this host.

Arguments
NameTypeDescription
destinationany
sourceany
bytesinteger
Returns
TypeDescription
nil

descriptormethod#

descriptor: function(value: any): any
@readonly

Returns bounds and layout information for a host value.

Arguments
NameTypeDescription
valueany
Returns
TypeDescription
any