-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wip): forge transformer implementation
- Loading branch information
Showing
15 changed files
with
370 additions
and
205 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
24 changes: 24 additions & 0 deletions
24
modules/common/src/main/kotlin/org/polyfrost/spice/util/SpiceClassWriter.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,24 @@ | ||
package org.polyfrost.spice.util | ||
|
||
import org.objectweb.asm.ClassReader | ||
import org.objectweb.asm.ClassWriter | ||
|
||
class SpiceClassWriter : ClassWriter { | ||
@Suppress("unused") | ||
constructor(flags: Int) : super(flags) | ||
|
||
@Suppress("unused") | ||
constructor(reader: ClassReader, flags: Int) | ||
: super(reader, flags) | ||
|
||
override fun getCommonSuperClass(a: String, b: String): String? { | ||
val chainA = classChain(readClass(a) ?: return "java/lang/Object") | ||
val chainB = classChain(readClass(b) ?: return "java/lang/Object") | ||
|
||
val commonSuperClasses = mutableSetOf<String>() | ||
|
||
chainA.forEach { if (chainB.contains(it)) commonSuperClasses += it } | ||
|
||
return commonSuperClasses.firstOrNull() | ||
} | ||
} |
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
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
Oops, something went wrong.