common, codegen: Implement Visitor And Use For CodeGen
Implement a generic visitor for components of a P4 program and use it to start P4 code generation (according to the behavioral model). Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -73,6 +73,14 @@ public func Map<T, U>(input: T, block: (T) -> U) -> U {
|
||||
return block(input)
|
||||
}
|
||||
|
||||
public func Fold<T, A>(input: [T], initial: A, block: (T, A) -> A) -> A {
|
||||
var result = initial
|
||||
for i in input {
|
||||
result = block(i, result)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@freestanding(expression) public macro RequireOkResult<T>(_: Result<T>) -> Bool =
|
||||
#externalMacro(module: "Macros", type: "RequireResult")
|
||||
@freestanding(expression) public macro RequireErrorResult<T>(
|
||||
|
||||
Reference in New Issue
Block a user