Skip to content

DataBody

INCLUDE FILE
#include "Body/DataBody.h"

class DataBody

Represents a body containing data. This is used for .data statements and encoded instructions.

DEFINITION
class DataBody;

constructor DataBody

DEFINITION
DataBody ( );

constructor DataBody

DEFINITION
DataBody ( std::vector< DataBodyElement >  data );
PARAMETERDESCRIPTION
data

method append_subvirtual protected

Append a BodyElement to this body directly, if supported.

If appending is supported, this method returns the resulting body. Otherwise, it returns an empty optional.

The default implementation does not support appending. If a subclass supports appending, it should override this method.

DEFINITION
virtual std::pair< bool, std::optional< Body > >  append_sub ( const Body & body,
const Body & element );
PARAMETERDESCRIPTION
body

The body to append to.

element

The element to append.

RETURNSDESCRIPTION
std::pair< bool, std::optional< Body > >

The resulting body, or {} if not supported.

method appending

DEFINITION
Body  appending ( const DataBody * body );
PARAMETERDESCRIPTION
body
RETURNSDESCRIPTION
Body

method appendingconst

DEFINITION
Body  appending ( const std::vector< DataBodyElement > & elements ) const;
PARAMETERDESCRIPTION
elements
RETURNSDESCRIPTION
Body

method cloneconst virtual

DEFINITION
virtual Body  clone ( const CloneContext & context ) const;
PARAMETERDESCRIPTION
context
RETURNSDESCRIPTION
Body

method createstatic

DEFINITION
static Body  create ( std::vector< DataBodyElement >  data );
PARAMETERDESCRIPTION
data
RETURNSDESCRIPTION
Body

method encodevirtual

Encode the BodyElement into a byte string.

The default implementation does nothing. Subclasses that represent data or instructions should override this method.

DEFINITION
virtual void  encode ( std::string & bytes,
const Memory * memory );
PARAMETERDESCRIPTION
bytes

The byte string to encode into.

memory

The memory context for encoding.

method evaluate_processvirtual

Evaluate the body element after all sub-body-elements and sub-expressions have been evaluated.

The default implementation does nothing.

DEFINITION
virtual std::optional< Body >  evaluate_process ( const EvaluationContext & context );
PARAMETERDESCRIPTION
context

The evaluation context.

RETURNSDESCRIPTION
std::optional< Body >

The Body to replace this BodyElement with, {} if no replacement is needed.

method serializeconst virtual

Serialize the BodyElement to a stream.

Subclasses must implement this method.

DEFINITION
virtual void  serialize ( std::ostream & stream,
const std::string & prefix ) const;
PARAMETERDESCRIPTION
stream

The stream to serialize to.

prefix

The prefix for each line of the serialized output.

method traversevirtual

Traverse the BodyElement.

This function is used by the default implementations of resolve() and expand_calls(). Unless a subclass overrides both of these methods, it should override traverse().

DEFINITION
virtual void  traverse ( std::function< void(Body &)>  body_callable,
std::function< void(Expression &)>  expression_callable );
PARAMETERDESCRIPTION
body_callable

A callable to apply to each sub-body-element.

expression_callable

A callable to apply to each sub-expression.

member data

DEFINITION
std::vector< DataBodyElement >  data;

class DataBodyElement

DEFINITION
class DataBodyElement;

constructor DataBodyElement

DEFINITION
DataBodyElement ( Expression  expression,
std::optional< Encoder >  encoding );
PARAMETERDESCRIPTION
expression
encoding

method sizeconst

DEFINITION
std::optional< uint64_t >  size ( ) const;
RETURNSDESCRIPTION
std::optional< uint64_t >

method size_rangeconst

DEFINITION
SizeRange  size_range ( ) const;
RETURNSDESCRIPTION
SizeRange

member encoding

DEFINITION
std::optional< Encoder >  encoding;

member expression

DEFINITION
Expression  expression;