Package convex.core.lang.ops
Class Lambda<T extends ACell>
- Type Parameters:
T
- Result type of Closure
- All Implemented Interfaces:
IValidated
,IWriteable
Op responsible for creating a new function (closure).
Captures value of local variable bindings during execution.
Equivalent to (fn [...] ...)
-
Field Summary
Fields inherited from class convex.core.data.ACell
cachedRef, memorySize
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
encodeRaw
(byte[] bs, int pos) Writes the raw data for this Op to the specified bytebuffer.Executes this op with the given context.getRef
(int i) Gets a numbered child Ref from within this Cell.int
Gets the number of Refs contained within this Cell.byte
opCode()
Returns the opcode for this opboolean
print
(BlobBuilder sb, long limit) Prints this Object to a readable String Representation.updateRefs
(IRefFunction func) Updates all Refs in this object using the given function.void
validate()
Validates the complete structure of this object.void
Validates the local structure and invariants of this cell.Methods inherited from class convex.core.lang.AOp
encode, equals, estimatedEncodingSize, 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
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print
-
Constructor Details
-
Lambda
-
-
Method Details
-
create
-
create
-
execute
Description copied from class:AOp
Executes this op with the given context. Must preserve depth unless an exceptional is returned. -
getRefCount
public int getRefCount()Description copied from class:ACell
Gets the number of Refs contained within this Cell. This number is final / immutable for any given instance and is defined by the Cell encoding rules. Contained Refs may be either external or embedded.- Overrides:
getRefCount
in classACell
- Returns:
- The number of Refs in this Cell
-
getRef
Description copied from class:ACell
Gets a numbered child Ref from within this Cell. WARNING: May need to convert to a canonical instance -
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.- Specified by:
updateRefs
in classAOp<AClosure<T extends ACell>>
- Parameters:
func
- Ref update function- Returns:
- Cell with updated Refs
-
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
-
encodeRaw
public int encodeRaw(byte[] bs, int pos) Description copied from class:AOp
Writes the raw data for this Op to the specified bytebuffer. Assumes Op tag and opcode already written. -
read
- Throws:
BadFormatException
-
validate
Description copied from interface:IValidated
Validates the complete structure of this object. It is necessary to ensure all child Refs are validated, so the general contract for validate is:- Call super.validate() - which will indirectly call validateCell()
- Call validate() on any contained cells in this class
- Specified by:
validate
in interfaceIValidated
- Overrides:
validate
in classACell
- Throws:
InvalidDataException
- If the data Value is invalid in any way
-
validateCell
Description copied from class:ACell
Validates the local structure and invariants of this cell. Called by validate() super implementation. Should validate directly contained data, but should not validate all other structure of this cell. In particular, should not traverse potentially missing child Refs.- Specified by:
validateCell
in classACell
- Throws:
InvalidDataException
- If the Cell is invalid
-
getFunction
-