value.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. namespace aFuncore {
  9. class Inter;
  10. class AFUN_CORE_EXPORT Object : public GcObject<class Object> {
  11. public:
  12. Inter &inter;
  13. const std::string type; // 标识 Object 的字符串
  14. explicit Object(const std::string &type_, Inter &inter_);
  15. ~Object() override = default;
  16. };
  17. class AFUN_CORE_EXPORT Function : public Object {
  18. public:
  19. class AFUN_CORE_EXPORT CallFunction;
  20. inline Function(const std::string &type_, Inter &inter_);
  21. virtual CallFunction *getCallFunction(Code *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() = 0;
  32. virtual void runFunction() = 0;
  33. };
  34. struct Function::CallFunction::ArgCodeList {
  35. Code *code = nullptr;
  36. Object *ret = nullptr;
  37. };
  38. class AFUN_CORE_EXPORT Literaler : public Object {
  39. public:
  40. inline Literaler(const std::string &type_, Inter &inter_);
  41. virtual void getObject(const std::string &literal, char prefix) = 0;
  42. };
  43. class AFUN_CORE_EXPORT CallBackVar : public Object {
  44. public:
  45. inline CallBackVar(const std::string &type_, Inter &inter_);
  46. virtual inline bool isCallBack();
  47. virtual void callBack() = 0;
  48. };
  49. };
  50. #include "value.inline.h"
  51. #endif //AFUN_VALUE_H