Skip to content

Commit

Permalink
Package rename
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanxD committed Aug 15, 2021
1 parent 4fdc715 commit 5e2b1c1
Show file tree
Hide file tree
Showing 203 changed files with 1,955 additions and 1,625 deletions.
2 changes: 1 addition & 1 deletion Kores
Submodule Kores updated 7488 files
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ buildscript {

}

group 'com.github.koresframework'
version '4.1.10.bytecode.4'
group 'com.koresframework'
version '4.2.1.bytecode'

apply from: project(":Kores").file("gradle/common.gradle")

Expand Down Expand Up @@ -59,7 +59,7 @@ dependencies {
// with runtime dependency pointing to Kores published version
//compile project(":Kores")
compileOnly project(":Kores")
runtimeOnly "com.github.koresframework:kores:4.1.9.base"
runtimeOnly "com.koresframework:kores:4.2.1.base"
implementation 'com.github.jonathanxd:bytecode-disassembler:2.4.1'
implementation "org.ow2.asm:asm:9.2"
implementation "org.ow2.asm:asm-analysis:9.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.github.jonathanxd.kores.bytecode
package com.koresframework.kores.bytecode

import com.github.jonathanxd.bytecodedisassembler.Disassembler
import com.github.jonathanxd.kores.base.ModuleDeclaration
import com.github.jonathanxd.kores.base.Named
import com.github.jonathanxd.kores.base.TypeDeclaration
import com.koresframework.kores.base.ModuleDeclaration
import com.koresframework.kores.base.Named
import com.koresframework.kores.base.TypeDeclaration

/**
* @property declaration Declaration that produced [bytecode]. Common types are [TypeDeclaration] and [ModuleDeclaration].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.github.jonathanxd.kores.bytecode
package com.koresframework.kores.bytecode

import com.github.jonathanxd.bytecodedisassembler.Disassembler
import com.github.jonathanxd.kores.base.ModuleDeclaration
import com.koresframework.kores.base.ModuleDeclaration

class BytecodeModule constructor(val module: ModuleDeclaration, private val bytecode_: ByteArray) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
*/
@file:JvmName("BytecodeOptions")

package com.github.jonathanxd.kores.bytecode
package com.koresframework.kores.bytecode

import com.github.jonathanxd.kores.base.Line
import com.github.jonathanxd.kores.bytecode.post.DeadCodeRemover
import com.github.jonathanxd.kores.bytecode.post.GotoOptimizer
import com.github.jonathanxd.kores.bytecode.post.MethodProcessor
import com.github.jonathanxd.kores.bytecode.pre.GenLineVisitor
import com.koresframework.kores.base.Line
import com.koresframework.kores.bytecode.post.DeadCodeRemover
import com.koresframework.kores.bytecode.post.GotoOptimizer
import com.koresframework.kores.bytecode.post.MethodProcessor
import com.koresframework.kores.bytecode.pre.GenLineVisitor
import com.github.jonathanxd.iutils.option.Option
import com.github.jonathanxd.iutils.option.Options
import com.github.jonathanxd.kores.bytecode.doc.NestLogic
import com.github.jonathanxd.kores.bytecode.doc.IndyConcatLogic
import com.koresframework.kores.bytecode.doc.NestLogic
import com.koresframework.kores.bytecode.doc.IndyConcatLogic

/**
* Calls [org.objectweb.asm.util.CheckClassAdapter] to check generated class.
Expand Down Expand Up @@ -97,14 +97,14 @@ val VALIDATE_SUPER = Option(true)
* The generation of bridge methods will slow down the Generator, if you mind the performance
* don't change this option.
*
* The generation of bridge methods is very limited, the [Bridge Generator][com.github.jonathanxd.kores.bytecode.util.BridgeUtil]
* The generation of bridge methods is very limited, the [Bridge Generator][com.koresframework.kores.bytecode.util.BridgeUtil]
* will inspect super-classes (and super-interfaces) and find the overridden method.
* The [Bridge Generator][com.github.jonathanxd.kores.bytecode.util.BridgeUtil] will only inspect
* [Java type][Class] and [Kores Type][com.github.jonathanxd.kores.base.TypeDeclaration].
* If the super-class and/or super-interfaces is of another type, [Bridge Generator][com.github.jonathanxd.kores.bytecode.util.BridgeUtil]
* The [Bridge Generator][com.koresframework.kores.bytecode.util.BridgeUtil] will only inspect
* [Java type][Class] and [Kores Type][com.koresframework.kores.base.TypeDeclaration].
* If the super-class and/or super-interfaces is of another type, [Bridge Generator][com.koresframework.kores.bytecode.util.BridgeUtil]
* will ignore and the bridge method will not be generated.
*
* You could also bridge methods manually with [com.github.jonathanxd.kores.factory.bridgeMethod].
* You could also bridge methods manually with [com.koresframework.kores.factory.bridgeMethod].
*/
@JvmField
val GENERATE_BRIDGE_METHODS = Option(false)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
* Kores-BytecodeWriter - Translates Kores Structure to JVM Bytecode <https://github.com/JonathanxD/CodeAPI-BytecodeWriter>
*
* The MIT License (MIT)
*
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]>
* Copyright (c) contributors
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.koresframework.kores.bytecode.classloader

