func-exit.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "func-exit.h"
  2. namespace aFunrt {
  3. aFuncore::Function::CallFunction *ExitFunction::getCallFunction(const aFuncore::Code::ByteCode *code, aFuncore::Inter &inter) {
  4. return dynamic_cast<CallFunction *>(new CallFunc(code, inter));
  5. }
  6. ExitFunction::CallFunc::CallFunc(const aFuncore::Code::ByteCode *code_, aFuncore::Inter &inter_) : call_code{code_}, inter{inter_} {
  7. acl = new std::list<ArgCodeList>;
  8. if (code_ != nullptr) {
  9. auto arg_code = code_->getSon()->toNext();
  10. if (arg_code != nullptr) {
  11. ArgCodeList agr1{code_->getSon()->toNext()};
  12. acl->push_front(agr1);
  13. }
  14. }
  15. }
  16. std::list<aFuncore::Function::CallFunction::ArgCodeList> *ExitFunction::CallFunc::getArgCodeList(aFuncore::Inter &inter_,
  17. aFuncore:: Activation &activation,
  18. const aFuncore::Code::ByteCode *call) {
  19. return acl;
  20. }
  21. void ExitFunction::CallFunc::runFunction() {
  22. inter.setInterExit();
  23. auto &stream = inter.getActivation()->getDownStream();
  24. if (acl->empty()) {
  25. auto none = new aFuncore::Object("None", inter);
  26. stream.pushMessage("NORMAL", new aFuncore::NormalMessage(none));
  27. none->delReference();
  28. } else
  29. stream.pushMessage("NORMAL", new aFuncore::NormalMessage(acl->begin()->getObject()));
  30. }
  31. ExitFunction::CallFunc::~CallFunc() {
  32. delete acl;
  33. }
  34. }