Struct ASTNode¶
- Defined in File ASTNode.h
Inheritance Relationships¶
Derived Types¶
public AST::Assn(Struct Assn)public AST::BinOp(Struct BinOp)public AST::FunctionCall(Struct FunctionCall)public AST::Ident(Struct Ident)public AST::If(Class If)public AST::Literal< _T >(Template Struct Literal)public AST::ObjectCall(Struct ObjectCall)public AST::Return(Struct Return)public AST::RhsArgs(Struct RhsArgs)public AST::Typecase(Struct Typecase)public AST::Typing(Struct Typing)public AST::UniOp(Struct UniOp)public AST::While(Struct While)public AST::Literal< bool >(Template Struct Literal)public AST::Literal< int >(Template Struct Literal)public AST::Literal< std::string >(Template Struct Literal)
Struct Documentation¶
-
struct
ASTNode¶ Subclassed by AST::Assn, AST::BinOp, AST::FunctionCall, AST::Ident, AST::If, AST::Literal< _T >, AST::ObjectCall, AST::Return, AST::RhsArgs, AST::Typecase, AST::Typing, AST::UniOp, AST::While, AST::Literal< bool >, AST::Literal< int >, AST::Literal< std::string >
Public Functions
-
virtual
~ASTNode()¶
-
virtual void
print_original_src(unsigned int indent_depth = 0) = 0¶
-
virtual bool
check_initialize_before_use(InitializedList &inits, InitializedList *all_inits, bool is_method) = 0¶
-
virtual void
update_initialized_list(InitializedList &inits, bool is_constructor)¶ Updates the initialized list in the initialized per use check.
- Parameters
inits: Set of initialized variables.is_constructor: True if the function being checked is a constructor.
-
virtual bool
perform_type_inference(TypeCheck::Settings &settings, Quack::Class *parent_type) = 0¶ Implements type inference for a single note in the AST.
-
virtual bool
update_inferred_type(TypeCheck::Settings &settings, Quack::Class *inferred_type, bool is_field)¶ Updates the symbol table and the nodes using an inferred type
- Return
- True if the update is successful
- Parameters
st: Symbol table for the methodinferred_type: Type inferred for updatingthis_class: Class type of the object
-
void
set_node_type(Quack::Class *new_type)¶ Updates the type for the node.
- Parameters
type: New type for the node
-
virtual std::string
generate_code(CodeGen::Settings &settings, unsigned indent_lvl, bool is_lhs) const = 0¶
-
void
generate_eval_branch(CodeGen::Settings settings, const unsigned indent_lvl, const std::string &true_label, const std::string &false_label)¶
-
std::string
generate_temp_var(const std::string &var_to_store, CodeGen::Settings settings, unsigned indent_lvl, bool is_lhs) const¶ Helper function that standardizes the generation of new temporary variables.
- Return
- Pointer to the memory location
- Parameters
var_to_store: Variable to store in a temporarysettings: Code generation settingsindent_lvl: Level of indentation
-
virtual bool
contains_return_all_paths()¶ Checks whether the statement has a return on all paths.
- Return
- True the tree node has a return on all possible subpaths
Public Static Functions
-
static std::string
indent_str(unsigned indent_level)¶
-
static const std::string
define_new_label(const std::string &label_header)¶ Helper function used to create a label using the label header and a unique integer to ensure that there are no duplicate labels.
- Return
- Unique label
- Parameters
label_header: Header used for the label
-
static void
generate_label(CodeGen::Settings &settings, unsigned indent_lvl, const std::string &label, bool add_new_line = false)¶ Standardized helper function to generte a label in the output.
- Parameters
settings: Code generation settingsindent_lvl: Level of indentationlabel: Label to generate
-
static void
generate_goto(CodeGen::Settings &settings, unsigned indent_lvl, const std::string &label, bool add_new_line = false)¶ Standard helper function to jump to the passed label.
- Parameters
settings:indent_lvl:label: Label to go to.
-
static const std::string
define_new_temp_var()¶ Helper function used to generate temporary variable names
- Return
- Temporary variable name
-
virtual