compiler, runtime: Refactor P4Type to P4QualifiedType
Also, refer to the different pieces of the qualified type as qualifiers and not attributes. Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -28,15 +28,15 @@ public struct ExpressionStatement {
|
||||
public struct Program {
|
||||
public var types: [P4DataType] = Array()
|
||||
public var externs: [P4DataType] = Array()
|
||||
public var instances: [P4Type] = Array()
|
||||
public var instances: [P4QualifiedType] = Array()
|
||||
|
||||
/// Type of closure for filtering results from ``Program/InstancesWithTypes(_:)``
|
||||
public typealias TypeFilter = (P4Type) -> Bool
|
||||
public typealias TypeFilter = (P4QualifiedType) -> Bool
|
||||
/// Type of closure for filtering results from ``Program/TypesWithTypes(_:)``
|
||||
public typealias DataTypeFilter = (P4DataType) -> Bool
|
||||
|
||||
/// Retrieve global instances in the compiled P4 program.
|
||||
public func InstancesWithTypes() -> [P4Type] {
|
||||
public func InstancesWithTypes() -> [P4QualifiedType] {
|
||||
return self.instances
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public struct Program {
|
||||
///
|
||||
/// @Snippet(path: "use-program-instanceswithtypes", slice: "include")
|
||||
///
|
||||
public func InstancesWithTypes(_ filter: TypeFilter) -> [P4Type] {
|
||||
public func InstancesWithTypes(_ filter: TypeFilter) -> [P4QualifiedType] {
|
||||
return self.instances.filter { instance in
|
||||
filter(instance)
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public struct Program {
|
||||
|
||||
public func find_parser(withName name: Identifier) -> Result<Parser> {
|
||||
for instance in self.instances {
|
||||
guard let parser = instance.dataType() as? Parser else {
|
||||
guard let parser = instance.baseType() as? Parser else {
|
||||
continue
|
||||
}
|
||||
if parser.name == name {
|
||||
|
||||
Reference in New Issue
Block a user