value.h 1.8 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. #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 Object {
  19. public:
  20. class AFUN_CORE_EXPORT CallFunction;
  21. inline Function(const std::string &type_, Inter &inter_);
  22. virtual CallFunction *getCallFunction(Code *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() = 0;
  33. virtual void runFunction() = 0;
  34. };
  35. struct Function::CallFunction::ArgCodeList {
  36. Code *code = nullptr;
  37. Object *ret = nullptr;
  38. };
  39. class AFUN_CORE_EXPORT Literaler : public Object {
  40. public:
  41. inline Literaler(const std::string &type_, Inter &inter_);
  42. virtual void getObject(const std::string &literal, char prefix, Inter &inter) = 0;
  43. };
  44. class AFUN_CORE_EXPORT CallBackVar : public Object {
  45. public:
  46. inline CallBackVar(const std::string &type_, Inter &inter_);
  47. virtual inline bool isCallBack();
  48. virtual void callBack(Inter &inter) = 0;
  49. };
  50. };
  51. #include "value.inline.h"
  52. #endif //AFUN_VALUE_H