Package convex.core.lang.ops
Class Def<T extends ACell>
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.lang.AOp<T>
convex.core.lang.ops.Def<T>
- Type Parameters:
T- Type of defined value
- All Implemented Interfaces:
IValidated,IWriteable
Op that creates a definition in the current environment.
Def may optionally have symbolic metadata attached to the symbol.
-
Field Summary
Fields inherited from class convex.core.data.ACell
cachedRef, memorySize -
Method Summary
Modifier and TypeMethodDescriptionintencodeRaw(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.getRef(int i) Gets a numbered child Ref from within this Cell.intGets the number of Refs contained within this Cell.byteopCode()Returns the opcode for this opbooleanprint(BlobBuilder sb, long limit) Prints this Object to a readable String Representation.Decodes a Def op from a Blob encodingupdateRefs(IRefFunction func) Updates all Refs in this object using the given function.voidValidates the local structure and invariants of this cell.Methods inherited from class convex.core.lang.AOp
encode, equals, getTag, getType, isCanonical, isCVMValue, isDataValue, toCanonicalMethods 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, validateMethods inherited from class convex.core.data.AObject
attachEncoding, print, print
-
Method Details
-
create
-
create
-
create
-
create
-
create
-
create
-
create
-
execute
Description copied from class:AOpExecutes this op with the given context. Must preserve depth unless an exceptional is returned. -
getRefCount
public int getRefCount()Description copied from class:ACellGets 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:
getRefCountin classACell- Returns:
- The number of Refs in this Cell
-
getRef
-
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. 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:
updateRefsin classAOp<T extends ACell>- Parameters:
func- Ref update function- Returns:
- Cell with updated Refs
-
print
Description copied from class:AObjectPrints 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:AOpWrites 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:IWriteableEstimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is highly likely to contain the entire object when encoded, including the tag byte. Should not traverse soft Refs, i.e. must be usable on arbitrary partial data structures- Specified by:
estimatedEncodingSizein interfaceIWriteable- Overrides:
estimatedEncodingSizein classAOp<T extends ACell>- Returns:
- The estimated size for the binary representation of this object.
-
read
Decodes a Def 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
-
validateCell
Description copied from class:ACellValidates 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:
validateCellin classACell- Throws:
InvalidDataException- If the Cell is invalid
-