XCTLRuntimeAbstractContext.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // XCTLRuntimeAbstractContext.swift
  3. // notebook
  4. //
  5. // Created by 邢铖 on 2023/5/25.
  6. //
  7. import Foundation
  8. internal class XCTLRuntimeVariableStackFrame {
  9. private var stack = [XCTLRuntimeVariable]()
  10. internal func pushVariable(_ variable: XCTLRuntimeVariable) {
  11. self.stack.append(variable)
  12. }
  13. internal func popVariable() -> XCTLRuntimeVariable? {
  14. self.stack.popLast()
  15. }
  16. internal var isEmpty: Bool {
  17. return self.stack.isEmpty
  18. }
  19. }
  20. internal protocol XCTLRuntimeAbstractContext: AnyObject {
  21. var nativeObjectInstance: NSObject { get }
  22. func valueDefined(_ name: String) -> Bool
  23. func value(forName name: String) -> XCTLRuntimeVariable?
  24. func setValue(_ value: XCTLRuntimeVariable, forName name: String)
  25. func setValueToRoot(_ value: XCTLRuntimeVariable, forName name: String)
  26. func setValueIgnoreParent(_ value: XCTLRuntimeVariable, forName name: String)
  27. func addImport(name: String)
  28. func addExport(name: String)
  29. func allocateObject(name: String, args: [XCTLRuntimeVariable]) throws -> XCTLRuntimeVariable
  30. func addLazyStatement(_ stmt: XCTLStatement)
  31. func makeSubContext() -> XCTLRuntimeAbstractContext
  32. func findConditionFrame() -> XCTLConditionParentStatementFrame?
  33. func findListFrame() -> XCTLListStatementFrame?
  34. func findForFrame() -> XCTLForStatementFrame?
  35. func recordConditionFrame(_ frame: XCTLConditionParentStatementFrame?)
  36. func recordListFrame(_ frame: XCTLListStatementFrame?)
  37. func recordForFrame(_ frame: XCTLForStatementFrame?)
  38. func getParentContext() -> XCTLRuntimeAbstractContext?
  39. var variableStack: XCTLRuntimeVariableStackFrame { get set }
  40. }