Package convex.core.lang
Class AOp<T extends ACell>
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.lang.AOp<T>
- Type Parameters:
T- the type of the operation return value
- All Implemented Interfaces:
IValidated,IWriteable
Abstract base class for CVM operations
"...that was the big revelation to me when I was in graduate school—when I
finally understood that the half page of code on the bottom of page 13 of the
Lisp 1.5 manual was Lisp in itself. These were “Maxwell’s Equations of
Software!” This is the whole world of programming in a few lines that I can
put my hand over."
- Alan Kay
-
Field Summary
Fields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal intencode(byte[] bs, int pos) Writes this Cell's encoding to a byte array, including a tag byte which will be written first.abstract intencodeRaw(byte[] bs, int pos) Writes the raw data for this Op to the specified bytebuffer.intEstimate the encoded data size for this Cell.Executes this op with the given context.bytegetTag()Gets the tag byte for this cell.final ATypegetType()Gets the most specific known runtime Type for this Cell.booleanReturns true if this Cell is in a canonical representation for message writing.final booleanReturns true if this Cell represents a first class CVM Value.abstract byteopCode()Returns the opcode for this opConverts this Cell to its canonical version.updateRefs(IRefFunction func) Updates all Refs in this object using the given function.Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, equals, equals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, getRefCount, hashCode, isCompletelyEncoded, isEmbedded, mark, mark, toCVMString, toString, validate, validateCell, writeMethods inherited from class convex.core.data.AObject
attachEncoding, print, print, print
-
Constructor Details
-
AOp
public AOp()
-
-
Method Details
-
execute
Executes this op with the given context. Must preserve depth unless an exceptional is returned.- Type Parameters:
I- Type of Context- Parameters:
context- Initial Context- Returns:
- The updated Context after executing this operation
-
getType
Description copied from class:ACellGets the most specific known runtime Type for this Cell. -
estimatedEncodingSize
public int estimatedEncodingSize()Description copied from interface:IWriteableEstimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is likely to contain the entire object when represented in binary format, including the tag byte.- Returns:
- The estimated size for the binary representation of this object.
-
isCanonical
public boolean isCanonical()Description copied from class:ACellReturns true if this Cell is in a canonical representation for message writing. Non-canonical objects may be used on a temporary internal basis, they must always be converted to canonical representations for external use (e.g. Encoding).- Specified by:
isCanonicalin classACell- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACellConverts this Cell to its canonical version. Returns this Cell if already canonical, may be O(n) in size of value otherwise.- Specified by:
toCanonicalin classACell- Returns:
- Canonical version of Cell
-
isCVMValue
public final boolean isCVMValue()Description copied from class:ACellReturns true if this Cell represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false, pretty much everything else should return true. Note: CVM values might not be in a canonical format, e.g. temporary data structures- Specified by:
isCVMValuein classACell- Returns:
- true if the object is a CVM Value, false otherwise
-
opCode
public abstract byte opCode()Returns the opcode for this op- Returns:
- Opcode as a byte
-
encode
public final int encode(byte[] bs, int pos) Description copied from class:ACellWrites this Cell's encoding to a byte array, including a tag byte which will be written first. Cell must be canonical, or else an error may occur.- Specified by:
encodein interfaceIWriteable- Specified by:
encodein classACell- Parameters:
bs- A byte array to which to write the encodingpos- The offset into the byte array- Returns:
- New position after writing
-
encodeRaw
public abstract int encodeRaw(byte[] bs, int pos) Writes the raw data for this Op to the specified bytebuffer. Assumes Op tag and opcode already written. -
updateRefs
Description copied from class:ACellUpdates 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:
updateRefsin classACell- Parameters:
func- Ref update function- Returns:
- Cell with updated Refs
-
getTag
public byte getTag()Description copied from class:ACellGets the tag byte for this cell. The tag byte is always written as the first byte of the Cell's Encoding
-