-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
114 additions
and
73 deletions.
There are no files selected for viewing
28 changes: 22 additions & 6 deletions
28
...ontends/btor2-frontend/src/main/java/hu/bme/mit/theta/frontend/model/Btor2Declarations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
import hu.bme.mit.theta.core.decl.Decls.Var | ||
import hu.bme.mit.theta.core.decl.VarDecl | ||
import hu.bme.mit.theta.core.type.Type | ||
import hu.bme.mit.theta.core.type.bvtype.BvType | ||
import hu.bme.mit.theta.frontend.model.Btor2Node | ||
import hu.bme.mit.theta.frontend.model.Btor2NodeVisitor | ||
import java.math.BigInteger | ||
|
||
// Declarations | ||
|
||
abstract class Btor2Sort(override val nid: UInt) : Btor2Node(nid) | ||
// TODO needs to be generalized if arrays are added | ||
abstract class Btor2Sort(override val nid: UInt, open val width: UInt) : Btor2Node(nid) { | ||
abstract fun getType() : BvType | ||
} | ||
|
||
// TODO start supporting arrays | ||
// data class Btor2ArrayDeclaration(val id: Int, val indexSort: Btor2SortDeclaration, val elementSort: Btor2SortDeclaration) | ||
data class Btor2BvSort(override val nid: UInt, val width: UInt) : Btor2Sort(nid) { | ||
fun <R> accept(visitor: Btor2NodeVisitor<R>): R { | ||
return visitor.visit(this) | ||
data class Btor2BvSort(override val nid: UInt, override val width: UInt) : Btor2Sort(nid, width) { | ||
override fun getType(): BvType { | ||
return BvType.of(width.toInt()) | ||
} | ||
|
||
override fun <R, P> accept(visitor: Btor2NodeVisitor<R, P>, param : P): R { | ||
return visitor.visit(this, param) | ||
} | ||
} | ||
|
||
// Constants | ||
// it can be in binary, decimal or hex in the circuit, but we extract the actual value to the int from that | ||
data class Btor2Const(override val nid: UInt, val value: BigInteger, override val sort: Btor2Sort) : Btor2Node(nid) { | ||
fun <R> accept(visitor: Btor2NodeVisitor<R>): R { | ||
return visitor.visit(this) | ||
private val constVar = Var("node_" + nid, sort.getType()) | ||
override fun <R, P> accept(visitor: Btor2NodeVisitor<R, P>, param : P): R { | ||
return visitor.visit(this, param) | ||
} | ||
|
||
fun getVar(): VarDecl<BvType> { | ||
return constVar | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters