Skip to content

Commit

Permalink
support NaN and Infinity constants
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMilshin committed May 30, 2024
1 parent df8619e commit 4331b67
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,28 @@ object PandaUndefinedConstant : PandaConstant {
}
}

object PandaInfinityConstant : PandaConstant {
override val type: PandaType
get() = PandaNumberType

override fun toString(): String = "Infinity"

override fun <T> accept(visitor: PandaExprVisitor<T>): T {
return visitor.visitPandaInfinityConstant(this)
}
}

object PandaNaNConstant : PandaConstant {
override val type: PandaType
get() = PandaAnyType

override fun toString(): String = "NaN"

override fun <T> accept(visitor: PandaExprVisitor<T>): T {
return visitor.visitPandaNaNConstant(this)
}
}

object PandaNullConstant : PandaConstant {
override val operands: List<PandaValue>
get() = emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ interface PandaExprVisitor<out T> : CommonExpr.Visitor<T> {
fun visitPandaNumberConstant(expr: PandaNumberConstant): T
fun visitPandaStringConstant(expr: PandaStringConstant): T
fun visitPandaUndefinedConstant(expr: PandaUndefinedConstant): T
fun visitPandaInfinityConstant(expr: PandaInfinityConstant): T
fun visitPandaNaNConstant(expr: PandaNaNConstant): T
fun visitPandaNullConstant(expr: PandaNullConstant): T
fun visitPandaFieldRef(expr: PandaFieldRef): T
fun visitPandaArrayAccess(expr: PandaArrayAccess): T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import org.jacodb.panda.dynamic.api.PandaGeExpr
import org.jacodb.panda.dynamic.api.PandaGotoInst
import org.jacodb.panda.dynamic.api.PandaGtExpr
import org.jacodb.panda.dynamic.api.PandaIfInst
import org.jacodb.panda.dynamic.api.PandaInfinityConstant
import org.jacodb.panda.dynamic.api.PandaInst
import org.jacodb.panda.dynamic.api.PandaInstLocation
import org.jacodb.panda.dynamic.api.PandaInstRef
Expand All @@ -60,6 +61,7 @@ import org.jacodb.panda.dynamic.api.PandaMethod
import org.jacodb.panda.dynamic.api.PandaMethodConstant
import org.jacodb.panda.dynamic.api.PandaModExpr
import org.jacodb.panda.dynamic.api.PandaMulExpr
import org.jacodb.panda.dynamic.api.PandaNaNConstant
import org.jacodb.panda.dynamic.api.PandaNegExpr
import org.jacodb.panda.dynamic.api.PandaNeqExpr
import org.jacodb.panda.dynamic.api.PandaNewExpr
Expand Down Expand Up @@ -627,6 +629,14 @@ class IRParser(
handle(PandaUndefinedConstant)
}

opcode == "Intrinsic.ldinfinity" -> {
handle(PandaInfinityConstant)
}

opcode == "Intrinsic.ldnan" -> {
handle(PandaNaNConstant)
}

opcode == "Intrinsic.defineclasswithbuffer" -> {
val todoExpr = TODOExpr(opcode, inputs) // TODO
handle(todoExpr)
Expand Down

0 comments on commit 4331b67

Please sign in to comment.