value.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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;
  18. };
  19. class AFUN_CORE_EXPORT Function : public virtual Object {
  20. public:
  21. class AFUN_CORE_EXPORT CallFunction;
  22. virtual CallFunction *getCallFunction(const Code::ByteCode *code, Inter &inter) = 0;
  23. virtual inline bool isInfix();
  24. };
  25. class AFUN_CORE_EXPORT Function::CallFunction {
  26. public:
  27. struct ArgCodeList;
  28. CallFunction() = default;
  29. virtual ~CallFunction() = default;
  30. CallFunction(const CallFunction &)=delete;
  31. CallFunction &operator=(const CallFunction &)=delete;
  32. virtual std::list<ArgCodeList> *getArgCodeList(Inter &inter, Activation &activation, const Code::ByteCode *call) = 0;
  33. virtual void runFunction() = 0;
  34. };
  35. struct Function::CallFunction::ArgCodeList {
  36. const Code::ByteCode *code = nullptr;
  37. Object *ret = nullptr;
  38. };
  39. class AFUN_CORE_EXPORT Literaler : public virtual Object {
  40. public:
  41. virtual void getObject(const std::string &literal, char prefix, Inter &inter, Activation &activation) = 0;
  42. };
  43. class AFUN_CORE_EXPORT CallBackVar : public virtual Object {
  44. public:
  45. virtual inline bool isCallBack(Inter &inter, Activation &activation);
  46. virtual void callBack(Inter &inter, Activation &activation) = 0;
  47. };
  48. };
  49. #include "value.inline.h"
  50. #endif //AFUN_VALUE_H