2
0

object-value.inline.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef AFUN_OBJECT_VALUE_INLINE_H
  2. #define AFUN_OBJECT_VALUE_INLINE_H
  3. #include "object-value.h"
  4. namespace aFuncore {
  5. size_t VarSpace::getCount() {
  6. std::unique_lock<std::mutex> mutex{lock};
  7. return var.size();
  8. }
  9. Object *VarSpace::findObject(const std::string &name) {
  10. Var *ret = findVar(name);
  11. return ret ? ret->getData() : nullptr;
  12. }
  13. ProtectVarSpace::ProtectVarSpace(Inter &inter) : VarSpace(inter), is_protect{false} {
  14. }
  15. ProtectVarSpace::ProtectVarSpace(Environment &env_) : VarSpace(env_), is_protect{false} {
  16. }
  17. bool ProtectVarSpace::getProtect() const {
  18. return is_protect;
  19. }
  20. bool ProtectVarSpace::setProtect(bool protect) {
  21. bool ret = is_protect; is_protect = protect; return ret;
  22. }
  23. Function::CallFunction::ArgCodeList::ArgCodeList(const Code::ByteCode *code_) : code{code_}, ret{nullptr} {
  24. }
  25. Function::CallFunction::ArgCodeList::~ArgCodeList() {
  26. if (ret != nullptr)
  27. ret->delReference();
  28. }
  29. Object *Function::CallFunction::ArgCodeList::setObject(Object *res) {
  30. Object *obj = ret;
  31. ret = res;
  32. if (ret != nullptr)
  33. ret->addReference();
  34. return obj;
  35. }
  36. Object *Function::CallFunction::ArgCodeList::getObject() {
  37. return ret;
  38. }
  39. ImportFunction::ImportFunction(Inter &inter_) : Object("Function", inter_) {
  40. }
  41. ImportFunction::ImportFunction(Environment &env_) : Object("Function", env_) {
  42. }
  43. };
  44. #endif //AFUN_OBJECT_VALUE_INLINE_H