Host ABI definition and ergonomics in TC
This commit is contained in:
@@ -51,3 +51,86 @@ runArboricxArgsByName = (nameBytes bs args :
|
||||
|
||||
runArboricxArgs = (bs args :
|
||||
runArboricxArgsByName [] bs args)
|
||||
|
||||
errHostCodecFailed = 14
|
||||
|
||||
hostTreeTag = 0
|
||||
hostStringTag = 1
|
||||
hostNumberTag = 2
|
||||
hostBoolTag = 3
|
||||
hostListTag = 4
|
||||
hostBytesTag = 5
|
||||
|
||||
hostTree = (value : pair hostTreeTag value)
|
||||
hostString = (bytes : pair hostStringTag bytes)
|
||||
hostNumber = (n : pair hostNumberTag n)
|
||||
hostBool = (b : pair hostBoolTag b)
|
||||
hostList = (xs : pair hostListTag xs)
|
||||
hostBytes = (bytes : pair hostBytesTag bytes)
|
||||
|
||||
hostValueTag = (hostValue : pairFirst hostValue)
|
||||
hostValuePayload = (hostValue : pairSecond hostValue)
|
||||
|
||||
hostBool? = (value : or? (equal? value false) (equal? value true))
|
||||
|
||||
hostNumber? = y (self value :
|
||||
triage
|
||||
true
|
||||
(_ : false)
|
||||
(bit rest :
|
||||
and?
|
||||
(or? (equal? bit false) (equal? bit true))
|
||||
(self rest))
|
||||
value)
|
||||
|
||||
hostList? = y (self value :
|
||||
triage
|
||||
true
|
||||
(_ : false)
|
||||
(_ rest : self rest)
|
||||
value)
|
||||
|
||||
hostString? = y (self value :
|
||||
matchList
|
||||
true
|
||||
(byte rest : and? (hostNumber? byte) (self rest))
|
||||
value)
|
||||
|
||||
hostBytes? = hostString?
|
||||
|
||||
wrapHostValue = (validator wrapper resultValue rest :
|
||||
matchBool
|
||||
(ok (wrapper resultValue) rest)
|
||||
(err errHostCodecFailed resultValue)
|
||||
(validator resultValue))
|
||||
|
||||
runArboricxByNameToTree = (nameBytes bs args :
|
||||
bindResult (runArboricxArgsByName nameBytes bs args)
|
||||
(value rest : ok (hostTree value) rest))
|
||||
|
||||
runArboricxByNameToString = (nameBytes bs args :
|
||||
bindResult (runArboricxArgsByName nameBytes bs args)
|
||||
(value rest : wrapHostValue hostString? hostString value rest))
|
||||
|
||||
runArboricxByNameToNumber = (nameBytes bs args :
|
||||
bindResult (runArboricxArgsByName nameBytes bs args)
|
||||
(value rest : wrapHostValue hostNumber? hostNumber value rest))
|
||||
|
||||
runArboricxByNameToBool = (nameBytes bs args :
|
||||
bindResult (runArboricxArgsByName nameBytes bs args)
|
||||
(value rest : wrapHostValue hostBool? hostBool value rest))
|
||||
|
||||
runArboricxByNameToList = (nameBytes bs args :
|
||||
bindResult (runArboricxArgsByName nameBytes bs args)
|
||||
(value rest : wrapHostValue hostList? hostList value rest))
|
||||
|
||||
runArboricxByNameToBytes = (nameBytes bs args :
|
||||
bindResult (runArboricxArgsByName nameBytes bs args)
|
||||
(value rest : wrapHostValue hostBytes? hostBytes value rest))
|
||||
|
||||
runArboricxToTree = (bs args : runArboricxByNameToTree [] bs args)
|
||||
runArboricxToString = (bs args : runArboricxByNameToString [] bs args)
|
||||
runArboricxToNumber = (bs args : runArboricxByNameToNumber [] bs args)
|
||||
runArboricxToBool = (bs args : runArboricxByNameToBool [] bs args)
|
||||
runArboricxToList = (bs args : runArboricxByNameToList [] bs args)
|
||||
runArboricxToBytes = (bs args : runArboricxByNameToBytes [] bs args)
|
||||
|
||||
Reference in New Issue
Block a user