value.hpp 1.6 KB

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