Skip to content

Commit

Permalink
Revert Common FieldRef and ArrayAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
Lipen committed Jun 14, 2024
1 parent 42b6dd8 commit eb988d9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ interface CommonValue : CommonExpr
interface CommonThis : CommonValue

interface CommonArgument : CommonValue

interface CommonFieldRef : CommonValue {
val instance: CommonValue? // null for static fields
// val classField: CommonField
}

interface CommonArrayAccess : CommonValue {
val array: CommonValue
val index: CommonValue
}
12 changes: 7 additions & 5 deletions jacodb-api-jvm/src/main/kotlin/org/jacodb/api/jvm/cfg/JcInst.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
package org.jacodb.api.jvm.cfg

import org.jacodb.api.common.cfg.CommonArgument
import org.jacodb.api.common.cfg.CommonArrayAccess
import org.jacodb.api.common.cfg.CommonAssignInst
import org.jacodb.api.common.cfg.CommonCallExpr
import org.jacodb.api.common.cfg.CommonCallInst
import org.jacodb.api.common.cfg.CommonExpr
import org.jacodb.api.common.cfg.CommonFieldRef
import org.jacodb.api.common.cfg.CommonGotoInst
import org.jacodb.api.common.cfg.CommonIfInst
import org.jacodb.api.common.cfg.CommonInst
Expand Down Expand Up @@ -848,9 +850,9 @@ data class JcArgument(
interface JcRef : JcValue

data class JcFieldRef(
val instance: JcValue?,
override val instance: JcValue?,
val field: JcTypedField,
) : JcRef {
) : JcRef, CommonFieldRef {

override val type: JcType
get() = this.field.type
Expand All @@ -866,10 +868,10 @@ data class JcFieldRef(
}

data class JcArrayAccess(
val array: JcValue,
val index: JcValue,
override val array: JcValue,
override val index: JcValue,
override val type: JcType,
) : JcRef {
) : JcRef, CommonArrayAccess {

override val operands: List<JcValue>
get() = listOf(array, index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.jacodb.panda.dynamic.api

import org.jacodb.api.common.cfg.CommonArgument
import org.jacodb.api.common.cfg.CommonArrayAccess
import org.jacodb.api.common.cfg.CommonFieldRef
import org.jacodb.api.common.cfg.CommonThis
import org.jacodb.api.common.cfg.CommonValue

Expand Down Expand Up @@ -190,10 +192,10 @@ data class PandaMethodConstant(
interface PandaComplexValue : PandaValue

data class PandaFieldRef(
val instance: PandaValue?, // null for static fields
override val instance: PandaValue?, // null for static fields
val classField: PandaField,
override val type: PandaType,
) : PandaComplexValue {
) : PandaComplexValue, CommonFieldRef {
override val operands: List<PandaValue>
get() = listOfNotNull(instance)

Expand All @@ -207,10 +209,10 @@ data class PandaFieldRef(
}

data class PandaArrayAccess(
val array: PandaValue,
val index: PandaValue,
override val array: PandaValue,
override val index: PandaValue,
override val type: PandaType,
) : PandaComplexValue {
) : PandaComplexValue, CommonArrayAccess {
override val operands: List<PandaValue>
get() = listOf(array, index)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
package org.jacodb.panda.staticvm.cfg

import org.jacodb.api.common.cfg.CommonArgument
import org.jacodb.api.common.cfg.CommonArrayAccess
import org.jacodb.api.common.cfg.CommonCallExpr
import org.jacodb.api.common.cfg.CommonExpr
import org.jacodb.api.common.cfg.CommonFieldRef
import org.jacodb.api.common.cfg.CommonInstanceCallExpr
import org.jacodb.api.common.cfg.CommonThis
import org.jacodb.api.common.cfg.CommonValue
Expand Down Expand Up @@ -72,9 +74,9 @@ class PandaThis(
}

class PandaFieldRef(
val instance: PandaValue?,
override val instance: PandaValue?,
val field: PandaField,
) : PandaValue {
) : PandaValue, CommonFieldRef {

override val type: PandaType
get() = this.field.type
Expand All @@ -86,10 +88,10 @@ class PandaFieldRef(
}

class PandaArrayAccess(
val array: PandaValue,
val index: PandaValue,
override val array: PandaValue,
override val index: PandaValue,
override val type: PandaType,
) : PandaValue {
) : PandaValue, CommonArrayAccess {
override val operands: List<PandaValue>
get() = listOf(array, index)

Expand Down

0 comments on commit eb988d9

Please sign in to comment.