Commit 1ff2dac0 authored by Lubomir Bulej's avatar Lubomir Bulej

ThreadLocalVar: change set/getDefaultValue() to set/getInitialValue() which...

ThreadLocalVar: change set/getDefaultValue() to set/getInitialValue() which makes it more clear that it concerns initialization.
ThreadLocalVar: removed method getTypeAsDesc()
AbstractLocalVar: added method getDescriptor() to replace the one removed from ThreadLocalVar. 
DiSL, AbstractParser: updated to reflect the changes in ThreadLocalVar. 
TLVInserter: cleaned up and simplified to use code already present in AsmHelper instead of duplicating it.
parent 6049d766
......@@ -7,7 +7,7 @@
<classpathentry kind="src" output="output/build/shvm-dispatch" path="src-shvm-dispatch"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="output/lib/disl-bypass.jar"/>
<classpathentry kind="lib" path="lib/asm-debug-all-5.0.3.jar"/>
<classpathentry kind="lib" path="lib/asm-debug-all-5.0.3.jar" sourcepath="/home/pallas/svn/DiiiiSL/disl-trunk/lib/asm-5.0.3-src.zip"/>
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="lib/junit-4.11.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
......
......@@ -427,7 +427,7 @@ public final class DiSL {
null, "bypass", Type.getType (boolean.class), false
);
tlv.setDefaultValue (false);
tlv.setInitialValue (false);
insertTLVs.add (tlv);
}
......
This diff is collapsed.
......@@ -345,15 +345,15 @@ abstract class AbstractParser {
// break;
case Opcodes.ICONST_M1:
tlv.setDefaultValue(-1);
tlv.setInitialValue(-1);
break;
case Opcodes.ICONST_0:
if (fieldInsn.desc.equals("Z")) {
tlv.setDefaultValue(false);
tlv.setInitialValue(false);
} else {
tlv.setDefaultValue(0);
tlv.setInitialValue(0);
}
break;
......@@ -361,64 +361,64 @@ abstract class AbstractParser {
case Opcodes.ICONST_1:
if (fieldInsn.desc.equals("Z")) {
tlv.setDefaultValue(true);
tlv.setInitialValue(true);
} else {
tlv.setDefaultValue(1);
tlv.setInitialValue(1);
}
break;
case Opcodes.ICONST_2:
tlv.setDefaultValue(2);
tlv.setInitialValue(2);
break;
case Opcodes.ICONST_3:
tlv.setDefaultValue(3);
tlv.setInitialValue(3);
break;
case Opcodes.ICONST_4:
tlv.setDefaultValue(4);
tlv.setInitialValue(4);
break;
case Opcodes.ICONST_5:
tlv.setDefaultValue(5);
tlv.setInitialValue(5);
break;
case Opcodes.LCONST_0:
tlv.setDefaultValue(0L);
tlv.setInitialValue(0L);
break;
case Opcodes.LCONST_1:
tlv.setDefaultValue(1L);
tlv.setInitialValue(1L);
break;
case Opcodes.FCONST_0:
tlv.setDefaultValue(0.0F);
tlv.setInitialValue(0.0F);
break;
case Opcodes.FCONST_1:
tlv.setDefaultValue(1.0F);
tlv.setInitialValue(1.0F);
break;
case Opcodes.FCONST_2:
tlv.setDefaultValue(2.0F);
tlv.setInitialValue(2.0F);
break;
case Opcodes.DCONST_0:
tlv.setDefaultValue(0.0D);
tlv.setInitialValue(0.0D);
break;
case Opcodes.DCONST_1:
tlv.setDefaultValue(1.0D);
tlv.setInitialValue(1.0D);
break;
case Opcodes.BIPUSH:
case Opcodes.SIPUSH:
tlv.setDefaultValue(((IntInsnNode) source).operand);
tlv.setInitialValue(((IntInsnNode) source).operand);
break;
case Opcodes.LDC:
tlv.setDefaultValue(((LdcInsnNode) source).cst);
tlv.setInitialValue(((LdcInsnNode) source).cst);
break;
default:
......
......@@ -44,6 +44,10 @@ public abstract class AbstractLocalVar {
return type;
}
public String getDescriptor () {
return type.getDescriptor ();
}
//
/**
......
......@@ -3,31 +3,46 @@ package ch.usi.dag.disl.localvar;
import org.objectweb.asm.Type;
public class ThreadLocalVar extends AbstractLocalVar {
public final class ThreadLocalVar extends AbstractLocalVar {
private Object defaultValue;
private boolean inheritable;
private Object __initialValue;
private final boolean __inheritable;
public ThreadLocalVar(String className, String fieldName, Type type,
boolean inheritable) {
//
super(className, fieldName, type);
this.inheritable = inheritable;
public ThreadLocalVar (
final String className, final String fieldName,
final Type type, final boolean inheritable
) {
super (className, fieldName, type);
__inheritable = inheritable;
}
public String getTypeAsDesc() {
return getType().getDescriptor();
}
public Object getDefaultValue() {
return defaultValue;
/**
* @return the initial value of this thread local variable.
*/
public Object getInitialValue() {
return __initialValue;
}
public void setDefaultValue(Object defaultValue) {
this.defaultValue = defaultValue;
/**
* Sets the initial value of this thread local variable.
*
* @param value the value to initialize the variable to
*/
public void setInitialValue (final Object value) {
__initialValue = value;
}
public boolean isInheritable() {
return inheritable;
/**
* Determines whether the initial value of this variable should
* be inherited from the current {@link Thread}.
*
* @return {@code true} if the variable value is inheritable.
*/
public boolean isInheritable () {
return __inheritable;
}
}
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