module.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef _SCRIPT_MODULE_H_
  2. #define _SCRIPT_MODULE_H_
  3. #include "runtime.h"
  4. #include "console/console.h"
  5. #include "platform/types.h"
  6. namespace Con
  7. {
  8. class Module
  9. {
  10. private:
  11. S32 mRefCount = 0;
  12. public:
  13. Module() = default;
  14. virtual ~Module() = default;
  15. void incRefCount() { mRefCount++; }
  16. void decRefCount() { mRefCount--; if (!mRefCount) delete this; }
  17. virtual const char* getFunctionArgs(StringTableEntry functionName, U32 functionOffset) = 0;
  18. virtual const char* getPath() = 0;
  19. virtual const char* getName() = 0;
  20. virtual EvalResult exec(U32 offset, const char* fnName, Namespace* ns, U32 argc,
  21. ConsoleValue* argv, bool noCalls, StringTableEntry packageName,
  22. S32 setFrame = -1) = 0;
  23. virtual void findBreakLine(U32 ip, U32& line, U32& instruction) {}
  24. virtual const char* getFileLine(U32 ip) { return ""; }
  25. /// Returns the first breakable line or 0 if none was found.
  26. /// @param lineNumber The one based line number.
  27. virtual U32 findFirstBreakLine(U32 lineNumber) { return 0; }
  28. /// Set a OP_BREAK instruction on a line. If a break
  29. /// is not possible on that line it returns false.
  30. /// @param lineNumber The one based line number.
  31. virtual bool setBreakpoint(U32 lineNumber) { return false;}
  32. virtual void setAllBreaks() {}
  33. virtual void clearAllBreaks() {}
  34. virtual void clearBreakpoint(U32 lineNumber) {}
  35. virtual Vector<U32> getBreakableLines() { return {}; }
  36. };
  37. }
  38. #endif