runtime.rb 927 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. require "execjs/encoding"
  2. module ExecJS
  3. # Abstract base class for runtimes
  4. class Runtime
  5. class Context
  6. include Encoding
  7. def initialize(runtime, source = "")
  8. end
  9. def exec(source, options = {})
  10. raise NotImplementedError
  11. end
  12. def eval(source, options = {})
  13. raise NotImplementedError
  14. end
  15. def call(properties, *args)
  16. raise NotImplementedError
  17. end
  18. end
  19. def name
  20. raise NotImplementedError
  21. end
  22. def context_class
  23. self.class::Context
  24. end
  25. def exec(source)
  26. context = context_class.new(self)
  27. context.exec(source)
  28. end
  29. def eval(source)
  30. context = context_class.new(self)
  31. context.eval(source)
  32. end
  33. def compile(source)
  34. context_class.new(self, source)
  35. end
  36. def deprecated?
  37. false
  38. end
  39. def available?
  40. raise NotImplementedError
  41. end
  42. end
  43. end