value.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef AFUN_VALUE_H
  2. #define AFUN_VALUE_H
  3. #include <list>
  4. #include <mutex>
  5. #include "aFuntool.h"
  6. #include "aFunCoreExport.h"
  7. #include "gc.h"
  8. #include "code.h"
  9. #include "inter.h"
  10. namespace aFuncore {
  11. class AFUN_CORE_EXPORT Object : public GcObject<class Object> {
  12. public:
  13. Environment &env;
  14. const std::string type; // 标识 Object 的字符串
  15. Object(std::string type_, Inter &inter);
  16. Object(std::string type_, Environment &env_);
  17. ~Object() override = default;
  18. protected:
  19. std::mutex lock;
  20. };
  21. class AFUN_CORE_EXPORT Function : public virtual Object {
  22. public:
  23. class AFUN_CORE_EXPORT CallFunction;
  24. virtual CallFunction *getCallFunction(const Code::ByteCode *code, Inter &inter) = 0;
  25. virtual inline bool isInfix();
  26. };
  27. class AFUN_CORE_EXPORT Function::CallFunction {
  28. public:
  29. struct ArgCodeList;
  30. CallFunction() = default;
  31. virtual ~CallFunction() = default;
  32. CallFunction(const CallFunction &)=delete;
  33. CallFunction &operator=(const CallFunction &)=delete;
  34. virtual std::list<ArgCodeList> *getArgCodeList(Inter &inter, Activation &activation, const Code::ByteCode *call) = 0;
  35. virtual void runFunction() = 0;
  36. };
  37. struct Function::CallFunction::ArgCodeList {
  38. const Code::ByteCode *code = nullptr;
  39. Object *ret = nullptr;
  40. };
  41. class AFUN_CORE_EXPORT Literaler : public virtual Object {
  42. public:
  43. virtual void getObject(const std::string &literal, char prefix, Inter &inter, Activation &activation) = 0;
  44. };
  45. class AFUN_CORE_EXPORT CallBackVar : public virtual Object {
  46. public:
  47. virtual inline bool isCallBack(Inter &inter, Activation &activation);
  48. virtual void callBack(Inter &inter, Activation &activation) = 0;
  49. };
  50. };
  51. #include "value.inline.h"
  52. #endif //AFUN_VALUE_H