Created
June 26, 2013 12:13
-
-
Save sorear/5866922 to your computer and use it in GitHub Desktop.
autosplit testing patch
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
diff --git a/src/vm/jvm/runtime/org/perl6/nqp/jast2bc/JASTToJVMBytecode.java b/src/vm/jvm/runtime/org/perl6/nqp/jast2bc/JASTToJVMBytecode.java | |
index 2fc2e88..d773edf 100644 | |
--- a/src/vm/jvm/runtime/org/perl6/nqp/jast2bc/JASTToJVMBytecode.java | |
+++ b/src/vm/jvm/runtime/org/perl6/nqp/jast2bc/JASTToJVMBytecode.java | |
@@ -40,7 +40,7 @@ public class JASTToJVMBytecode { | |
{ | |
BufferedReader in = new BufferedReader(new InputStreamReader( | |
new FileInputStream(argv[0]), "UTF-8")); | |
- JavaClass c = buildClassFrom(in); | |
+ JavaClass c = buildClassFrom(in, true); | |
in.close(); | |
FileOutputStream fos = new FileOutputStream(argv[1]); | |
fos.write(c.bytes); | |
@@ -48,6 +48,7 @@ public class JASTToJVMBytecode { | |
} | |
catch (Exception e) | |
{ | |
+ e.printStackTrace(); | |
System.err.println("Error: " + e.getMessage()); | |
} | |
@@ -56,7 +57,7 @@ public class JASTToJVMBytecode { | |
public static JavaClass buildClassFromString(String in) { | |
try { | |
BufferedReader br = new BufferedReader(new StringReader(in)); | |
- JavaClass c = buildClassFrom(br); | |
+ JavaClass c = buildClassFrom(br, false); | |
return c; | |
} | |
catch (Exception e) { | |
@@ -67,7 +68,7 @@ public class JASTToJVMBytecode { | |
public static void writeClassFromString(String in, String filename) { | |
try { | |
BufferedReader br = new BufferedReader(new StringReader(in)); | |
- JavaClass c = buildClassFrom(br); | |
+ JavaClass c = buildClassFrom(br, false); | |
FileOutputStream fos = new FileOutputStream(filename); | |
if (c.serialized == null) { | |
@@ -98,7 +99,7 @@ public class JASTToJVMBytecode { | |
} | |
} | |
- private static JavaClass buildClassFrom(BufferedReader in) throws Exception | |
+ private static JavaClass buildClassFrom(BufferedReader in, boolean split) throws Exception | |
{ | |
JavaClass c = new JavaClass(); | |
// Read in class name, superclass and any fields. | |
@@ -157,7 +158,7 @@ public class JASTToJVMBytecode { | |
// Process all of the methods. | |
if (!curLine.equals("+ method")) | |
throw new Exception("Expected method after class configuration"); | |
- while (processMethod(c, in, cw, className)) | |
+ while (processMethod(c, in, cw, className, split)) | |
; | |
// Add empty constructor. | |
@@ -181,7 +182,7 @@ public class JASTToJVMBytecode { | |
public boolean defined; | |
} | |
- private static boolean processMethod(JavaClass jcout, BufferedReader in, ClassWriter c, String className) throws Exception { | |
+ private static boolean processMethod(JavaClass jcout, BufferedReader in, ClassWriter c, String className, boolean split) throws Exception { | |
String curLine, methodName = null, returnType = null, desc = null; | |
String crName = null, crCuid = null, crOuter = null; | |
int crOuterIx = -2; // not coderef | |
@@ -278,11 +279,9 @@ public class JASTToJVMBytecode { | |
// Create method object. | |
desc = Type.getMethodDescriptor(processType(returnType), argTypes.toArray(new Type[0])); | |
- m = c.visitMethod( | |
- (isStatic | |
- ? Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC | |
- : Opcodes.ACC_PUBLIC), | |
- methodName, desc, null, null); | |
+ int modifiers = isStatic ? Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC : Opcodes.ACC_PUBLIC; | |
+ m = split ? new AutosplitMethodWriter(c, className, modifiers, methodName, desc, null, null) : | |
+ c.visitMethod(modifiers, methodName, desc, null, null); | |
// Add code ref info annotation. | |
if ((crCuid != null && !crCuid.equals("")) || crOuterIx >= -1) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment