FIR DFA: generate type implications on all null comparisons
This commit is contained in:
@@ -72,16 +72,6 @@ abstract class LogicSystem<FLOW : Flow>(protected val context: ConeInferenceCont
|
||||
statements: Collection<Implication>,
|
||||
)
|
||||
|
||||
/**
|
||||
* Recursively collects all TypeStatements approved by [approvedStatement] and all predicates
|
||||
* that has been implied by it
|
||||
* TODO: or not recursively?
|
||||
*/
|
||||
fun approveOperationStatement(flow: FLOW, approvedStatement: OperationStatement): Collection<TypeStatement> {
|
||||
val statements = getImplicationsWithVariable(flow, approvedStatement.variable)
|
||||
return approveOperationStatement(flow, approvedStatement, statements).values
|
||||
}
|
||||
|
||||
fun orForTypeStatements(left: TypeStatements, right: TypeStatements): MutableTypeStatements {
|
||||
if (left.isEmpty() || right.isEmpty()) return mutableMapOf()
|
||||
val map = mutableMapOf<RealVariable, MutableTypeStatement>()
|
||||
|
||||
@@ -60,18 +60,25 @@ infix fun DataFlowVariable.notEq(constant: Boolean?): OperationStatement {
|
||||
|
||||
infix fun OperationStatement.implies(effect: Statement<*>): Implication = Implication(this, effect)
|
||||
|
||||
infix fun RealVariable.typeEq(type: ConeKotlinType): TypeStatement =
|
||||
if (type !is ConeErrorType) {
|
||||
MutableTypeStatement(this, linkedSetOf<ConeKotlinType>().apply { this += type }, HashSet())
|
||||
} else {
|
||||
MutableTypeStatement(this)
|
||||
infix fun RealVariable.typeEq(type: ConeKotlinType): MutableTypeStatement =
|
||||
MutableTypeStatement(this) andTypeEq type
|
||||
|
||||
infix fun RealVariable.typeNotEq(type: ConeKotlinType): MutableTypeStatement =
|
||||
MutableTypeStatement(this) andTypeNotEq type
|
||||
|
||||
infix fun MutableTypeStatement.andTypeEq(type: ConeKotlinType): MutableTypeStatement =
|
||||
this.apply {
|
||||
if (type !is ConeErrorType) {
|
||||
exactType += type
|
||||
}
|
||||
}
|
||||
|
||||
infix fun RealVariable.typeNotEq(type: ConeKotlinType): TypeStatement =
|
||||
if (type !is ConeErrorType) {
|
||||
MutableTypeStatement(this, linkedSetOf(), LinkedHashSet<ConeKotlinType>().apply { this += type })
|
||||
} else {
|
||||
MutableTypeStatement(this)
|
||||
infix fun MutableTypeStatement.andTypeNotEq(type: ConeKotlinType): MutableTypeStatement =
|
||||
this.apply {
|
||||
require(exactNotType.isEmpty()) { "statement $this already has a negation; use `logicSystem.and`" }
|
||||
if (type !is ConeErrorType) {
|
||||
exactNotType += type
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------- Utils ---------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user