inter.inline.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef AFUN_INTER_INLINE_H
  2. #define AFUN_INTER_INLINE_H
  3. #include "inter.h"
  4. namespace aFuncore {
  5. inline Environment &Inter::getEnvironment() {
  6. return env;
  7. }
  8. inline void Inter::pushActivation(Activation *new_activation) {
  9. stack.push_front(new_activation);
  10. activation = new_activation;
  11. }
  12. inline Activation *Inter::popActivation() {
  13. if (activation == nullptr)
  14. return nullptr;
  15. Activation *ret = activation;
  16. stack.pop_front();
  17. if (stack.empty())
  18. activation = nullptr;
  19. else
  20. activation = stack.front();
  21. return ret;
  22. }
  23. inline Inter::InterStatus Inter::getStatus() const {
  24. return status;
  25. }
  26. inline bool Inter::isInterStop() const {
  27. return (status == inter_exit || status == inter_stop);
  28. }
  29. inline bool Inter::isInterExit() const {
  30. return (status == inter_exit);
  31. }
  32. inline ProtectVarSpace *Inter::getProtectVarSpace() const {
  33. return env.protect;
  34. }
  35. inline VarSpace *Inter::getGlobalVarSpace() const {
  36. return env.global;
  37. }
  38. inline VarList *Inter::getGlobalVarlist() const {
  39. return env.global_varlist;
  40. }
  41. inline const std::list<Activation *> &Inter::getStack() const {
  42. return stack;
  43. }
  44. inline Activation *Inter::getActivation() const {
  45. return activation;
  46. }
  47. inline EnvVarSpace &Inter::getEnvVarSpace() {
  48. return env.envvar;
  49. }
  50. inline InterOutMessage &Inter::getOutMessageStream() {
  51. return out;
  52. }
  53. inline InterInMessage &Inter::getInMessageStream() {
  54. return in;
  55. }
  56. inline size_t Environment::operator++(){
  57. std::unique_lock<std::mutex> mutex{lock};
  58. return ++reference;
  59. }
  60. inline size_t Environment::operator--(){
  61. std::unique_lock<std::mutex> mutex{lock};
  62. return --reference;
  63. }
  64. inline size_t Environment::operator++(int){
  65. std::unique_lock<std::mutex> mutex{lock};
  66. return reference++;
  67. }
  68. inline size_t Environment::operator--(int){
  69. std::unique_lock<std::mutex> mutex{lock};
  70. return reference--;
  71. }
  72. inline Inter::InterStatus Inter::setInterStop() {
  73. InterStatus ret = status;
  74. if (status != inter_exit)
  75. status = inter_stop;
  76. return ret;
  77. }
  78. inline Inter::InterStatus Inter::setInterExit() {
  79. InterStatus ret = status;
  80. status = inter_exit;
  81. return ret;
  82. }
  83. }
  84. #endif //AFUN_INTER_INLINE_H