Skip to content

Commit 5cf8899

Browse files
committed
Improved Dup
1 parent 449de40 commit 5cf8899

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ buildscript {
1818
}
1919

2020
group 'com.github.jonathanxd'
21-
version '3.1.1-3.1.3'
21+
version '3.1.1-3.1.4'
2222

2323
apply from: project(":CodeAPI").file("gradle/common.gradle")
2424

src/main/kotlin/com/github/jonathanxd/codeapi/bytecode/extra/Dup.kt

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,45 @@
2727
*/
2828
package com.github.jonathanxd.codeapi.bytecode.extra
2929

30+
import com.github.jonathanxd.codeapi.CodePart
3031
import com.github.jonathanxd.codeapi.base.Typed
32+
import com.github.jonathanxd.codeapi.type.CodeType
3133

3234
/**
3335
* CodeAPI-BytecodeWriter Dup part. This part will dup result of [part].
3436
*/
35-
data class Dup(val part: Typed) : Typed by part
37+
data class Dup(val part: CodePart, override val type: CodeType) : Typed {
38+
39+
constructor(part: Typed) : this(part, part.type)
40+
41+
override fun builder(): Builder = Builder(this)
42+
43+
class Builder() : Typed.Builder<Dup, Builder> {
44+
45+
lateinit var part: CodePart
46+
lateinit var type: CodeType
47+
48+
constructor(defaults: Dup) : this() {
49+
this.part = defaults.part
50+
this.type = defaults.type
51+
}
52+
53+
fun withPart(value: CodePart): Builder {
54+
this.part = value
55+
return this
56+
}
57+
58+
override fun withType(value: CodeType): Builder {
59+
this.type = value
60+
return this
61+
}
62+
63+
override fun build(): Dup = Dup(this.part, this.type)
64+
65+
companion object {
66+
@JvmStatic
67+
fun builder() = Builder()
68+
}
69+
}
70+
71+
}

0 commit comments

Comments
 (0)