XCTLRuntimeAbstractContext.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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, assumeExport export: Bool)
  26. func setValueToRootAssumeExport(_ value: XCTLRuntimeVariable, forName name: String)
  27. func setValueIgnoreParent(_ value: XCTLRuntimeVariable, forName name: String)
  28. func addImport(name: String)
  29. func addExport(name: String)
  30. func hasExport(name: String) -> Bool
  31. func allocateObject(name: String, args: [XCTLRuntimeVariable]) throws -> XCTLRuntimeVariable
  32. func addLazyStatement(_ stmt: XCTLReferencedVariableStatement)
  33. func makeSubContext() -> XCTLRuntimeAbstractContext
  34. func findConditionFrame() -> XCTLConditionParentStatementFrame?
  35. func findListFrame() -> XCTLListStatementFrame?
  36. func findForFrame() -> XCTLForStatementFrame?
  37. func recordConditionFrame(_ frame: XCTLConditionParentStatementFrame?)
  38. func recordListFrame(_ frame: XCTLListStatementFrame?)
  39. func recordForFrame(_ frame: XCTLForStatementFrame?)
  40. func getParentContext() -> XCTLRuntimeAbstractContext?
  41. var variableStack: XCTLRuntimeVariableStackFrame { get set }
  42. }