Skip to content

LabelBody

INCLUDE FILE
#include "Body/LabelBody.h"

class LabelBody

Represents a label, which is a position in the code: label: or :.

DEFINITION
class LabelBody;

constructor LabelBody

DEFINITION
LabelBody ( const Location & location,
Visibility  visibility,
Symbol  name );
PARAMETERDESCRIPTION
location
visibility
name

method add_reference

DEFINITION
void  add_reference ( );

method cloneconst virtual

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

method createstatic

DEFINITION
static Body  create ( const Location & location,
Symbol  name = {},
Visibility  visibility = Visibility::ENTITY );
PARAMETERDESCRIPTION
location
name
visibility
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 enter_namesvirtual

Enter names defined by the BodyElement in the given scope.

This method is used to enter names into the given scope.

The default implementation calls enter_names() on all sub-body-elements using traverse(). Subclasses that define names should override this method.

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

The scope to enter names into.

containing_entity

The entity that contains the BodyElement.

method evaluatevirtual

Evaluate the BodyElement in a given context.

Subclasses must implement this method.

If an error occurs during evaluation, either an error should be reported via DiagnosticOutput and the BodyElement marked as invalid, or an exception should be thrown.

DEFINITION
virtual std::optional< Body >  evaluate ( 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 is_referencedconst

DEFINITION
bool  is_referenced ( ) const;
RETURNSDESCRIPTION
bool

method remove_reference

DEFINITION
void  remove_reference ( );

method resolvevirtual

Resolve all names in the BodyElement.

If a name cannot be resolved, an error should be reported via DiagnosticOutput and the BodyElement marked as invalid, or an exception should be thrown.

The default implementation calls resolve() on all sub-body-elements and sub-expressions using traverse().

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

The scope to resolve names in.

containing_entity

The entity that contains the BodyElement.

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.

member name

DEFINITION
Symbol  name;

member reference_countprivate

DEFINITION
uint64_t  reference_count;

member visibility

DEFINITION
Visibility  visibility;