Bash++
Bash++ compiler internal documentation
DynamicCastTarget.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <AST/ASTNode.h>
9#include <optional>
10
11namespace AST {
12
13class DynamicCastTarget : public ASTNode {
14 protected:
15 std::optional<AST::Token<std::string>> m_TARGETTYPE;
16 public:
18 constexpr AST::NodeType getType() const override { return static_type; }
19
20 void setTargetType(const AST::Token<std::string>& target_type) {
21 m_TARGETTYPE = target_type;
22 }
23 const std::optional<AST::Token<std::string>>& TARGETTYPE() const {
24 return m_TARGETTYPE;
25 }
26
27 std::ostream& prettyPrint(std::ostream& os, int indentation_level = 0) const override {
28 std::string indent(indentation_level * PRETTYPRINT_INDENTATION_AMOUNT, ' ');
29 os << indent << "(DynamicCastTarget"
30 << (m_TARGETTYPE.has_value() ? " " + m_TARGETTYPE->getValue() : "");
31 for (const auto& child : children) {
32 os << std::endl;
33 child->prettyPrint(os, indentation_level + 1);
34 }
35 os << ")" << std::flush;
36 return os;
37 }
38};
39
40} // namespace AST
#define PRETTYPRINT_INDENTATION_AMOUNT
Definition ASTNode.h:18
The base class for all non-terminal nodes in the Bash++ AST. Each ASTNode contains information about ...
Definition ASTNode.h:28
std::vector< std::shared_ptr< ASTNode > > children
Definition ASTNode.h:30
Definition DynamicCastTarget.h:13
const std::optional< AST::Token< std::string > > & TARGETTYPE() const
Definition DynamicCastTarget.h:23
static constexpr AST::NodeType static_type
Definition DynamicCastTarget.h:17
std::optional< AST::Token< std::string > > m_TARGETTYPE
Definition DynamicCastTarget.h:15
std::ostream & prettyPrint(std::ostream &os, int indentation_level=0) const override
Definition DynamicCastTarget.h:27
void setTargetType(const AST::Token< std::string > &target_type)
Definition DynamicCastTarget.h:20
constexpr AST::NodeType getType() const override
Definition DynamicCastTarget.h:18
A class representing a token in the Bash++ AST. Tokens store their value along with line and column i...
Definition Token.h:21
Definition AccessModifier.h:8
NodeType
Definition NodeTypes.h:9