Work On Derived Types

1. Add support for field access
2. Add support for proper type checking of array access
3. Add tests for nested field and array access

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-03-16 08:31:16 -04:00
parent 8ee20fcf9f
commit 2fd5ecf8d6
10 changed files with 629 additions and 72 deletions
+16 -1
View File
@@ -76,9 +76,24 @@ public struct BinaryOperatorExpression {
public struct ArrayAccessExpression {
public let indexor: EvaluatableExpression
public let name: EvaluatableExpression
public let type: P4Array
public init(withName name: EvaluatableExpression, withIndexor indexor: EvaluatableExpression) {
public init(
withName name: EvaluatableExpression, withType type: P4Array,
withIndexor indexor: EvaluatableExpression
) {
self.name = name
self.type = type
self.indexor = indexor
}
}
public struct FieldAccessExpression {
public let field: P4StructFieldIdentifier
public let strct: EvaluatableExpression
public init(withStruct strct: EvaluatableExpression, withField field: P4StructFieldIdentifier) {
self.strct = strct
self.field = field
}
}