Skip to content

Body

INCLUDE FILE
#include "Body/Body.h"

class Body

Represents a body of an object or macro. This is the class other parts of the program interact with. It is a wrapper around the BodyElement hierarchy.

DEFINITION
class Body;

constructor Body

Constructs an empty body.

DEFINITION
Body ( );

constructor Body

Constructs a body with a given element.

DEFINITION
Body ( const std::shared_ptr< BodyElement > & element );
PARAMETERDESCRIPTION
element

The element to wrap.

method append

Appends a new element to the body.

If necessary, the body will be converted to a BlockBody to accommodate the new element.

DEFINITION
void  append ( const Body & element );
PARAMETERDESCRIPTION
element

The element to append.

method append_sub

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

method asconst

Get the body element as a specific type.

DEFINITION
template <typename T>
T * as ( ) const;
RETURNSDESCRIPTION
T *

The body element as type T, or nullptr if it is not of that type.

method backconst

DEFINITION
std::optional< Body >  back ( ) const;
RETURNSDESCRIPTION
std::optional< Body >

method cloneconst

Create a deep copy of the body.

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

A new Body that is a deep copy of this body.

method emptyconst

Check if it is an EmptyBody.

DEFINITION
bool  empty ( ) const;
RETURNSDESCRIPTION
bool

true if the body is empty, false otherwise.

method encode

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

method enter_names

DEFINITION
void  enter_names ( Scope * scope,
Entity * containing_entity );
PARAMETERDESCRIPTION
scope
containing_entity

method evaluate

DEFINITION
void  evaluate ( const EvaluationContext & context );
PARAMETERDESCRIPTION
context

method evaluatedconst

DEFINITION
std::optional< Body >  evaluated ( const EvaluationContext & context ) const;
PARAMETERDESCRIPTION
context
RETURNSDESCRIPTION
std::optional< Body >

method expand_calls

Expand macro and function calls in the body.

This will recursively expand all macro and function calls within the body.

DEFINITION
void  expand_calls ( );

method fully_evaluated

Check if all contained body elements and expressions have been fully evaluated.

DEFINITION
bool  fully_evaluated ( );
RETURNSDESCRIPTION
bool

true if the body is fully evaluated, false otherwise.

method get_elementconst

Get the body element.

DEFINITION
std::shared_ptr< BodyElement >  get_element ( ) const;
RETURNSDESCRIPTION
std::shared_ptr< BodyElement >

The body element as a shared pointer.

method isconst

Check if the body element is of a specific type.

DEFINITION
template <typename T>
bool  is ( ) const;
RETURNSDESCRIPTION
bool

true if the body element is of type T, false otherwise.

method offsetconst

DEFINITION
SizeRange  offset ( ) const;
RETURNSDESCRIPTION
SizeRange

method resolve

Resolve all names in the body.

DEFINITION
void  resolve ( Scope * scope,
Entity * containing_entity );
PARAMETERDESCRIPTION
scope

The scope to resolve names in.

containing_entity

The entity that contains the body.

method serializeconst

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

method sizeconst

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

method size_rangeconst

DEFINITION
SizeRange  size_range ( ) const;
RETURNSDESCRIPTION
SizeRange

method type_nameconst

DEFINITION
std::string_view  type_name ( ) const;
RETURNSDESCRIPTION
std::string_view

method validconst

DEFINITION
bool  valid ( ) const;
RETURNSDESCRIPTION
bool

member elementprivate

DEFINITION
std::shared_ptr< BodyElement >  element;