mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-13 17:04:25 +00:00
Fixed bug in ASMMixinCompiler and StackAnalyser with wide types.
This commit is contained in:
1 parent
008a75c8fc
commit
bc7c679f0e
2 files changed
+14
-7
No files matched your search
@@ -24,7 +24,7 @@ import codechicken.multipart.handler.MultipartProxy
|
||||
|
||||
object DebugPrinter
|
||||
{
|
||||
def debug = MultipartProxy.config.getTag("debug_asm").getBooleanValue(!ObfMapping.obfuscated)
|
||||
val debug = MultipartProxy.config.getTag("debug_asm").getBooleanValue(!ObfMapping.obfuscated)
|
||||
|
||||
private var permGenUsed = 0
|
||||
val dir = new File("asm/multipart")
|
||||
@@ -60,6 +60,8 @@ object DebugPrinter
|
||||
|
||||
object ASMMixinCompiler
|
||||
{
|
||||
import StackAnalyser.width
|
||||
|
||||
val cl = getClass.getClassLoader.asInstanceOf[LaunchClassLoader]
|
||||
val m_defineClass = classOf[ClassLoader].getDeclaredMethod("defineClass", classOf[Array[Byte]], Integer.TYPE, Integer.TYPE)
|
||||
val m_runTransformers = classOf[LaunchClassLoader].getDeclaredMethod("runTransformers", classOf[String], classOf[String], classOf[Array[Byte]])
|
||||
@@ -246,7 +248,7 @@ object ASMMixinCompiler
|
||||
mv.visitVarInsn(args(i).getOpcode(ILOAD), i+1)
|
||||
mv.visitMethodInsn(opcode, owner, name, desc)
|
||||
mv.visitInsn(getReturnType(mvdesc).getOpcode(IRETURN))
|
||||
mv.visitMaxs(args.length+1, args.length+1)
|
||||
mv.visitMaxs(width(args)+1, width(args)+1)
|
||||
}
|
||||
|
||||
def writeBridge(mv:MethodVisitor, mvdesc:String, opcode:Int, owner:String, name:String, desc:String)
|
||||
@@ -278,18 +280,19 @@ object ASMMixinCompiler
|
||||
t.fields.foreach{ f =>
|
||||
val fv = cnode.visitField(ACC_PRIVATE, f.accessName(t.name), f.desc, null, null).asInstanceOf[FieldNode]
|
||||
|
||||
val ftype = getType(fv.desc)
|
||||
var mv = cnode.visitMethod(ACC_PUBLIC, fv.name, "()"+f.desc, null, null)
|
||||
mv.visitVarInsn(ALOAD, 0)
|
||||
mv.visitFieldInsn(GETFIELD, name, fv.name, fv.desc)
|
||||
mv.visitInsn(getType(fv.desc).getOpcode(IRETURN))
|
||||
mv.visitInsn(ftype.getOpcode(IRETURN))
|
||||
mv.visitMaxs(1, 1)
|
||||
|
||||
mv = cnode.visitMethod(ACC_PUBLIC, fv.name+"_$eq", "("+f.desc+")V", null, null)
|
||||
mv.visitVarInsn(ALOAD, 0)
|
||||
mv.visitVarInsn(getType(fv.desc).getOpcode(ILOAD), 1)
|
||||
mv.visitVarInsn(ftype.getOpcode(ILOAD), 1)
|
||||
mv.visitFieldInsn(PUTFIELD, name, fv.name, fv.desc)
|
||||
mv.visitInsn(RETURN)
|
||||
mv.visitMaxs(2, 2)
|
||||
mv.visitMaxs(width(ftype)+1, width(ftype)+1)
|
||||
}
|
||||
|
||||
t.supers.foreach{ s =>
|
||||
@@ -560,7 +563,7 @@ object ASMMixinCompiler
|
||||
val csym:ClassSymbol = sig.evalT(0)
|
||||
for(i <- 0 until sig.table.length)
|
||||
{
|
||||
import ScalaSignature._
|
||||
import ScalaSignature._
|
||||
|
||||
val e = sig.table(i)
|
||||
if(e.id == 8)//method
|
||||
|
||||
@@ -9,6 +9,10 @@ import scala.collection.JavaConversions._
|
||||
|
||||
object StackAnalyser
|
||||
{
|
||||
def width(t:Type):Int = t.getSize
|
||||
def width(s:String):Int = width(Type.getType(s))
|
||||
def width(it:Iterable[Type]):Int = it.foldLeft(0)(_+width(_))
|
||||
|
||||
trait StackEntry
|
||||
{
|
||||
def getType:Type
|
||||
@@ -129,7 +133,7 @@ class StackAnalyser(val owner:Type, val m:MethodNode)
|
||||
if(e.getType.getSize == 2)
|
||||
{
|
||||
if(peek(i) != e) throw new IllegalStateException("Wide stack entry elems don't match ("+e+","+peek(i))
|
||||
stack.remove(i)
|
||||
stack.remove(stack.size-i-1)
|
||||
}
|
||||
e
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user