souffle  2.0.2-371-g6315b36
Public Types | Public Member Functions | Protected Member Functions | Private Attributes
souffle::ast::NumericConstant Class Reference

Numeric Constant. More...

#include <NumericConstant.h>

Inheritance diagram for souffle::ast::NumericConstant:
Inheritance graph
Collaboration diagram for souffle::ast::NumericConstant:
Collaboration graph

Public Types

enum  Type { Type::Int, Type::Uint, Type::Float }
 

Public Member Functions

NumericConstantclone () const override
 Create clone. More...
 
std::optional< TypegetFinalType () const
 
const std::optional< Type > & getFixedType () const
 
 NumericConstant (RamSigned value)
 
 NumericConstant (std::string constant, SrcLocation loc)
 
 NumericConstant (std::string constant, std::optional< Type > fixedType=std::nullopt, SrcLocation loc={})
 
void setFinalType (Type newType)
 
- Public Member Functions inherited from souffle::ast::Constant
const std::string & getConstant () const
 Get string representation of Constant. More...
 
- Public Member Functions inherited from souffle::ast::Argument
 Node (SrcLocation loc={})
 
- Public Member Functions inherited from souffle::ast::Node
virtual void apply (const NodeMapper &)
 Apply the mapper to all child nodes. More...
 
std::string extloc () const
 Return source location of the syntactic element. More...
 
virtual std::vector< const Node * > getChildNodes () const
 Obtain a list of all embedded AST child nodes. More...
 
const SrcLocationgetSrcLoc () const
 Return source location of the Node. More...
 
 Node (SrcLocation loc={})
 
bool operator!= (const Node &other) const
 Inequality check for two AST nodes. More...
 
bool operator== (const Node &other) const
 Equivalence check for two AST nodes. More...
 
void setSrcLoc (SrcLocation l)
 Set source location for the Node. More...
 
virtual ~Node ()=default
 

Protected Member Functions

bool equal (const Node &node) const override
 Abstract equality check for two AST nodes. More...
 
- Protected Member Functions inherited from souffle::ast::Constant
 Constant (std::string value, SrcLocation loc={})
 
void print (std::ostream &os) const override
 Output to a given output stream. More...
 

Private Attributes

std::optional< TypefinalTranslatorType
 
std::optional< TypefixedType
 

Detailed Description

Numeric Constant.

The constant can be initialized with type. If this is the case, the typesystem will be forced to use it. Otherwise the type is inferred from context.

Definition at line 43 of file NumericConstant.h.

Member Enumeration Documentation

◆ Type

Enumerator
Int 
Uint 
Float 

Definition at line 51 of file NumericConstant.h.

52 {

Constructor & Destructor Documentation

◆ NumericConstant() [1/3]

souffle::ast::NumericConstant::NumericConstant ( RamSigned  value)
inline

Definition at line 53 of file NumericConstant.h.

55 {

◆ NumericConstant() [2/3]

souffle::ast::NumericConstant::NumericConstant ( std::string  constant,
SrcLocation  loc 
)
inline

Definition at line 55 of file NumericConstant.h.

55  {
56  copy->setFinalType(finalTranslatorType.value());
57  }

References souffle::detail::brie::copy(), and finalTranslatorType.

Here is the call graph for this function:

◆ NumericConstant() [3/3]

souffle::ast::NumericConstant::NumericConstant ( std::string  constant,
std::optional< Type fixedType = std::nullopt,
SrcLocation  loc = {} 
)
inline

Definition at line 59 of file NumericConstant.h.

61  {
62  return fixedType;

Member Function Documentation

◆ clone()

NumericConstant* souffle::ast::NumericConstant::clone ( ) const
inlineoverridevirtual

Create clone.

Implements souffle::ast::Constant.

Definition at line 64 of file NumericConstant.h.

65  {
66  finalTranslatorType = newType;
67  }
68 
69  std::optional<Type> getFinalType() const {
70  return finalTranslatorType;
71  }

References finalTranslatorType.

◆ equal()

bool souffle::ast::NumericConstant::equal ( const Node ) const
inlineoverrideprotectedvirtual

Abstract equality check for two AST nodes.

Reimplemented from souffle::ast::Constant.

Definition at line 86 of file NumericConstant.h.

◆ getFinalType()

std::optional<Type> souffle::ast::NumericConstant::getFinalType ( ) const
inline

Definition at line 81 of file NumericConstant.h.

◆ getFixedType()

const std::optional<Type>& souffle::ast::NumericConstant::getFixedType ( ) const
inline

Definition at line 73 of file NumericConstant.h.

73  :
74  bool equal(const Node& node) const override {
75  const auto& other = static_cast<const NumericConstant&>(node);

References souffle::ast::Constant::equal(), and fixedType.

Referenced by souffle::ast::analysis::TypeConstraintsAnalysis::visitNumericConstant().

Here is the call graph for this function:

◆ setFinalType()

void souffle::ast::NumericConstant::setFinalType ( Type  newType)
inline

Definition at line 77 of file NumericConstant.h.

79  :
80  std::optional<Type> fixedType;

Field Documentation

◆ finalTranslatorType

std::optional<Type> souffle::ast::NumericConstant::finalTranslatorType
private

Definition at line 95 of file NumericConstant.h.

Referenced by clone(), and NumericConstant().

◆ fixedType

std::optional<Type> souffle::ast::NumericConstant::fixedType
private

Definition at line 92 of file NumericConstant.h.

Referenced by getFixedType().


The documentation for this class was generated from the following file:
souffle::detail::brie::copy
auto copy(span< A, arity > s)
Definition: Brie.h:98
souffle::ast::NumericConstant::NumericConstant
NumericConstant(RamSigned value)
Definition: NumericConstant.h:53
souffle::ast::NumericConstant::finalTranslatorType
std::optional< Type > finalTranslatorType
Definition: NumericConstant.h:95
souffle::ast::NumericConstant::getFinalType
std::optional< Type > getFinalType() const
Definition: NumericConstant.h:81
souffle::ast::Node::Node
Node(SrcLocation loc={})
Definition: Node.h:42
souffle::ast::NumericConstant::fixedType
std::optional< Type > fixedType
Definition: NumericConstant.h:92
souffle::ast::NumericConstant::equal
bool equal(const Node &node) const override
Abstract equality check for two AST nodes.
Definition: NumericConstant.h:86