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, EMPTY_ARRAY
-
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 opvoid
print(StringBuilder sb)
Prints this Object to a readable String Representationread(ByteBuffer b)
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, getTag, getType, isCanonical, isCVMValue, toCanonical
Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, equals, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, hashCode, isEmbedded, mark, mark, toString, validate, write
Methods inherited from class convex.core.data.AObject
attachEncoding, print
-
Constructor Details
-
Cond
-
-
Method Details
-
create
Create a Cond operation with the given nested operations- Type Parameters:
T
- Return type of Cond- Parameters:
ops
- Ops to execute conditionally- Returns:
- Cond instance
-
recreate
Description copied from class:AMultiOp
Recreates this object with an updated list of child Ops. -
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 -
opCode
public byte opCode()Description copied from class:AOp
Returns the opcode for this op -
read
- Throws:
BadFormatException
-
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. 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
-