Better Support For Keysets

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-03-27 01:36:38 -04:00
parent fafc80553e
commit 99804e3053
7 changed files with 476 additions and 51 deletions
+12 -2
View File
@@ -18,7 +18,7 @@
import Common
import P4Lang
extension KeysetExpression: EvaluatableExpression {
extension SelectCaseExpression: EvaluatableExpression {
public func evaluate(execution: Common.ProgramExecution) -> Common.Result<any Common.P4Value> {
return execution.scopes.lookup(identifier: next_state_identifier)
}
@@ -33,7 +33,7 @@ extension SelectExpression: EvaluatableExpression {
public func evaluate(execution: Common.ProgramExecution) -> Common.Result<any Common.P4Value> {
switch self.selector.evaluate(execution: execution) {
case .Ok(let selector_value):
for kse in self.keyset_expressions {
for kse in self.select_expressions {
if case .Ok(let kse_key) = kse.key.evaluate(execution: execution),
kse_key.eq(rhs: selector_value)
{
@@ -374,3 +374,13 @@ extension FieldAccessExpression: EvaluatableLValueExpression {
return .Ok(())
}
}
extension KeysetExpression: EvaluatableExpression {
public func evaluate(execution: Common.ProgramExecution) -> Common.Result<any Common.P4Value> {
return self.kse_evaluate(execution: execution)
}
public func type() -> any Common.P4Type {
return self.kse_type()
}
}