Class If

Inheritance Relationships

Base Type

Class Documentation

class If : public AST::ASTNode

Public Functions

If(ASTNode *cond, Block *truepart, Block *falsepart)
~If()
void print_original_src(unsigned int indent_depth = 0)
bool check_initialize_before_use(InitializedList &inits, InitializedList *all_inits, bool is_method)

Specialized implementation of the initialize before use type check. The initialized list is modified by the function and represents the set of variables in the intersection of the variables from the true and false blocks.

Return
True if the check passed.
Parameters
  • inits: Initialized list modified in place

std::string generate_code(CodeGen::Settings &settings, unsigned indent_lvl, bool is_lhs) const

Generates the code for an If block.

Return
No variable name returned. This is because no temporary variables are associated with an If.
Parameters
  • settings: Code generator settings
  • indent_lvl: Indentation level for the generated code

bool contains_return_all_paths()

Checks whether the if block contains a return in both the true and false parts

Return
True both the true and false parts always raise a return

bool perform_type_inference(TypeCheck::Settings &settings, Quack::Class *parent_type)

Implements type inference for a single note in the AST.

Return
True if type inference was successful.
Parameters
  • st: Symbol table for the method
  • return_type: Return type from the block
  • parent_type: Type of the parent node. If parent node has no type, then BASE_CLASS.