Package convex.core.lang.ops
Class Cond<T extends ACell>
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.lang.AOp<T>
convex.core.lang.ops.AMultiOp<T>
convex.core.lang.ops.Cond<T>
- Type Parameters:
T
- Result type of Op
- All Implemented Interfaces:
IValidated
,IWriteable
Op representing a conditional expression.
Child ops:
1. Should be condition / result pairs (with an optional single default result).
2. Are executed in sequence until the first condition succeeds
3. Are only executed if required, i.e. cond operates as a "short-circuiting" conditional.
-
Field Summary
Fields inherited from class convex.core.data.ACell
cachedRef, memorySize
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a Cond operation with the given nested operationsExecutes this op with the given context.byte
opCode()
Returns the opcode for this opboolean
print
(BlobBuilder sb, long limit) Prints this Object to a readable String Representation.Decodes a Cond op from a Blob encoding.Recreates this object with an updated list of child Ops.updateRefs
(IRefFunction func) Updates all Refs in this object using the given function.Methods inherited from class convex.core.lang.ops.AMultiOp
encodeRaw, estimatedEncodingSize, getRef, getRefCount, validateCell
Methods inherited from class convex.core.lang.AOp
encode, equals, getTag, getType, isCanonical, isCVMValue, isDataValue, toCanonical
Methods inherited from class convex.core.data.ACell
attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createEncoding, createRef, equals, genericEquals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getMemorySize, getRef, hashCode, isEmbedded, toCVMString, toString, validate
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print
-
Constructor Details
-
Cond
-
-
Method Details
-
create
-
recreate
-
create
-
execute
Description copied from class:AOp
Executes this op with the given context. Must preserve depth unless an exceptional is returned. -
print
Description copied from class:AObject
Prints this Object to a readable String Representation. SECURITY: Must halt and return false in O(1) time when limit of printing is exceeded otherwise DoS attacks may be possible. -
opCode
-
read
Decodes a Cond op from a Blob encoding.- Parameters:
b
- Blob to read frompos
- Start position in Blob (location of tag byte)- Returns:
- New decoded instance
- Throws:
BadFormatException
- In the event of any encoding error
-
updateRefs
Description copied from class:ACell
Updates all Refs in this object using the given function. The function *must not* change the hash value of Refs, in order to ensure structural integrity of modified data structures. The implementation *should* re-attach any original encoding in order to prevent re-encoding or surplus hashing This is a building block for a very sneaky trick that enables use to do a lot of efficient operations on large trees of smart references. Must return the same object if no Refs are altered.- Overrides:
updateRefs
in classAMultiOp<T extends ACell>
- Parameters:
func
- Ref update function- Returns:
- Cell with updated Refs
-