From 1847df7fab7857b2255a0de2142babc9a4caaf91 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Mon, 20 Apr 2026 03:35:44 -0400 Subject: [PATCH] compiler: Actions Have BlockStatements for Bodies Signed-off-by: Will Hawkins --- Sources/P4Lang/Control.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Sources/P4Lang/Control.swift b/Sources/P4Lang/Control.swift index 4775620..814032d 100644 --- a/Sources/P4Lang/Control.swift +++ b/Sources/P4Lang/Control.swift @@ -23,13 +23,13 @@ public struct Action: CustomStringConvertible { + "\(self.name) with parameters \(self.params) and body \(String(describing: self.body))" } - public var body: EvaluatableStatement? + public var body: BlockStatement? public var params: ParameterList public var name: Identifier public init( named name: Identifier, withParameters parameters: ParameterList, - withBody body: EvaluatableStatement? + withBody body: BlockStatement? ) { self.name = name self.params = parameters @@ -181,6 +181,7 @@ public struct Control: P4DataType, P4DataValue, Equatable, CustomStringConvertib let table: Table let _parameters: ParameterList let _name: Identifier + let apply: ApplyStatement public var parameters: ParameterList { _parameters @@ -192,12 +193,13 @@ public struct Control: P4DataType, P4DataValue, Equatable, CustomStringConvertib public init( named: Identifier, withParameters parameters: ParameterList, withTable table: Table, - withActions actions: Actions + withActions actions: Actions, withApply apply: ApplyStatement ) { self._name = named self._parameters = parameters self.actions = actions self.table = table + self.apply = apply } public func def() -> any P4DataValue { @@ -207,7 +209,7 @@ public struct Control: P4DataType, P4DataValue, Equatable, CustomStringConvertib withTable: Table( withName: Identifier(name: "empty"), withPropertyList: TablePropertyList(withActions: TableActions(), withKeys: TableKeys())), - withActions: Actions(withActions: [])) + withActions: Actions(withActions: []), withApply: ApplyStatement()) } }