Skip to content

Commit

Permalink
modify LiteralArray.toString.
Browse files Browse the repository at this point in the history
  • Loading branch information
magiclf committed Aug 28, 2024
1 parent cb87330 commit d8021e6
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,26 @@ class LiteralArray(

override fun toString():String{
val sb = StringBuilder()
sb.append("{ $size [ ")
sb.append("[")

var idx = 0
content.forEach {

if(idx != 0) {
sb.append(", ")
}

if(it is Literal.Str){
sb.append("str:\"${it.get(abc)}\", ")
sb.append("\"${it.get(abc)}\"")
} else if(it is Literal.LiteralMethod) {
val method = abc.method(it.offset)
sb.append("${it::class.simpleName}:${method.clazz.name}.${method.name}, ")
sb.append("\"${method.clazz.name}.${method.name}\"")
}else {
sb.append("${it}, ")
sb.append("${it}")
}
idx += 1
}
sb.append(" ]}")
sb.append("]")
return sb.toString()
}
// val size
Expand Down Expand Up @@ -100,20 +108,20 @@ class LiteralArray(

sealed class LiteralDirect<T>(val value: T) : Literal(){
override fun toString(): String {
return "${this::class.simpleName}:$value"
return "$value"
}
}
sealed class LiteralRef(val offset: Int) : Literal(){
override fun toString(): String {
return "${this::class.simpleName}:${offset.toString(16)}"
return "${offset.toString(16)}"
}
}
sealed class LiteralMethod(offset: Int) :LiteralRef(offset){
fun get(abc: AbcBuf) : MethodItem = abc.method(offset)
}
sealed class ArrRef(offset: Int) : LiteralRef(offset){
override fun toString(): String {
return "${this::class.simpleName}:${offset.toString(16)}"
return "${offset.toString(16)}"
}
}

Expand Down

0 comments on commit d8021e6

Please sign in to comment.