activation.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef AFUN_ACTIVATION_H
  2. #define AFUN_ACTIVATION_H
  3. #include "aFuntool.h"
  4. #include "aFunCoreExport.h"
  5. #include "core.h"
  6. #include "value.h"
  7. namespace aFuncore {
  8. AFUN_CORE_EXPORT class Activation {
  9. protected:
  10. Activation *prev;
  11. VarList *varlist;
  12. UpMessage *up;
  13. DownMessage *down;
  14. StringFilePath path;
  15. FileLine line;
  16. public:
  17. Inter *const inter;
  18. explicit Activation(Inter *inter_);
  19. virtual ~Activation();
  20. Activation &operator=(const Activation &)=delete;
  21. virtual ActivationStatus getCode(Code *&code) = 0;
  22. virtual void runCode(Code *code);
  23. virtual void endRun() {}
  24. [[nodiscard]] VarList *getVarlist() const {return varlist;}
  25. [[nodiscard]] Activation *toPrev() const {return prev;}
  26. [[nodiscard]] UpMessage *getUpStream() const {return up;}
  27. [[nodiscard]] DownMessage *getDownStream() const {return down;}
  28. [[nodiscard]] FileLine getFileLine() const {return line;}
  29. [[nodiscard]] const StringFilePath &getFilePath() const {return path;}
  30. };
  31. AFUN_CORE_EXPORT class ExeActivation : public Activation {
  32. Code *start;
  33. Code *next;
  34. bool first=true;
  35. public:
  36. explicit ExeActivation(Code *code, Inter *inter_) : Activation(inter_), start{code}, next{code} {}
  37. ActivationStatus getCode(Code *&code) override;
  38. [[nodiscard]] Code *getStart() const {return start;}
  39. };
  40. AFUN_CORE_EXPORT class TopActivation : public ExeActivation {
  41. public:
  42. explicit TopActivation(Code *code, Inter *inter_);
  43. ~TopActivation() override;
  44. };
  45. AFUN_CORE_EXPORT class FuncActivation : public Activation {
  46. enum {
  47. func_first = 0,
  48. func_get_func = 1,
  49. func_get_arg = 2,
  50. } status = func_first;
  51. bool on_tail = false;
  52. Code *call;
  53. Function *func = nullptr;
  54. Function::CallFunction *call_func = nullptr;
  55. std::list<Function::CallFunction::ArgCodeList> *acl = nullptr;
  56. std::list<Function::CallFunction::ArgCodeList>::iterator acl_begin;
  57. std::list<Function::CallFunction::ArgCodeList>::iterator acl_end;
  58. public:
  59. explicit FuncActivation(Code *code, Inter *inter_) : Activation(inter_), call{code,} {}
  60. ~FuncActivation() override;
  61. ActivationStatus getCode(Code *&code) override;
  62. void endRun() override;
  63. };
  64. }
  65. #endif //AFUN_ACTIVATION_H