-
Notifications
You must be signed in to change notification settings - Fork 15
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
96 changed files
with
583 additions
and
143 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
dependencies { | ||
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: "1.8.3" | ||
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: kotlin_version | ||
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_version | ||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: coroutines_version | ||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-collections-immutable-jvm', version: collections_version | ||
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-serialization-cbor', version: '1.3.3' | ||
implementation group: 'org.jetbrains.xodus', name: 'xodus-entity-store', version: xodus_version | ||
implementation group: 'org.ow2.asm', name: 'asm', version: asm_version | ||
implementation group: 'org.ow2.asm', name: 'asm-tree', version: asm_version | ||
|
||
testImplementation(platform('org.junit:junit-bom:5.8.2')) | ||
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter' | ||
testImplementation group: 'com.google.guava', name: 'guava', version: '31.1-jre' | ||
testImplementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-benchmark-runtime', version: '0.4.4' | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.utbot.jcdb.api | ||
|
||
interface Hook { | ||
|
||
fun afterStart() | ||
|
||
fun afterStop() {} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
64 changes: 64 additions & 0 deletions
64
core/src/main/kotlin/org/utbot/jcdb/impl/fs/ByteCodeConverter.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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.utbot.jcdb.impl.fs | ||
|
||
import kotlinx.collections.immutable.toImmutableList | ||
import org.objectweb.asm.Type | ||
import org.objectweb.asm.tree.AnnotationNode | ||
import org.objectweb.asm.tree.ClassNode | ||
import org.objectweb.asm.tree.FieldNode | ||
import org.objectweb.asm.tree.MethodNode | ||
import org.utbot.jcdb.impl.types.* | ||
|
||
interface ByteCodeConverter { | ||
|
||
fun ClassNode.asClassInfo() = ClassInfo( | ||
name = Type.getObjectType(name).className, | ||
signature = signature, | ||
access = access, | ||
|
||
outerClass = outerClassName(), | ||
innerClasses = innerClasses.map { | ||
Type.getObjectType(it.name).className | ||
}.toImmutableList(), | ||
outerMethod = outerMethod, | ||
outerMethodDesc = outerMethodDesc, | ||
superClass = superName?.let { Type.getObjectType(it).className }, | ||
interfaces = interfaces.map { Type.getObjectType(it).className }.toImmutableList(), | ||
methods = methods.map { it.asMethodInfo() }.toImmutableList(), | ||
fields = fields.map { it.asFieldInfo() }.toImmutableList(), | ||
annotations = visibleAnnotations.orEmpty().map { it.asAnnotationInfo() }.toImmutableList() | ||
) | ||
|
||
private fun ClassNode.outerClassName(): OuterClassRef? { | ||
val innerRef = innerClasses.firstOrNull { it.name == name } | ||
|
||
val direct = outerClass?.let { Type.getObjectType(it).className } | ||
if (direct == null && innerRef != null) { | ||
return OuterClassRef(Type.getObjectType(innerRef.outerName).className, innerRef.innerName) | ||
} | ||
return direct?.let { | ||
OuterClassRef(it, innerRef?.innerName) | ||
} | ||
} | ||
|
||
private fun AnnotationNode.asAnnotationInfo() = AnnotationInfo( | ||
className = Type.getType(desc).className | ||
) | ||
|
||
private fun MethodNode.asMethodInfo() = MethodInfo( | ||
name = name, | ||
signature = signature, | ||
desc = desc, | ||
access = access, | ||
returnType = Type.getReturnType(desc).className, | ||
parameters = Type.getArgumentTypes(desc).map { it.className }.toImmutableList(), | ||
annotations = visibleAnnotations.orEmpty().map { it.asAnnotationInfo() }.toImmutableList() | ||
) | ||
|
||
private fun FieldNode.asFieldInfo() = FieldInfo( | ||
name = name, | ||
signature = signature, | ||
access = access, | ||
type = Type.getType(desc).className, | ||
annotations = visibleAnnotations.orEmpty().map { it.asAnnotationInfo() }.toImmutableList() | ||
) | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.