activation.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef AFUN_ACTIVATION_HPP
  2. #define AFUN_ACTIVATION_HPP
  3. #include "tool.hpp"
  4. #include "aFunCoreExport.h"
  5. namespace aFuncore {
  6. class Activation;
  7. class TopActivation;
  8. typedef enum ActivationStatus {
  9. as_run = 0,
  10. as_end = 1,
  11. } ActivationStatus;
  12. }
  13. #include "msg.hpp"
  14. #include "code.hpp"
  15. #include "inter.hpp"
  16. #include "var.hpp"
  17. namespace aFuncore {
  18. class Activation {
  19. protected:
  20. Activation *prev;
  21. VarList *varlist;
  22. VarList *old_varlist;
  23. UpMessage *up;
  24. DownMessage *down;
  25. public:
  26. Inter *const inter;
  27. StringFilePath path;
  28. FileLine line;
  29. explicit Activation(Inter *inter_);
  30. virtual ~Activation();
  31. virtual ActivationStatus getCode(Code *&code)=0;
  32. virtual bool onTail()=0;
  33. virtual void runCode(Code *code);
  34. [[nodiscard]] VarList *getVarlist() const {return varlist;}
  35. [[nodiscard]] Activation *toPrev() const {return prev;}
  36. [[nodiscard]] UpMessage *getUpStream() const {return up;}
  37. [[nodiscard]] DownMessage *getDownStream() const {return down;}
  38. };
  39. class ExeActivation : public Activation {
  40. Code *start;
  41. Code *next;
  42. bool first=true;
  43. public:
  44. explicit ExeActivation(Code *code, Inter *inter_) : Activation(inter_), start{code}, next{code} {}
  45. ActivationStatus getCode(Code *&code) override;
  46. bool onTail() override {return next == nullptr;}
  47. [[nodiscard]] Code *getStart() const {return start;}
  48. };
  49. class TopActivation : public ExeActivation {
  50. public:
  51. explicit TopActivation(Code *code, Inter *inter_);
  52. ~TopActivation() override;
  53. bool onTail() override {return false;}
  54. };
  55. }
  56. #endif //AFUN_ACTIVATION_HPP