source: liacs/coco/assignment4/ICGenerator.h@ 310

Last change on this file since 310 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 1.7 KB
RevLine 
[2]1/*
2 * ICGenerator.h - Declaration of the ICGenerator class
3 *
4 * Part of the assignment of the Compiler Construction course
5 * LIACS, Leiden University
6 */
7
8#ifndef _ICGENERATOR_H_
9#define _ICGENERATOR_H_
10
11#include "SyntaxTree.h"
12#include "SymbolTable.h"
13#include "IntermediateCode.h"
14
15
16// This class handles the intermediate code generation. Extend it to your own
17// needs. Do not remove any of the predefined methods or members.
18class ICGenerator {
19 public:
20 // Constructor
21 ICGenerator();
22
23 // Destructor
24 ~ICGenerator();
25
26 // Preprocesses the syntax tree; this method is called before
27 // GenerateIntermediateCode() if optimizations are enabled
28 void Preprocess (SyntaxTree * tree, SymbolTable * symtab);
29
30 // Takes a SyntaxTree and converts it into an IntermediateCode structure
31 IntermediateCode * GenerateIntermediateCode (SyntaxTree * inputTree, SymbolTable * symtab);
32
33 // Postprocesses the intermediate code; this method is called after
34 // GenerateIntermediateCode() if optimizations are enabled
35 void Postprocess (IntermediateCode * code, SymbolTable * symtab);
36
37 private:
38
39 // Internal functions
40 IOperand*ProcessTree(IntermediateCode*,Node*);
41 void ProcessParamlist(IntermediateCode*,Node*);
42 IStatement*ProcessBoolExpr(IntermediateCode*,Node*,Symbol*);
43 void ReverseBranchCondition(IStatement*);
44 Symbol*GenerateTempVar(ReturnType);
45 Symbol*GenerateLabelSymbol();
46 IStatement*GenerateLabel(IntermediateCode*,Symbol*);
47
48 // Internal variables
49 unsigned int tempvarIndex;
50 unsigned int labelIndex;
51
52 // Pointer to the symbol table
53 SymbolTable * symtab;
54
55 // Pointer to the tree
56 SyntaxTree * tree;
57
58 // <insert your own private members and methods>
59
60};
61
62#endif
Note: See TracBrowser for help on using the repository browser.