Better Support For Keysets
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user