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:
@@ -20,28 +20,28 @@ import Common
|
||||
public struct Statement {}
|
||||
|
||||
public struct VariableDeclarationStatement {
|
||||
public var initializer: EvaluatableExpression
|
||||
public var identifier: Identifier
|
||||
public init(identifier: Identifier, withInitializer initializer: EvaluatableExpression) {
|
||||
public var initializer: P4Expression
|
||||
public var identifier: TypedIdentifier
|
||||
public init(identifier: TypedIdentifier, withInitializer initializer: P4Expression) {
|
||||
self.identifier = identifier
|
||||
self.initializer = initializer
|
||||
}
|
||||
}
|
||||
|
||||
public struct ConditionalStatement {
|
||||
public var condition: EvaluatableExpression
|
||||
public var thenn: EvaluatableStatement
|
||||
public var elss: EvaluatableStatement?
|
||||
public var condition: P4Expression
|
||||
public var thenn: P4Statement
|
||||
public var elss: P4Statement?
|
||||
|
||||
public init(condition: EvaluatableExpression, withThen thenn: EvaluatableStatement) {
|
||||
public init(condition: P4Expression, withThen thenn: P4Statement) {
|
||||
self.condition = condition
|
||||
self.thenn = thenn
|
||||
self.elss = .none
|
||||
}
|
||||
|
||||
public init(
|
||||
condition: EvaluatableExpression, withThen thenn: EvaluatableStatement,
|
||||
andElse elss: EvaluatableStatement
|
||||
condition: P4Expression, withThen thenn: P4Statement,
|
||||
andElse elss: P4Statement
|
||||
) {
|
||||
self.condition = condition
|
||||
self.thenn = thenn
|
||||
@@ -50,18 +50,18 @@ public struct ConditionalStatement {
|
||||
}
|
||||
|
||||
public struct BlockStatement {
|
||||
public var statements: [EvaluatableStatement]
|
||||
public var statements: [P4Statement]
|
||||
|
||||
public init(_ statements: [EvaluatableStatement]) {
|
||||
public init(_ statements: [P4Statement]) {
|
||||
self.statements = statements
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct ReturnStatement {
|
||||
public let value: EvaluatableExpression
|
||||
public let value: P4Expression
|
||||
|
||||
public init(_ value: EvaluatableExpression) {
|
||||
public init(_ value: P4Expression) {
|
||||
self.value = value
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user