address¶
type address
An address represents a read-only bounded section of memory.
meth address(String: string): address
Returns an address view of
String
.address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A>
meth (Arg₁: address) != (Arg₂: address): address | nil
Returns
Arg₂
if the bytes atArg₁
!= the bytes atArg₂
andnil
otherwise."Hello" != "World" :> "World" "World" != "Hello" :> "Hello" "Hello" != "Hello" :> nil "abcd" != "abc" :> "abc" "abc" != "abcd" :> "abcd"
meth (Address: address) + (Offset: integer): address
Returns the address at offset
Offset
fromAddress
.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A + 4 :> <9:6F20776F726C64210A>
meth (Address₁: address) - (Address₂: address): integer
Returns the offset from
Address₂
toAddress₁
, providedAddress₂
is visible toAddress₁
.let A := address("Hello world!\n") let B := A + 4 B - A :> 4 address("world!\n") - A :> error("ValueError", "Addresses are not from same base")
meth (Arg₁: address) < (Arg₂: address): address | nil
Returns
Arg₂
if the bytes atArg₁
< the bytes atArg₂
andnil
otherwise."Hello" < "World" :> "World" "World" < "Hello" :> nil "Hello" < "Hello" :> nil "abcd" < "abc" :> nil "abc" < "abcd" :> "abcd"
meth (Arg₁: address) <= (Arg₂: address): address | nil
Returns
Arg₂
if the bytes atArg₁
<= the bytes atArg₂
andnil
otherwise."Hello" <= "World" :> "World" "World" <= "Hello" :> nil "Hello" <= "Hello" :> "Hello" "abcd" <= "abc" :> nil "abc" <= "abcd" :> "abcd"
meth (A: address) <> (B: address): integer
Compares the bytes at
A
andB
lexicographically and returns-1
,0
or1
respectively."Hello" <> "World" :> -1 "World" <> "Hello" :> 1 "Hello" <> "Hello" :> 0 "abcd" <> "abc" :> 1 "abc" <> "abcd" :> -1
meth (Arg₁: address) = (Arg₂: address): address | nil
Returns
Arg₂
if the bytes atArg₁
= the bytes atArg₂
andnil
otherwise."Hello" = "World" :> nil "World" = "Hello" :> nil "Hello" = "Hello" :> "Hello" "abcd" = "abc" :> nil "abc" = "abcd" :> nil
meth (Arg₁: address) > (Arg₂: address): address | nil
Returns
Arg₂
if the bytes atArg₁
> the bytes atArg₂
andnil
otherwise."Hello" > "World" :> nil "World" > "Hello" :> "Hello" "Hello" > "Hello" :> nil "abcd" > "abc" :> "abc" "abc" > "abcd" :> nil
meth (Arg₁: address) >= (Arg₂: address): address | nil
Returns
Arg₂
if the bytes atArg₁
>= the bytes atArg₂
andnil
otherwise."Hello" >= "World" :> nil "World" >= "Hello" :> "Hello" "Hello" >= "Hello" :> "Hello" "abcd" >= "abc" :> "abc" "abc" >= "abcd" :> nil
meth (Address: address) @ (Length: integer): address
Returns the same address as
Address
, limited toLength
bytes.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A @ 5 :> <5:48656C6C6F>
meth (Address: address) @ (Offset: integer, Length: integer): address
Returns the address at offset
Offset
fromAddress
limited toLength
bytes.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A @ (4, 4) :> <4:6F20776F>
meth (Haystack: address):find(Needle: address): integer | nil
Returns the offset of the first occurence of the bytes of
Needle
inHaystack
ornil
is no occurence is found.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:find("world") :> 6 A:find("other") :> nil
meth (Address: address):get16: integer
Returns the signed 16-bit value at
Address
. Currently follows the platform endiness.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:get16 :> 25928
meth (Address: address):get32: integer
Returns the signed 32-bit value at
Address
. Currently follows the platform endiness.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:get32 :> 1819043144
meth (Address: address):get64: integer
Returns the signed 64-bit value at
Address
. Currently follows the platform endiness.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:get64 :> 8031924123371070792
meth (Address: address):get8: integer
Returns the signed 8-bit value at
Address
.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:get8 :> 72
meth (Address: address):getf32: real
Returns the single precision floating point value at
Address
. Currently follows the platform endiness.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:getf32 :> 1.14313912243758e+27
meth (Address: address):getf64: real
Returns the double precision floating point value at
Address
. Currently follows the platform endiness.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:getf64 :> 8.76577647882785e+228
meth (Address: address):gets: string
Returns the string consisting of the bytes at
Address
.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:gets :> "Hello world!\n"
meth (Address: address):gets(Size: integer): string
Returns the string consisting of the first
Size
bytes atAddress
.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:gets(5) :> "Hello"
meth (Address: address):getu16: integer
Returns the unsigned 16-bit value at
Address
. Currently follows the platform endiness.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:getu16 :> 25928
meth (Address: address):getu32: integer
Returns the unsigned 32-bit value at
Address
. Currently follows the platform endiness.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:getu32 :> 1819043144
meth (Address: address):getu64: integer
Returns the unsigned 64-bit value at
Address
. Currently follows the platform endiness. .. warning:Minilang currently uses signed 64-bit integers so this method will produce incorrect results if the actual value is too large to fit. This may change in future implementations or if arbitrary precision integers are added to the runtime.
let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:getu64 :> 8031924123371070792
meth (Address: address):getu8: integer
Returns the unsigned 8-bit value at
Address
.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:getu8 :> 72
meth (Address: address):length: integer
Returns the number of bytes visible at
Address
.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:length :> 13
meth (Address: address):size: integer
Returns the number of bytes visible at
Address
.let A := address("Hello world!\n") :> <13:48656C6C6F20776F726C64210A> A:size :> 13
meth (Buffer: string::buffer):append(Value: address)
Appends the contents of
Value
toBuffer
.