Interpreter
public struct Interpreter
A virtual machine that executes Hylo’s in-memory IR representation.
-
The program to be executed.
Declaration
Swift
private let program: IR.Program -
The stack- and dynamically-allocated memory in use by the program.
Declaration
Swift
private var memory: Memory -
Local variables, parameters, and return addresses.
Declaration
Swift
private var callStack: Stack -
Identity of the next instruction to be executed.
Declaration
Swift
private var programCounter: CodePointer -
True iff the program is still running.
Declaration
Swift
public private(set) var isRunning: Bool { get } -
Text written so far to the process’ standard output stream.
Declaration
Swift
public private(set) var standardOutput: String { get } -
Text written so far to the process’ standard error stream.
Declaration
Swift
public private(set) var standardError: String { get } -
The top stack frame.
Declaration
Swift
private var topOfStack: StackFrame { get set } -
An instance executing
p.Precondition
p.entry != nilDeclaration
Swift
public init(_ p: IR.Program) -
Executes a single instruction.
Declaration
Swift
public mutating func step() throws -
Executes a single instruction without recording its result.
Declaration
Swift
private mutating func stepResult() throws -> InstructionResult? -
The instruction at which the program counter points.
Precondition
the program is running.Declaration
Swift
public var currentInstruction: any Instruction { get } -
Moves the program counter to the next instruction.
Declaration
Swift
mutating func advanceProgramCounter() throws -
Removes topmost stack frame and return code pointer to next instruction of any previous stack frame.
Precondition
the program is running.Declaration
Swift
mutating func popStackFrame() -> CodePointer -
Deallocates
aallocated on stack.Declaration
Swift
mutating func deallocateStack(_ a: Memory.Place) throws -
Interpret
xas a Place.Precondition
xis a Place.Declaration
Swift
func asPlace(_ x: Operand) -> Memory.Place -
Interpret
xas a builtin value.Precondition
xis builtin value.Declaration
Swift
func asBuiltinValue(_ x: Operand) -> BuiltinValue
View on GitHub