import com.koresframework.kores.base.TypeDeclaration
import com.koresframework.kores.bytecode.BytecodeClass
import com.koresframework.kores.type.`is`
import java.lang.reflect.Type

open class BytecodeCodeClassLoader : ClassLoader {

constructor() : super()
constructor(parent: ClassLoader) : super(parent)

/**
* Define type declaration class.
*
* @param typeDeclaration Type declaration.
* @param bytes Bytes.
* @return Defined Class.
*/
open fun define(typeDeclaration: TypeDeclaration, bytes: ByteArray): Class<*> {
return super.defineClass(typeDeclaration.type, bytes, 0, bytes.size)
}

/**
* Define [BytecodeClass] class.
*
* @param bytecodeClass Bytecode class.
* @return Defined Class.
*/
open fun define(bytecodeClass: BytecodeClass): Class<*> {
val type = (bytecodeClass.declaration as? TypeDeclaration)
?: throw IllegalArgumentException("Non-TypeDeclaration loading is not supported yet. BytecodeClass: $bytecodeClass")

return this.define(type, bytecodeClass.bytecode)
}

/**
* Define [classes][BytecodeClass] and inner classes.
*
* Make sure that all elements in the `bytecodeClasses` is a inner type of first element.
*
* @param bytecodeClasses Bytecode class (first element) and inner classes (remaining).
* @return First Defined Class.
*/
open fun define(bytecodeClasses: Array<out BytecodeClass>): Class<*> {
return this.define(bytecodeClasses.iterator())
}

/**
* Define [classes][BytecodeClass] and inner classes.
*
* Make sure that all elements in the `bytecodeClasses` is a inner type of first element.
*
* @param bytecodeClasses Bytecode class (first element) and inner classes (remaining).
* @return First Defined Class.
*/
open fun define(bytecodeClasses: Collection<BytecodeClass>): Class<*> {
return this.define(bytecodeClasses.iterator())
}

/**
* Define [classes][BytecodeClass] and inner classes.
*
* Make sure that all elements in the `bytecodeClasses` is a inner type of first element.
*
* @param bytecodeClasses Bytecode class (first element) and inner classes (remaining).
* @return First Defined Class.
*/
open fun define(bytecodeClasses: Iterator<BytecodeClass>): Class<*> {
if (!bytecodeClasses.hasNext()) {
throw IllegalArgumentException("Empty 'bytecodeClasses' array")
}

val bytecodeClass = bytecodeClasses.next()

val type = (bytecodeClass.declaration as? TypeDeclaration)
?: throw IllegalArgumentException("Non-TypeDeclaration loading is not supported yet. BytecodeClass: $bytecodeClass")

val define = this.define(type, bytecodeClass.bytecode)

bytecodeClasses.forEach {
this.define(it)
}

return define
}

/**
* Defines very [class][BytecodeClass] in [bytecodeClasses] iterator. All defined
* classes are added to provided [collection].
*
* This function may be used to define inner classes as well as multiple individual classes.
*
* @param bytecodeClasses Bytecode class (first element) and inner classes (remaining).
* @return First Defined Class.
*/
open fun <C: MutableCollection<in LoadedBytecodeClass>> defineEveryTo(
collection: C,
bytecodeClasses: Iterator<BytecodeClass>
): C {
if (!bytecodeClasses.hasNext()) {
throw IllegalArgumentException("Empty 'bytecodeClasses' array")
}

val known = mutableListOf<LoadedBytecodeClass>()

while (bytecodeClasses.hasNext()) {
val bytecodeClass = bytecodeClasses.next()

val type = (bytecodeClass.declaration as? TypeDeclaration)
?: throw IllegalArgumentException("Non-TypeDeclaration loading is not supported yet. BytecodeClass: $bytecodeClass")

val define = this.define(type, bytecodeClass.bytecode)
val outerType = bytecodeClass.declaration.outerType
val outerLazy by lazy {
known.firstOrNull { outerType != null && (it.bytecodeClass.declaration as Type).`is`(outerType) }
}

val loaded = LoadedBytecodeClass(
bytecodeClass,
outerType = { outerLazy },
loadedClass = define
)

collection.add(loaded)
known.add(loaded)
}

return collection
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Kores-BytecodeWriter - Translates Kores Structure to JVM Bytecode <https://github.com/JonathanxD/CodeAPI-BytecodeWriter>
*
* The MIT License (MIT)
*
* Copyright (c) 2021 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) <[email protected]>
* Copyright (c) contributors
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.koresframework.kores.bytecode.classloader

import com.koresframework.kores.base.TypeDeclaration
import java.util.*

/**
* Cache all defined classes.
*/
class CachedBytecodeCodeClassLoader : BytecodeCodeClassLoader {

constructor() : super()
constructor(parent: ClassLoader) : super(parent)

private val cache = mutableMapOf<TypeDeclaration, Class<*>>()
private val immutableCache = Collections.unmodifiableMap(cache)

override fun define(typeDeclaration: TypeDeclaration, bytes: ByteArray): Class<*> {
val define = super.define(typeDeclaration, bytes)

this.cache[typeDeclaration] = define

return define
}

fun getCache(): Map<TypeDeclaration, Class<*>> {
return this.immutableCache
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.github.jonathanxd.kores.bytecode.classloader
package com.koresframework.kores.bytecode.classloader

import com.github.jonathanxd.kores.base.TypeDeclaration
import com.koresframework.kores.base.TypeDeclaration
import java.util.*

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.github.jonathanxd.kores.bytecode.classloader
package com.koresframework.kores.bytecode.classloader

import com.github.jonathanxd.kores.base.TypeDeclaration
import com.github.jonathanxd.kores.bytecode.BytecodeClass
import com.koresframework.kores.base.TypeDeclaration
import com.koresframework.kores.bytecode.BytecodeClass

/**
* Class injection utility.
Expand All @@ -44,7 +44,7 @@ object ClassInject {
* @return Defined class
* @throws IllegalStateException if the injection fails.
*/
fun ClassLoader.inject(bytecodeClass: com.github.jonathanxd.kores.bytecode.BytecodeClass): Class<*> {
fun ClassLoader.inject(bytecodeClass: com.koresframework.kores.bytecode.BytecodeClass): Class<*> {
val type = (bytecodeClass.declaration as? TypeDeclaration)?.type
?: throw IllegalArgumentException("Non-TypeDeclaration loading is not supported yet. BytecodeClass: $bytecodeClass")

Expand All @@ -58,7 +58,7 @@ object ClassInject {
* @return Defined class.
* @throws IllegalStateException if the injection fails or [bytecode classes array][bytecodeClasses] is empty.
*/
fun ClassLoader.inject(bytecodeClasses: Array<out com.github.jonathanxd.kores.bytecode.BytecodeClass>): Class<*> {
fun ClassLoader.inject(bytecodeClasses: Array<out com.koresframework.kores.bytecode.BytecodeClass>): Class<*> {
if (bytecodeClasses.isEmpty()) {
throw IllegalArgumentException("Empty 'bytecodeClasses' array")
}
Expand Down
Loading

0 comments on commit 5e2b1c1

Please sign in to comment.