compiler, common, testing: Support For Checking For Invalid Statements
Add support functions to check whether a (block of) statement(s) contains any statements that should not appear in that block (e.g., switch in an action). Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -351,3 +351,25 @@ extension Argument: Compilable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ContainsInvalidStatements(
|
||||
statement: EvaluatableStatement, invalids: [EvaluatableStatement.Type]
|
||||
) -> Bool {
|
||||
for es in invalids {
|
||||
if type(of: statement) == es {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ContainsInvalidStatements(block: BlockStatement, invalids: [EvaluatableStatement.Type]) -> Bool {
|
||||
return block.statements.contains() { statement in
|
||||
for es in invalids {
|
||||
if type(of: statement) == es {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user