value.h 1.8 KB

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