Package convex.core.lang.ops
Class Constant<T extends ACell>
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.lang.AOp<T>
convex.core.lang.ops.Constant<T>
- Type Parameters:
T
- Type of constant value
- All Implemented Interfaces:
IValidated
,IWriteable
Operation representing a constant value
"One man's constant is another man's variable." - Alan Perlis
-
Field Summary
FieldsFields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY
-
Method Summary
Modifier and TypeMethodDescriptioncreate(T value)
createFromRef(Ref<T> valueRef)
createString(String stringValue)
int
encodeRaw(byte[] bs, int pos)
Writes the raw data for this Op to the specified bytebuffer.int
Estimate the encoded data size for this Cell.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.nil()
byte
opCode()
Returns the opcode for this opvoid
print(StringBuilder sb)
Prints this Object to a readable String Representationread(ByteBuffer bb)
updateRefs(IRefFunction func)
Updates all Refs in this object using the given function.void
Validates the local structure and invariants of this cell.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
-
Field Details
-
NULL
-
TRUE
-
FALSE
-
EMPTY_VECTOR
-
EMPTY_LIST
-
-
Method Details
-
create
-
of
-
createString
-
createFromRef
-
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 -
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. -
estimatedEncodingSize
public int estimatedEncodingSize()Description copied from interface:IWriteable
Estimate 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.- Specified by:
estimatedEncodingSize
in interfaceIWriteable
- Overrides:
estimatedEncodingSize
in classAOp<T extends ACell>
- Returns:
- The estimated size for the binary representation of this object.
-
read
- Throws:
BadFormatException
-
opCode
public byte opCode()Description copied from class:AOp
Returns the opcode for this op -
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.- Specified by:
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. -
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.- Specified by:
updateRefs
in classAOp<T extends ACell>
- Parameters:
func
- Ref update function- Returns:
- Cell with updated Refs
-
nil
-
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
-