/* * ICGenerator.cc - Implementation of the ICGenerator class * * Part of the assignment of the Compiler Construction course * LIACS, Leiden University */ #include #include "ICGenerator.h" // Constructor ICGenerator::ICGenerator() { tempvarIndex = 0; labelIndex = 0; symtab = NULL; tree = NULL; } // Destructor ICGenerator::~ICGenerator() { } // Preprocesses the syntax tree; this method is called before // GenerateIntermediateCode() if optimizations are enabled void ICGenerator::Preprocess (SyntaxTree * tree, SymbolTable * symtab) { this->symtab = symtab; this->tree = tree; // For assignment 5, this function might be a suitable point where you can // apply some optimizations to the syntax tree. For example, you can insert // the optimization code you wrote for assignment 3. } // Postprocesses the intermediate code; this method is called after // GenerateIntermediateCode() if optimizations are enabled void ICGenerator::Postprocess (IntermediateCode * code, SymbolTable * symtab) { this->symtab = symtab; // For assignment 5, this function might be a suitable point where you can // apply some optimizations to the syntax tree. For example, you can insert // the optimization code you wrote for assignment 3. }