rt_normal_activation.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef AFUN_RT_NORMAL_ACTIVATION_H
  2. #define AFUN_RT_NORMAL_ACTIVATION_H
  3. #include "aFunRuntimeExport.h"
  4. #include "aFuncore.h"
  5. #include "rt_func_object.h"
  6. #include "rt_varspace_object.h"
  7. #include "rt_var_object.h"
  8. namespace aFunrt {
  9. class AFUN_RT_EXPORT NormalActivation : public aFuncore::Activation {
  10. public:
  11. class AFUN_RT_EXPORT VarList {
  12. public:
  13. AFUN_INLINE explicit VarList();
  14. virtual ~VarList();
  15. AFUN_INLINE VarList(VarList &&new_varlist) noexcept ;
  16. AFUN_INLINE VarList &operator=(VarList &&new_varlist) noexcept;
  17. VarList(const VarList &) = delete;
  18. VarList &operator=(const VarList &) = delete;
  19. void clear();
  20. void connect(VarList &new_varlist);
  21. AFUN_INLINE void push(VarSpace *varspace_);
  22. AFUN_INLINE size_t count();
  23. template <typename Callable,typename...T>
  24. void forEach(Callable func, T...arg);
  25. [[nodiscard]] virtual Var *findVar(const std::string &name);
  26. virtual bool defineVar(const std::string &name, aFuncore::Object *data);
  27. virtual bool defineVar(const std::string &name, Var *data);
  28. virtual bool setVar(const std::string &name, aFuncore::Object *data);
  29. virtual bool delVar(const std::string &name);
  30. [[nodiscard]] AFUN_INLINE aFuncore::Object *findObject(const std::string &name);
  31. private:
  32. std::list<VarSpace *> varspace;
  33. };
  34. aFuncore::Inter &inter;
  35. explicit NormalActivation(aFuncore::Inter &inter_);
  36. ~NormalActivation() override;
  37. void runCode(const aFuncode::Code::ByteCode *code) override;
  38. void endRun() override;
  39. [[nodiscard]] AFUN_INLINE VarList &getVarlist();
  40. [[nodiscard]] aFuncore::UpMessageStream &getUpStream() override;
  41. [[nodiscard]] aFuncore::DownMessageStream &getDownStream() override;
  42. [[nodiscard]] aFuntool::FileLine getFileLine() override;
  43. [[nodiscard]] const aFuntool::FilePath &getFilePath() override;
  44. protected:
  45. VarList varlist;
  46. aFuncore::UpMessageStream up;
  47. aFuncore::DownMessageStream down;
  48. aFuntool::FilePath path;
  49. aFuntool::FileLine line;
  50. virtual void runCodeElement(const aFuncode::Code::ByteCode *code);
  51. virtual void runCodeBlockP(const aFuncode::Code::ByteCode *code);
  52. virtual void runCodeBlockC(const aFuncode::Code::ByteCode *code);
  53. virtual void runCodeBlockB(const aFuncode::Code::ByteCode *code);
  54. };
  55. }
  56. #include "rt_normal_activation.inline.h"
  57. #include "rt_normal_activation.template.h"
  58. #endif //AFUN_RT_NORMAL_ACTIVATION_H