Created
October 24, 2017 09:27
-
-
Save Groostav/a7aa6e0729734f6f94889c034074700b to your computer and use it in GitHub Desktop.
conversion method from my local antlr-based language to z3 constraints.
This file contains hidden or 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
override fun exitLiteral(ctx: LiteralContext) { | |
exprs.push(when { | |
ctx.FLOAT() != null -> z3.mkReal(ctx.FLOAT().text) | |
ctx.INTEGER() != null -> z3.mkReal(ctx.INTEGER().text) | |
ctx.CONSTANT() != null -> when(ctx.text.toLowerCase()){ | |
//RealExpr(z3, Native.rcfMkPi(z3)) | |
// "pi" -> z3.mkReal(Math.PI.toString()) | |
"pi" -> { | |
val exprCtor = RealExpr::class.constructors.single().apply { isAccessible = true } | |
val nCtxMember = Context::class.members.single { it.name == "nCtx" }.apply { isAccessible = true } | |
exprCtor.call(z3, Native.rcfMkPi(nCtxMember.call(z3) as Long)) | |
// results in JVM crash with EXCEPTION_ACCESS_VIOLATION | |
} | |
"e" -> z3.mkReal(Math.E.toString()) | |
else -> TODO() | |
} | |
else -> TODO() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment