compiler, runtime: Begin Runtime Refactor
Ultimately, the goal is to completely separate the compilation from the runtime to make it possible to have the interpreter/evaluator be "just another" entity that can perform meaningful work when given a parsed GP4 program. Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -18,7 +18,11 @@
|
||||
import Common
|
||||
import P4Lang
|
||||
|
||||
extension ParserAssignmentStatement: EvaluatableStatement {
|
||||
extension ParserAssignmentStatement: P4Statement {
|
||||
public func effect(context: Common.CompilerContext) -> Common.CompilerContext {
|
||||
return context
|
||||
}
|
||||
|
||||
public func evaluate(execution: ProgramExecution) -> (ControlFlow, ProgramExecution) {
|
||||
let updated_execution = execution
|
||||
//let result = self.value.evaluate(execution: updated_execution)
|
||||
@@ -192,3 +196,19 @@ extension ParserValue: LibraryCallable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ParserState: P4Statement {
|
||||
public func evaluate(
|
||||
execution: Common.ProgramExecution
|
||||
) -> (Common.ControlFlow, Common.ProgramExecution) {
|
||||
return (
|
||||
ControlFlow.Error,
|
||||
execution.setError(error: Error(withMessage: "Cannot evaluate unspecialized parser state"))
|
||||
)
|
||||
}
|
||||
|
||||
public func effect(context: Common.CompilerContext) -> Common.CompilerContext {
|
||||
return context.update(
|
||||
newTypes: context.types.declare(identifier: self.getName(), withValue: self))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user