Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DiSL
DiSL
Commits
6081a78c
Commit
6081a78c
authored
May 20, 2014
by
Lubomir Bulej
Browse files
ExtendThread: cleaned up whitespace before subsequent merges.
parent
db6c0fda
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ch/usi/dag/disl/utilinstr/tlvinserter/ExtendThread.java
View file @
6081a78c
...
@@ -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
();
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment