Skip to content

Constant

INCLUDE FILE
#include "Entity/Constant.h"

class Constant

DEFINITION
class Constant;

constructor Constant

DEFINITION
Constant ( const Location & location,
Symbol  name,
std::shared_ptr< Scope >  parent_scope,
const std::shared_ptr< StructuredValue > & definition );
PARAMETERDESCRIPTION
location
name
parent_scope
definition

constructor Constant

DEFINITION
Constant ( const Location & location,
Symbol  name,
Visibility  visibility,
std::shared_ptr< Scope >  containing_scope,
bool  default_only,
Expression  value );
PARAMETERDESCRIPTION
location
name
visibility
containing_scope
default_only
value

method add_reference

DEFINITION
void  add_reference ( );

method has_valueconst

DEFINITION
bool  has_value ( ) const;
RETURNSDESCRIPTION
bool

method is_referencedconst

DEFINITION
bool  is_referenced ( ) const;
RETURNSDESCRIPTION
bool

method remove_reference

DEFINITION
void  remove_reference ( );

method serializeconst virtual

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

method single_referenceconst

DEFINITION
bool  single_reference ( ) const;
RETURNSDESCRIPTION
bool

method traversevirtual protected

Traverse the Entity.

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

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

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

expression_callable

A callable to apply to each sub-expression.

member reference_countprivate

The number of ConstantExpressions that refer to this constant.

It is used to determine when a ScopeBody can remove a constant from its scope and when an ArgumentConstant can be inlined.

We don't use std::shared_ptr's reference counting because we only keep a weak reference to the constant in ConstantExpression. Also, counting it ourselves is more precise.

DEFINITION
size_t  reference_count;

member token_valuestatic private

DEFINITION
static const Token  token_value;

member value

DEFINITION
Expression  value;