Script.cpp 537 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "Script.h"
  2. #include <iostream>
  3. Script::Script()
  4. {
  5. }
  6. Script::~Script()
  7. {
  8. for(int i = 0; i < instructions.getSize(); i++)
  9. {
  10. delete instructions.get(i);
  11. }
  12. }
  13. void Script::execute()
  14. {
  15. for(int i = 0; i < instructions.getSize(); i++)
  16. {
  17. cout << i << endl;
  18. instructions.get(i)->execute(dataStack);
  19. }
  20. if(!dataStack.isEmpty())
  21. {
  22. cout << "RESULT: " << *dataStack.pop() << endl;
  23. }
  24. }
  25. ArrayList<Instruction*>& Script::getInstructions()
  26. {
  27. return instructions;
  28. }