value.h 1.8 KB

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