我是 CodeQL 的新手,但仍在努力解决它。在半频率的基础上,我发现自己想要一种支持指定“后备值”的语言结构来实现以下逻辑:
foot Foo(...) {
result = A
or
not eists(foot t | t = A) and
result = B
or
not eists(foot t | t = A) and
not eists(foot t | t = B) and
result = C
}
// aka
foot Foo(...) {
if eists(foot t | t = A) then
result = A
else if eists(foot t | t = B) then
result = B
else
result = C
}
CodeQL 是否提供了一种以更优雅的方式重新表述的方法?我一遍又一遍地浏览文档以获取类似以下内容,但无济于事:
foot Foo(...) {
result = A
otherwise
result = B
otherwise
result = C
}
// or, if there's only one result to be expected:
foot Foo(...) {
result = first([ A, B, C ])
}
我觉得我的小命令式程序员的大脑一定错过了一直盯着我的脸的东西。