Skip to content

Commit

Permalink
Added some cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
jimtahu committed Apr 28, 2013
1 parent 2512dac commit fc9e26d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion AssingmentStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ void AssingmentStatement::Execute(){
}

AssingmentStatement::~AssingmentStatement() {
// TODO Auto-generated destructor stub
delete this->id;
delete this->value;
}

} /* namespace ParseTree */
3 changes: 2 additions & 1 deletion BinOpValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ string BinOpValue::getValue(){
}

BinOpValue::~BinOpValue() {
// TODO Auto-generated destructor stub
delete this->a;
delete this->b;
}

} /* namespace ParseTree */
2 changes: 1 addition & 1 deletion PrintStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void PrintStatement::Execute(){
}

PrintStatement::~PrintStatement() {
// TODO Auto-generated destructor stub
delete this->value;
}

} /* namespace ParseTree */
4 changes: 3 additions & 1 deletion Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ void Program::run(){
}

Program::~Program() {

for(std::vector<Statement *>::iterator i=code.begin(); i!=code.end(); i++){
delete *i;
}
}

} /* namespace ParseTree */
10 changes: 10 additions & 0 deletions ScalarVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ string getScalar(string name){
else return "EMPTY";
}//end getValue

/**
* Cleans out the Scalar table.
*/
void cleanScalars(){
for(map<string, ScalarVariable*>::iterator i=scalarTable.begin();
i!=scalarTable.end();i++){
delete i->second;
}//end for table
}//end cleanScalars

ScalarVariable::ScalarVariable(string name):Variable(name){
this->Value="";
}
Expand Down
1 change: 1 addition & 0 deletions ScalarVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace runtime {

std::string setScalar(std::string name, std::string value);
std::string getScalar(std::string name);
void cleanScalars();

class ScalarVariable: public Variable {
std::string Value;
Expand Down
3 changes: 3 additions & 0 deletions Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <map>

#include "ParseTree.h"
#include "ScalarVariable.h"

using namespace std;

Expand Down Expand Up @@ -43,8 +44,10 @@ int main(int argc, char *argv[]) {
theProg->run();
}catch(ParseTree::ExitCondition *ex){
cout<<"Program terminated"<<endl;
delete ex;
}
delete theProg;
runtime::cleanScalars();
return 0;
}//end main

0 comments on commit fc9e26d

Please sign in to comment.