Last change
on this file since 90 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.4 KB
|
Rev | Line | |
---|
[2] | 1 | /*
|
---|
| 2 | * IntermediateCode.h - Declaration of the IntermediateCode abstract data structure
|
---|
| 3 | *
|
---|
| 4 | * Part of the assignment of the Compiler Construction course
|
---|
| 5 | * LIACS, Leiden University
|
---|
| 6 | *
|
---|
| 7 | * Note that deleting an IntermediateCode object will also delete all
|
---|
| 8 | * IStatement objects associated to it.
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #ifndef _INTERMEDIATECODE_H_
|
---|
| 12 | #define _INTERMEDIATECODE_H_
|
---|
| 13 |
|
---|
| 14 | #include <cstdio>
|
---|
| 15 | #include <vector>
|
---|
| 16 | #include "IStatement.h"
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | using namespace std;
|
---|
| 20 |
|
---|
| 21 | // This class stores a linear list of intermediate statements and provides
|
---|
| 22 | // operations to modify that list.
|
---|
| 23 | class IntermediateCode {
|
---|
| 24 | public:
|
---|
| 25 | // Constructor/destructor
|
---|
| 26 | IntermediateCode();
|
---|
| 27 | ~IntermediateCode();
|
---|
| 28 |
|
---|
| 29 | // Gets the program name
|
---|
| 30 | string GetProgramName();
|
---|
| 31 |
|
---|
| 32 | // Sets the program name
|
---|
| 33 | void SetProgramName(string name);
|
---|
| 34 |
|
---|
| 35 | // Returns the number of statements
|
---|
| 36 | unsigned int GetStatementCount();
|
---|
| 37 |
|
---|
| 38 | // Gets the i-th statement
|
---|
| 39 | IStatement *GetStatement(unsigned int i);
|
---|
| 40 |
|
---|
| 41 | // Appends a statement
|
---|
| 42 | void AppendStatement(IStatement *stmt);
|
---|
| 43 |
|
---|
| 44 | // Inserts a statement before the i-th statement
|
---|
| 45 | void InsertStatement(IStatement *stmt, unsigned int i);
|
---|
| 46 |
|
---|
| 47 | // Removes the i-th statement
|
---|
| 48 | void RemoveStatement(unsigned int i);
|
---|
| 49 |
|
---|
| 50 | // Checks if the intermediate code statisfies the specification
|
---|
| 51 | bool CheckStructure();
|
---|
| 52 |
|
---|
| 53 | // Dump
|
---|
| 54 | void Dump(FILE *file);
|
---|
| 55 |
|
---|
| 56 | private:
|
---|
| 57 | string programName;
|
---|
| 58 | vector<IStatement*> statements;
|
---|
| 59 | };
|
---|
| 60 |
|
---|
| 61 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.