Commit 6081a78c authored by Lubomir Bulej's avatar Lubomir Bulej
Browse files

ExtendThread: cleaned up whitespace before subsequent merges.

parent db6c0fda
...@@ -14,49 +14,49 @@ import ch.usi.dag.disl.localvar.ThreadLocalVar; ...@@ -14,49 +14,49 @@ import ch.usi.dag.disl.localvar.ThreadLocalVar;
import ch.usi.dag.disl.util.Constants; import ch.usi.dag.disl.util.Constants;
/** /**
* This is just a utility class for disl compilation * This is just a utility class for disl compilation
*/ */
public final class ExtendThread { public final class ExtendThread {
private static final String THREAD_BIN_DIR = "./bin-thread/"; private static final String THREAD_BIN_DIR = "./bin-thread/";
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Class<?> tc = Thread.class; Class<?> tc = Thread.class;
// get thread class as resource // get thread class as resource
InputStream tis = tc.getResourceAsStream("Thread.class"); InputStream tis = tc.getResourceAsStream("Thread.class");
// prepare dynamic bypass variable // prepare dynamic bypass variable
ThreadLocalVar tlv = new ThreadLocalVar(null, "bypass", ThreadLocalVar tlv = new ThreadLocalVar(null, "bypass",
Type.getType(boolean.class), false); Type.getType(boolean.class), false);
tlv.setDefaultValue(0); tlv.setDefaultValue(0);
// prepare Set with dynamic bypass // prepare Set with dynamic bypass
Set<ThreadLocalVar> tlvs = new HashSet<ThreadLocalVar>(); Set<ThreadLocalVar> tlvs = new HashSet<ThreadLocalVar>();
tlvs.add(tlv); tlvs.add(tlv);
// parse Thread in ASM // parse Thread in ASM
ClassReader cr = new ClassReader(tis); ClassReader cr = new ClassReader(tis);
ClassWriter cw = new ClassWriter(cr, 0); ClassWriter cw = new ClassWriter(cr, 0);
// put dynamic bypass into Thread using TLVInserter // put dynamic bypass into Thread using TLVInserter
cr.accept(new TLVInserter(cw, tlvs), 0); cr.accept(new TLVInserter(cw, tlvs), 0);
// prepare Thread file name // prepare Thread file name
String threadFileName = tc.getName(); String threadFileName = tc.getName();
threadFileName = threadFileName.replace( threadFileName = threadFileName.replace(
Constants.PACKAGE_STD_DELIM, Constants.PACKAGE_INTERN_DELIM); Constants.PACKAGE_STD_DELIM, Constants.PACKAGE_INTERN_DELIM);
threadFileName += Constants.CLASS_EXT; threadFileName += Constants.CLASS_EXT;
// output Thread code into special thread bin directory // output Thread code into special thread bin directory
write(THREAD_BIN_DIR + threadFileName, cw.toByteArray()); write(THREAD_BIN_DIR + threadFileName, cw.toByteArray());
} }
private static void write(String outputFile, byte[] data) throws IOException { private static void write(String outputFile, byte[] data) throws IOException {
FileOutputStream fos = new FileOutputStream(outputFile); FileOutputStream fos = new FileOutputStream(outputFile);
fos.write(data); fos.write(data);
fos.close(); fos.close();
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment