instruction index in SSAInstruction for javascript

This commit is contained in:
Juergen Graf 2011-04-13 12:56:36 +02:00
parent 7c518d1867
commit ee3c56b9e9
14 changed files with 229 additions and 223 deletions

3
.gitignore vendored
View File

@ -10,3 +10,6 @@ com.ibm.wala.cast.java.polyglot/lib/polyglot.jar
com.ibm.wala.cast.java.test.data/src/JLex/
com.ibm.wala.cast.js.rhino/lib/
com.ibm.wala.cast.js/lib/
com.ibm.wala.cast.js.rhino.test/2009_swine_flu_outbreak
com.ibm.wala.cast.js.rhino.test/*.html
com.ibm.wala.cast.js.test/examples-src/ajaxslt/

View File

@ -53,7 +53,7 @@ public class JSCallGraph extends AstCallGraph {
if (cha.isSubclassOf(cha.lookupClass(T), cha.lookupClass(JavaScriptTypes.Root))) {
int instance = nextLocal++;
NewSiteReference ref = NewSiteReference.make(statements.size(), T);
SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(instance, ref);
SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(statements.size(), instance, ref);
statements.add(result);
return result;
} else {

View File

@ -83,19 +83,19 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addStatement(insts.GetInstruction(4, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.PutInstruction(5, 4, "prototype"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 4, "prototype"));
S.getNextProgramCounter();
S.addConstant(new Integer(8), new ConstantValue(value));
S.addStatement(insts.PutInstruction(5, 8, "$value"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 8, "$value"));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls);
@ -106,18 +106,18 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(5, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 5, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(6, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 6, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.PutInstruction(6, 5, "prototype"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 5, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(6, 2, "$value"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 2, "$value"));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(6, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 6, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls);
@ -143,15 +143,15 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Object);
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addStatement(insts.GetInstruction(4, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
S.addStatement(insts.PutInstruction(5, 4, "prototype"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 4, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls);
@ -162,7 +162,7 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Object);
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.ReturnInstruction(2, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls);
@ -200,18 +200,18 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Array);
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(5, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 5, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(6, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Array)));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 6, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Array)));
S.addStatement(insts.PutInstruction(6, 5, "prototype"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 5, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(6, 2, "length"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 2, "length"));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(6, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 6, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls);
@ -223,28 +223,28 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
JavaScriptSummary S = new JavaScriptSummary(ref, nargs + 1);
S.addConstant(new Integer(nargs + 3), new ConstantValue("prototype"));
S.addStatement(insts.PropertyRead(nargs + 4, 1, nargs + 3));
S.addStatement(insts.PropertyRead(S.getNumberOfStatements(), nargs + 4, 1, nargs + 3));
S.getNextProgramCounter();
S.addStatement(
insts.NewInstruction(nargs + 5, NewSiteReference.make(S.getNextProgramCounter(),
insts.NewInstruction(S.getNumberOfStatements(), nargs + 5, NewSiteReference.make(S.getNextProgramCounter(),
JavaScriptTypes.Array)));
S.addStatement(insts.PutInstruction(nargs + 5, nargs + 4, "prototype"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), nargs + 5, nargs + 4, "prototype"));
S.getNextProgramCounter();
S.addConstant(new Integer(nargs + 7), new ConstantValue(nargs));
S.addStatement(insts.PutInstruction(nargs + 5, nargs + 7, "length"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), nargs + 5, nargs + 7, "length"));
S.getNextProgramCounter();
int vn = nargs + 9;
for (int i = 0; i < nargs; i++, vn += 2) {
S.addConstant(new Integer(vn), new ConstantValue(i));
S.addStatement(insts.PropertyWrite(nargs + 5, vn, i + 1));
S.addStatement(insts.PropertyWrite(S.getNumberOfStatements(), nargs + 5, vn, i + 1));
S.getNextProgramCounter();
}
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls);
@ -265,7 +265,7 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addConstant(new Integer(2), new ConstantValue(""));
S.addStatement(insts.ReturnInstruction(2, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls);
@ -276,13 +276,13 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = AstMethodReference.fnReference(JavaScriptTypes.String);
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(4, 2, "toString"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 2, "toString"));
S.getNextProgramCounter();
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
S.addStatement(insts.Invoke(4, 5, new int[] { 2 }, 6, cs));
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls);
@ -305,7 +305,7 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addConstant(new Integer(2), new ConstantValue(0.0));
S.addStatement(insts.ReturnInstruction(2, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls);
@ -316,13 +316,13 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = AstMethodReference.fnReference(JavaScriptTypes.Number);
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(4, 2, "toNumber"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 2, "toNumber"));
S.getNextProgramCounter();
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
S.addStatement(insts.Invoke(4, 5, new int[] { 2 }, 6, cs));
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 4, 5, new int[] { 2 }, 6, cs));
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls);
@ -348,23 +348,23 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(receiver.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addStatement(insts.GetInstruction(4, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.NewInstruction(7, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 7, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
S.addStatement(insts.PutInstruction(7, 4, "prototype"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 7, 4, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(5, 7, "prototype"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 7, "prototype"));
S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(7, 5, "constructor"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 7, 5, "constructor"));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter();
if (receiver != cls)
@ -458,15 +458,15 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, nargs + 1);
S.addStatement(insts.GetInstruction(nargs + 4, 1, "prototype"));
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), nargs + 4, 1, "prototype"));
S.getNextProgramCounter();
S.addStatement(
insts.NewInstruction(nargs + 5,
insts.NewInstruction(S.getNumberOfStatements(), nargs + 5,
NewSiteReference.make(S.getNextProgramCounter(),
JavaScriptTypes.Object)));
S.addStatement(insts.PutInstruction(nargs + 5, nargs + 4, "prototype"));
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), nargs + 5, nargs + 4, "prototype"));
S.getNextProgramCounter();
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
@ -476,10 +476,10 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
args[i + 1] = i + 2;
S.addStatement(insts.Invoke(1, nargs + 7, args, nargs + 8, cs));
S.addStatement(insts.ReturnInstruction(nargs + 7, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), nargs + 7, false));
S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(nargs + 5, false));
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), nargs + 5, false));
S.getNextProgramCounter();
return record(key, new JavaScriptConstructor(ref, S, cls));

View File

@ -25,7 +25,7 @@ public class JavaScriptSummary extends MethodSummary {
super(ref);
this.declaredParameters = declaredParameters;
addStatement(
JavaScriptLoader.JS.instructionFactory().NewInstruction(
JavaScriptLoader.JS.instructionFactory().NewInstruction(getNumberOfStatements(),
declaredParameters+1,
NewSiteReference.make(
getNextProgramCounter(),

View File

@ -196,48 +196,48 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
public JSInstructionFactory instructionFactory() {
return new JSInstructionFactory() {
public JavaScriptCheckReference CheckReference(int ref) {
return new JavaScriptCheckReference(ref);
public JavaScriptCheckReference CheckReference(int iindex, int ref) {
return new JavaScriptCheckReference(iindex, ref);
}
public SSAGetInstruction GetInstruction(int result, int ref, String field) {
return GetInstruction(result, ref, FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(field),
public SSAGetInstruction GetInstruction(int iindex, int result, int ref, String field) {
return GetInstruction(iindex, result, ref, FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(field),
JavaScriptTypes.Root));
}
public JavaScriptInstanceOf InstanceOf(int result, int objVal, int typeVal) {
return new JavaScriptInstanceOf(result, objVal, typeVal);
public JavaScriptInstanceOf InstanceOf(int iindex, int result, int objVal, int typeVal) {
return new JavaScriptInstanceOf(iindex, result, objVal, typeVal);
}
public JavaScriptInvoke Invoke(int function, int[] results, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(function, results, params, exception, site);
public JavaScriptInvoke Invoke(int iindex, int function, int[] results, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(iindex, function, results, params, exception, site);
}
public JavaScriptInvoke Invoke(int function, int[] results, int[] params, int exception, CallSiteReference site,
public JavaScriptInvoke Invoke(int iindex, int function, int[] results, int[] params, int exception, CallSiteReference site,
Access[] lexicalReads, Access[] lexicalWrites) {
return new JavaScriptInvoke(function, results, params, exception, site, lexicalReads, lexicalWrites);
return new JavaScriptInvoke(iindex, function, results, params, exception, site, lexicalReads, lexicalWrites);
}
public JavaScriptInvoke Invoke(int function, int result, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(function, result, params, exception, site);
public JavaScriptInvoke Invoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(iindex, function, result, params, exception, site);
}
public JavaScriptInvoke Invoke(int function, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(function, params, exception, site);
public JavaScriptInvoke Invoke(int iindex, int function, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(iindex, function, params, exception, site);
}
public JavaScriptPropertyRead PropertyRead(int result, int objectRef, int memberRef) {
return new JavaScriptPropertyRead(result, objectRef, memberRef);
public JavaScriptPropertyRead PropertyRead(int iindex, int result, int objectRef, int memberRef) {
return new JavaScriptPropertyRead(iindex, result, objectRef, memberRef);
}
public JavaScriptPropertyWrite PropertyWrite(int objectRef, int memberRef, int value) {
return new JavaScriptPropertyWrite(objectRef, memberRef, value);
public JavaScriptPropertyWrite PropertyWrite(int iindex, int objectRef, int memberRef, int value) {
return new JavaScriptPropertyWrite(iindex, objectRef, memberRef, value);
}
public SSAPutInstruction PutInstruction(int ref, int value, String field) {
public SSAPutInstruction PutInstruction(int iindex, int ref, int value, String field) {
try {
byte[] utf8 = field.getBytes("UTF-8");
return PutInstruction(ref, value, FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreate(utf8, 0, utf8.length),
return PutInstruction(iindex, ref, value, FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreate(utf8, 0, utf8.length),
JavaScriptTypes.Root));
} catch (UnsupportedEncodingException e) {
Assertions.UNREACHABLE();
@ -245,190 +245,190 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
}
}
public JavaScriptTypeOfInstruction TypeOfInstruction(int lval, int object) {
return new JavaScriptTypeOfInstruction(lval, object);
public JavaScriptTypeOfInstruction TypeOfInstruction(int iindex, int lval, int object) {
return new JavaScriptTypeOfInstruction(iindex, lval, object);
}
public JavaScriptWithRegion WithRegion(int expr, boolean isEnter) {
return new JavaScriptWithRegion(expr, isEnter);
public JavaScriptWithRegion WithRegion(int iindex, int expr, boolean isEnter) {
return new JavaScriptWithRegion(iindex, expr, isEnter);
}
public AstAssertInstruction AssertInstruction(int value, boolean fromSpecification) {
return new AstAssertInstruction(value, fromSpecification);
public AstAssertInstruction AssertInstruction(int iindex, int value, boolean fromSpecification) {
return new AstAssertInstruction(iindex, value, fromSpecification);
}
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int result, int val) {
return new AssignInstruction(result, val);
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int iindex, int result, int val) {
return new AssignInstruction(iindex, result, val);
}
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int value, int objectRef) {
return new EachElementGetInstruction(value, objectRef);
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int iindex, int value, int objectRef) {
return new EachElementGetInstruction(iindex, value, objectRef);
}
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int value, int objectRef) {
return new EachElementHasNextInstruction(value, objectRef);
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int iindex, int value, int objectRef) {
return new EachElementHasNextInstruction(iindex, value, objectRef);
}
public AstEchoInstruction EchoInstruction(int[] rvals) {
return new AstEchoInstruction(rvals);
public AstEchoInstruction EchoInstruction(int iindex, int[] rvals) {
return new AstEchoInstruction(iindex, rvals);
}
public AstGlobalRead GlobalRead(int lhs, FieldReference global) {
return new AstGlobalRead(lhs, global);
public AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global) {
return new AstGlobalRead(iindex, lhs, global);
}
public AstGlobalWrite GlobalWrite(FieldReference global, int rhs) {
return new AstGlobalWrite(global, rhs);
public AstGlobalWrite GlobalWrite(int iindex, FieldReference global, int rhs) {
return new AstGlobalWrite(iindex, global, rhs);
}
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef) {
return new AstIsDefinedInstruction(lval, rval, fieldVal, fieldRef);
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef) {
return new AstIsDefinedInstruction(iindex, lval, rval, fieldVal, fieldRef);
}
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, FieldReference fieldRef) {
return new AstIsDefinedInstruction(lval, rval, fieldRef);
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef) {
return new AstIsDefinedInstruction(iindex, lval, rval, fieldRef);
}
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal) {
return new AstIsDefinedInstruction(lval, rval, fieldVal);
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal) {
return new AstIsDefinedInstruction(iindex, lval, rval, fieldVal);
}
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval) {
return new AstIsDefinedInstruction(lval, rval);
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval) {
return new AstIsDefinedInstruction(iindex, lval, rval);
}
public AstLexicalRead LexicalRead(Access[] accesses) {
return new AstLexicalRead(accesses);
public AstLexicalRead LexicalRead(int iindex, Access[] accesses) {
return new AstLexicalRead(iindex, accesses);
}
public AstLexicalRead LexicalRead(Access access) {
return new AstLexicalRead(access);
public AstLexicalRead LexicalRead(int iindex, Access access) {
return new AstLexicalRead(iindex, access);
}
public AstLexicalRead LexicalRead(int lhs, String definer, String globalName) {
return new AstLexicalRead(lhs, definer, globalName);
public AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName) {
return new AstLexicalRead(iindex, lhs, definer, globalName);
}
public AstLexicalWrite LexicalWrite(Access[] accesses) {
return new AstLexicalWrite(accesses);
public AstLexicalWrite LexicalWrite(int iindex, Access[] accesses) {
return new AstLexicalWrite(iindex, accesses);
}
public AstLexicalWrite LexicalWrite(Access access) {
return new AstLexicalWrite(access);
public AstLexicalWrite LexicalWrite(int iindex, Access access) {
return new AstLexicalWrite(iindex, access);
}
public AstLexicalWrite LexicalWrite(String definer, String globalName, int rhs) {
return new AstLexicalWrite(definer, globalName, rhs);
public AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, int rhs) {
return new AstLexicalWrite(iindex, definer, globalName, rhs);
}
public SSAArrayLengthInstruction ArrayLengthInstruction(int result, int arrayref) {
public SSAArrayLengthInstruction ArrayLengthInstruction(int iindex, int result, int arrayref) {
throw new UnsupportedOperationException();
}
public SSAArrayLoadInstruction ArrayLoadInstruction(int result, int arrayref, int index, TypeReference declaredType) {
public SSAArrayLoadInstruction ArrayLoadInstruction(int iindex, int result, int arrayref, int index, TypeReference declaredType) {
throw new UnsupportedOperationException();
}
public SSAArrayStoreInstruction ArrayStoreInstruction(int arrayref, int index, int value, TypeReference declaredType) {
public SSAArrayStoreInstruction ArrayStoreInstruction(int iindex, int arrayref, int index, int value, TypeReference declaredType) {
throw new UnsupportedOperationException();
}
public SSABinaryOpInstruction BinaryOpInstruction(IOperator operator, boolean overflow, boolean unsigned, int result,
public SSABinaryOpInstruction BinaryOpInstruction(int iindex, IOperator operator, boolean overflow, boolean unsigned, int result,
int val1, int val2, boolean mayBeInteger) {
return new SSABinaryOpInstruction(operator, result, val1, val2, mayBeInteger) {
return new SSABinaryOpInstruction(iindex, operator, result, val1, val2, mayBeInteger) {
public boolean isPEI() {
return false;
}
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return insts.BinaryOpInstruction(getOperator(), false, false, defs == null || defs.length == 0 ? getDef(0) : defs[0],
return insts.BinaryOpInstruction(iindex, getOperator(), false, false, defs == null || defs.length == 0 ? getDef(0) : defs[0],
uses == null ? getUse(0) : uses[0], uses == null ? getUse(1) : uses[1], mayBeIntegerOp());
}
};
}
public SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference[] types) {
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference[] types) {
throw new UnsupportedOperationException();
}
public SSACheckCastInstruction CheckCastInstruction(int result, int val, int[] typeValues) {
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int[] typeValues) {
throw new UnsupportedOperationException();
}
public SSACheckCastInstruction CheckCastInstruction(int result, int val, int typeValue) {
return CheckCastInstruction(result, val, new int[]{ typeValue });
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int typeValue) {
return CheckCastInstruction(iindex, result, val, new int[]{ typeValue });
}
public SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference type) {
return CheckCastInstruction(result, val, new TypeReference[]{ type });
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference type) {
return CheckCastInstruction(iindex, result, val, new TypeReference[]{ type });
}
public SSAComparisonInstruction ComparisonInstruction(Operator operator, int result, int val1, int val2) {
return new SSAComparisonInstruction(operator, result, val1, val2);
public SSAComparisonInstruction ComparisonInstruction(int iindex, Operator operator, int result, int val1, int val2) {
return new SSAComparisonInstruction(iindex, operator, result, val1, val2);
}
public SSAConditionalBranchInstruction ConditionalBranchInstruction(
public SSAConditionalBranchInstruction ConditionalBranchInstruction(int iindex,
com.ibm.wala.shrikeBT.IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2) {
return new SSAConditionalBranchInstruction(operator, type, val1, val2);
return new SSAConditionalBranchInstruction(iindex, operator, type, val1, val2);
}
public SSAConversionInstruction ConversionInstruction(int result, int val, TypeReference fromType, TypeReference toType,
public SSAConversionInstruction ConversionInstruction(int iindex, int result, int val, TypeReference fromType, TypeReference toType,
boolean overflow) {
assert !overflow;
return new SSAConversionInstruction(result, val, fromType, toType) {
return new SSAConversionInstruction(iindex, result, val, fromType, toType) {
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) throws IllegalArgumentException {
if (uses != null && uses.length == 0) {
throw new IllegalArgumentException("(uses != null) and (uses.length == 0)");
}
return insts.ConversionInstruction(defs == null || defs.length == 0 ? getDef(0) : defs[0], uses == null ? getUse(0)
return insts.ConversionInstruction(iindex, defs == null || defs.length == 0 ? getDef(0) : defs[0], uses == null ? getUse(0)
: uses[0], getFromType(), getToType(), false);
}
};
}
public SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int bbNumber, int exceptionValueNumber) {
return new SSAGetCaughtExceptionInstruction(bbNumber, exceptionValueNumber);
public SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int iindex, int bbNumber, int exceptionValueNumber) {
return new SSAGetCaughtExceptionInstruction(iindex, bbNumber, exceptionValueNumber);
}
public SSAGetInstruction GetInstruction(int result, FieldReference field) {
public SSAGetInstruction GetInstruction(int iindex, int result, FieldReference field) {
throw new UnsupportedOperationException();
}
public SSAGetInstruction GetInstruction(int result, int ref, FieldReference field) {
return new SSAGetInstruction(result, ref, field) {
public SSAGetInstruction GetInstruction(int iindex, int result, int ref, FieldReference field) {
return new SSAGetInstruction(iindex, result, ref, field) {
public boolean isPEI() {
return false;
}
};
}
public SSAGotoInstruction GotoInstruction() {
return new SSAGotoInstruction();
public SSAGotoInstruction GotoInstruction(int iindex) {
return new SSAGotoInstruction(iindex);
}
public SSAInstanceofInstruction InstanceofInstruction(int result, int ref, TypeReference checkedType) {
public SSAInstanceofInstruction InstanceofInstruction(int iindex, int result, int ref, TypeReference checkedType) {
throw new UnsupportedOperationException();
}
public SSAInvokeInstruction InvokeInstruction(int result, int[] params, int exception, CallSiteReference site) {
public SSAInvokeInstruction InvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) {
throw new UnsupportedOperationException();
}
public SSAInvokeInstruction InvokeInstruction(int[] params, int exception, CallSiteReference site) {
public SSAInvokeInstruction InvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) {
throw new UnsupportedOperationException();
}
public SSALoadMetadataInstruction LoadMetadataInstruction(int lval, TypeReference entityType, Object token) {
public SSALoadMetadataInstruction LoadMetadataInstruction(int iindex, int lval, TypeReference entityType, Object token) {
throw new UnsupportedOperationException();
}
public SSAMonitorInstruction MonitorInstruction(int ref, boolean isEnter) {
public SSAMonitorInstruction MonitorInstruction(int iindex, int ref, boolean isEnter) {
throw new UnsupportedOperationException();
}
public SSANewInstruction NewInstruction(int result, NewSiteReference site) {
return new SSANewInstruction(result, site) {
public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site) {
return new SSANewInstruction(iindex, result, site) {
public boolean isPEI() {
return true;
}
@ -439,44 +439,44 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
};
}
public SSANewInstruction NewInstruction(int result, NewSiteReference site, int[] params) {
public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site, int[] params) {
throw new UnsupportedOperationException();
}
public SSAPhiInstruction PhiInstruction(int result, int[] params) {
return new SSAPhiInstruction(result, params);
public SSAPhiInstruction PhiInstruction(int iindex, int result, int[] params) {
return new SSAPhiInstruction(iindex, result, params);
}
public SSAPiInstruction PiInstruction(int result, int val, int piBlock, int successorBlock, SSAInstruction cause) {
return new SSAPiInstruction(result, val, piBlock, successorBlock, cause);
public SSAPiInstruction PiInstruction(int iindex, int result, int val, int piBlock, int successorBlock, SSAInstruction cause) {
return new SSAPiInstruction(iindex, result, val, piBlock, successorBlock, cause);
}
public SSAPutInstruction PutInstruction(int ref, int value, FieldReference field) {
return new SSAPutInstruction(ref, value, field) {
public SSAPutInstruction PutInstruction(int iindex, int ref, int value, FieldReference field) {
return new SSAPutInstruction(iindex, ref, value, field) {
public boolean isPEI() {
return false;
}
};
}
public SSAPutInstruction PutInstruction(int value, FieldReference field) {
public SSAPutInstruction PutInstruction(int iindex, int value, FieldReference field) {
throw new UnsupportedOperationException();
}
public SSAReturnInstruction ReturnInstruction() {
return new SSAReturnInstruction();
public SSAReturnInstruction ReturnInstruction(int iindex) {
return new SSAReturnInstruction(iindex);
}
public SSAReturnInstruction ReturnInstruction(int result, boolean isPrimitive) {
return new SSAReturnInstruction(result, isPrimitive);
public SSAReturnInstruction ReturnInstruction(int iindex, int result, boolean isPrimitive) {
return new SSAReturnInstruction(iindex, result, isPrimitive);
}
public SSASwitchInstruction SwitchInstruction(int val, int defaultLabel, int[] casesAndLabels) {
return new SSASwitchInstruction(val, defaultLabel, casesAndLabels);
public SSASwitchInstruction SwitchInstruction(int iindex, int val, int defaultLabel, int[] casesAndLabels) {
return new SSASwitchInstruction(iindex, val, defaultLabel, casesAndLabels);
}
public SSAThrowInstruction ThrowInstruction(int exception) {
return new SSAThrowInstruction(exception) {
public SSAThrowInstruction ThrowInstruction(int iindex, int exception) {
return new SSAThrowInstruction(iindex, exception) {
public boolean isPEI() {
return true;
}
@ -487,28 +487,28 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
};
}
public SSAUnaryOpInstruction UnaryOpInstruction(com.ibm.wala.shrikeBT.IUnaryOpInstruction.IOperator operator, int result,
public SSAUnaryOpInstruction UnaryOpInstruction(int iindex, com.ibm.wala.shrikeBT.IUnaryOpInstruction.IOperator operator, int result,
int val) {
return new SSAUnaryOpInstruction(operator, result, val);
return new SSAUnaryOpInstruction(iindex, operator, result, val);
}
public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, TypeReference pointeeType) {
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, TypeReference pointeeType) {
throw new UnsupportedOperationException();
}
public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, int indexVal, TypeReference pointeeType) {
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, int indexVal, TypeReference pointeeType) {
throw new UnsupportedOperationException();
}
public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, FieldReference field, TypeReference pointeeType) {
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, FieldReference field, TypeReference pointeeType) {
throw new UnsupportedOperationException();
}
public SSALoadIndirectInstruction LoadIndirectInstruction(int lval, TypeReference t, int addressVal) {
public SSALoadIndirectInstruction LoadIndirectInstruction(int iindex, int lval, TypeReference t, int addressVal) {
throw new UnsupportedOperationException();
}
public SSAStoreIndirectInstruction StoreIndirectInstruction(int addressVal, int rval, TypeReference t) {
public SSAStoreIndirectInstruction StoreIndirectInstruction(int iindex, int addressVal, int rval, TypeReference t) {
throw new UnsupportedOperationException();
}

View File

@ -8,28 +8,28 @@ import com.ibm.wala.ssa.SSAPutInstruction;
public interface JSInstructionFactory extends AstInstructionFactory {
JavaScriptCheckReference CheckReference(int ref);
JavaScriptCheckReference CheckReference(int iindex, int ref);
SSAGetInstruction GetInstruction(int result, int ref, String field);
SSAGetInstruction GetInstruction(int iindex, int result, int ref, String field);
JavaScriptInstanceOf InstanceOf(int result, int objVal, int typeVal);
JavaScriptInstanceOf InstanceOf(int iindex, int result, int objVal, int typeVal);
JavaScriptInvoke Invoke(int function, int results[], int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int function, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites);
JavaScriptInvoke Invoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites);
JavaScriptInvoke Invoke(int function, int result, int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int function, int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int iindex, int function, int[] params, int exception, CallSiteReference site);
JavaScriptPropertyRead PropertyRead(int result, int objectRef, int memberRef);
JavaScriptPropertyRead PropertyRead(int iindex, int result, int objectRef, int memberRef);
JavaScriptPropertyWrite PropertyWrite(int objectRef, int memberRef, int value);
JavaScriptPropertyWrite PropertyWrite(int iindex, int objectRef, int memberRef, int value);
SSAPutInstruction PutInstruction(int ref, int value, String field);
SSAPutInstruction PutInstruction(int iindex, int ref, int value, String field);
JavaScriptTypeOfInstruction TypeOfInstruction(int lval, int object);
JavaScriptTypeOfInstruction TypeOfInstruction(int iindex, int lval, int object);
JavaScriptWithRegion WithRegion(int expr, boolean isEnter);
JavaScriptWithRegion WithRegion(int iindex, int expr, boolean isEnter);
}

View File

@ -12,13 +12,14 @@ import com.ibm.wala.types.TypeReference;
public class JavaScriptCheckReference extends SSAInstruction {
private final int ref;
public JavaScriptCheckReference(int ref) {
public JavaScriptCheckReference(int iindex, int ref) {
super(iindex);
this.ref = ref;
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).CheckReference(uses==null? ref: uses[0]);
return ((JSInstructionFactory)insts).CheckReference(iindex, uses==null? ref: uses[0]);
}
@Override

View File

@ -15,7 +15,8 @@ public class JavaScriptInstanceOf extends SSAInstruction {
private final int typeVal;
private final int result;
public JavaScriptInstanceOf(int result, int objVal, int typeVal) {
public JavaScriptInstanceOf(int iindex, int result, int objVal, int typeVal) {
super(iindex);
this.objVal = objVal;
this.typeVal = typeVal;
this.result = result;
@ -24,7 +25,7 @@ public class JavaScriptInstanceOf extends SSAInstruction {
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return
((JSInstructionFactory)insts).InstanceOf(
((JSInstructionFactory)insts).InstanceOf(iindex,
defs==null? result: defs[0],
uses==null? objVal: uses[0],
uses==null? typeVal: uses[1]);

View File

@ -29,25 +29,25 @@ public class JavaScriptInvoke extends AbstractLexicalInvoke {
private int function;
public JavaScriptInvoke(int function, int results[], int[] params, int exception, CallSiteReference site) {
super(results, exception, site);
public JavaScriptInvoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site) {
super(iindex, results, exception, site);
this.function = function;
this.params = params;
}
public JavaScriptInvoke(int function, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads,
public JavaScriptInvoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads,
Access[] lexicalWrites) {
super(results, exception, site, lexicalReads, lexicalWrites);
super(iindex, results, exception, site, lexicalReads, lexicalWrites);
this.function = function;
this.params = params;
}
public JavaScriptInvoke(int function, int result, int[] params, int exception, CallSiteReference site) {
this(function, new int[] { result }, params, exception, site);
public JavaScriptInvoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site) {
this(iindex, function, new int[] { result }, params, exception, site);
}
public JavaScriptInvoke(int function, int[] params, int exception, CallSiteReference site) {
this(function, null, params, exception, site);
public JavaScriptInvoke(int iindex, int function, int[] params, int exception, CallSiteReference site) {
this(iindex, function, null, params, exception, site);
}
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
@ -93,7 +93,7 @@ public class JavaScriptInvoke extends AbstractLexicalInvoke {
}
}
return ((JSInstructionFactory)insts).Invoke(fn, newLvals, newParams, newExp, site, reads, writes);
return ((JSInstructionFactory)insts).Invoke(iindex, fn, newLvals, newParams, newExp, site, reads, writes);
}
public String toString(SymbolTable symbolTable) {

View File

@ -18,13 +18,13 @@ import com.ibm.wala.ssa.SSAInstructionFactory;
import com.ibm.wala.types.TypeReference;
public class JavaScriptPropertyRead extends AbstractReflectiveGet {
public JavaScriptPropertyRead(int result, int objectRef, int memberRef) {
super(result, objectRef, memberRef);
public JavaScriptPropertyRead(int iindex, int result, int objectRef, int memberRef) {
super(iindex, result, objectRef, memberRef);
}
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return
((JSInstructionFactory)insts).PropertyRead(
((JSInstructionFactory)insts).PropertyRead(iindex,
defs==null? getDef(): defs[0],
uses==null? getObjectRef(): uses[0],
uses==null? getMemberRef(): uses[1]);

View File

@ -20,12 +20,12 @@ import com.ibm.wala.types.TypeReference;
public class JavaScriptPropertyWrite extends AbstractReflectivePut {
public JavaScriptPropertyWrite(int objectRef, int memberRef, int value) {
super(objectRef, memberRef, value);
public JavaScriptPropertyWrite(int iindex, int objectRef, int memberRef, int value) {
super(iindex, objectRef, memberRef, value);
}
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).PropertyWrite(uses == null ? getObjectRef() : uses[0], uses == null ? getMemberRef() : uses[1],
return ((JSInstructionFactory)insts).PropertyWrite(iindex, uses == null ? getObjectRef() : uses[0], uses == null ? getMemberRef() : uses[1],
uses == null ? getValue() : uses[2]);
}

View File

@ -20,12 +20,12 @@ import com.ibm.wala.types.TypeReference;
public class JavaScriptTypeOfInstruction extends SSAAbstractUnaryInstruction {
public JavaScriptTypeOfInstruction(int lval, int object) {
super(lval, object);
public JavaScriptTypeOfInstruction(int iindex, int lval, int object) {
super(iindex, lval, object);
}
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).TypeOfInstruction((defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
return ((JSInstructionFactory)insts).TypeOfInstruction(iindex, (defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
}
public String toString(SymbolTable symbolTable) {

View File

@ -11,14 +11,15 @@ public class JavaScriptWithRegion extends SSAInstruction {
private final int expr;
private final boolean isEnter;
public JavaScriptWithRegion(int expr, boolean isEnter) {
public JavaScriptWithRegion(int iindex, int expr, boolean isEnter) {
super(iindex);
this.expr = expr;
this.isEnter = isEnter;
}
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).WithRegion(uses==null? expr: uses[0], isEnter);
return ((JSInstructionFactory)insts).WithRegion(iindex, uses==null? expr: uses[0], isEnter);
}
@Override

View File

@ -72,7 +72,7 @@ public class JSAstTranslator extends AstTranslator {
private void addDefinedCheck(CAstNode n, WalkContext context, int readVn) {
context.cfg().addPreNode(n);
context.cfg().addInstruction(((JSInstructionFactory)insts).CheckReference(readVn));
context.cfg().addInstruction(((JSInstructionFactory)insts).CheckReference(context.cfg().getCurrentInstruction(), readVn));
CAstNode target = context.getControlFlow().getTarget(n, JavaScriptTypes.ReferenceError);
if (target != null) {
@ -159,7 +159,7 @@ public class JSAstTranslator extends AstTranslator {
}
protected void doThrow(WalkContext context, int exception) {
context.cfg().addInstruction(insts.ThrowInstruction(exception));
context.cfg().addInstruction(insts.ThrowInstruction(context.cfg().getCurrentInstruction(), exception));
}
protected void doCall(WalkContext context, CAstNode call, int result, int exception, CAstNode name, int receiver, int[] arguments) {
@ -169,7 +169,7 @@ public class JSAstTranslator extends AstTranslator {
AstMethodReference.fnReference(JavaScriptTypes.CodeBody);
context.cfg().addInstruction(
((JSInstructionFactory)insts).Invoke(receiver, result, arguments, exception,
((JSInstructionFactory)insts).Invoke(context.cfg().getCurrentInstruction(), receiver, result, arguments, exception,
new JSCallSiteReference(ref, context.cfg().getCurrentInstruction())));
context.cfg().addPreNode(call, context.getUnwindState());
@ -190,7 +190,7 @@ public class JSAstTranslator extends AstTranslator {
TypeName.string2TypeName( "L" + type ));
context.cfg().addInstruction(
insts.NewInstruction(
insts.NewInstruction(context.cfg().getCurrentInstruction(),
result,
NewSiteReference.make(
context.cfg().getCurrentInstruction(),
@ -201,7 +201,7 @@ public class JSAstTranslator extends AstTranslator {
int nm = context.currentScope().getConstantValue("L"+composeEntityName(context, fn));
int tmp = super.doGlobalRead(n, context, "Function");
context.cfg().addInstruction(
((JSInstructionFactory)insts).Invoke(tmp, result, new int[]{ nm }, exception,
((JSInstructionFactory)insts).Invoke(context.cfg().getCurrentInstruction(), tmp, result, new int[]{ nm }, exception,
new JSCallSiteReference(
JavaScriptMethods.ctorReference,
context.cfg().getCurrentInstruction())));
@ -219,17 +219,17 @@ public class JSAstTranslator extends AstTranslator {
this.visit(elt, context, this);
int x = context.currentScope().allocateTempValue();
context.cfg().addInstruction(((JSInstructionFactory)insts).AssignInstruction(x, receiver));
context.cfg().addInstruction(((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(), x, receiver));
if (elt.getKind()==CAstNode.CONSTANT && elt.getValue() instanceof String) {
String field = (String)elt.getValue();
// symtab needs to have this value
context.currentScope().getConstantValue(field);
context.cfg().addInstruction(
((JSInstructionFactory)insts).GetInstruction(result, x, field));
((JSInstructionFactory)insts).GetInstruction(context.cfg().getCurrentInstruction(), result, x, field));
} else {
context.cfg().addInstruction(
((JSInstructionFactory)insts).PropertyRead(result, x, getValue(elt) ));
((JSInstructionFactory)insts).PropertyRead(context.cfg().getCurrentInstruction(), result, x, getValue(elt) ));
}
}
@ -239,7 +239,7 @@ public class JSAstTranslator extends AstTranslator {
{
String field = (String)elt.getValue();
context.currentScope().getConstantValue(field);
SSAPutInstruction put = ((JSInstructionFactory)insts).PutInstruction(receiver, rval, field);
SSAPutInstruction put = ((JSInstructionFactory)insts).PutInstruction(context.cfg().getCurrentInstruction(), receiver, rval, field);
try {
assert field.equals(put.getDeclaredField().getName().toUnicodeString());
} catch (UTFDataFormatException e) {
@ -248,7 +248,7 @@ public class JSAstTranslator extends AstTranslator {
context.cfg().addInstruction(put);
} else {
context.cfg().addInstruction(
((JSInstructionFactory)insts).PropertyWrite(receiver, getValue(elt), rval));
((JSInstructionFactory)insts).PropertyWrite(context.cfg().getCurrentInstruction(), receiver, getValue(elt), rval));
}
}
@ -259,7 +259,7 @@ public class JSAstTranslator extends AstTranslator {
int rval = context.currentScope().getConstantValue(typeName);
context.currentScope().getConstantValue("class");
context.cfg().addInstruction(
((JSInstructionFactory)insts).PutInstruction(resultVal, rval, "class"));
((JSInstructionFactory)insts).PutInstruction(context.cfg().getCurrentInstruction(), resultVal, rval, "class"));
}
protected void doPrimitive(int resultVal, WalkContext context, CAstNode primitiveCall) {
@ -267,42 +267,42 @@ public class JSAstTranslator extends AstTranslator {
String name = (String)primitiveCall.getChild(0).getValue();
if (name.equals("GlobalNaN")) {
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal,
context.currentScope().getConstantValue(new Float(Float.NaN))));
} else if (name.equals("GlobalInfinity")) {
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal,
context.currentScope().getConstantValue(new Float(Float.POSITIVE_INFINITY))));
} else if (name.equals("MathE")) {
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal,
context.currentScope().getConstantValue(new Double(Math.E))));
} else if (name.equals("MathPI")) {
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal,
context.currentScope().getConstantValue(new Double(Math.PI))));
} else if (name.equals("MathSQRT1_2")) {
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal,
context.currentScope().getConstantValue(new Double(Math.sqrt(.5)))));
} else if (name.equals("MathSQRT2")) {
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal,
context.currentScope().getConstantValue(new Double(Math.sqrt(2)))));
} else if (name.equals("MathLN2")) {
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal,
context.currentScope().getConstantValue(new Double(Math.log(2)))));
} else if (name.equals("MathLN10")) {
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal,
context.currentScope().getConstantValue(new Double(Math.log(10)))));
} else if (name.equals("NewObject")) {
@ -328,7 +328,7 @@ public class JSAstTranslator extends AstTranslator {
} else {
context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction(
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal,
context.currentScope().getConstantValue( null )));
}
@ -352,12 +352,12 @@ public class JSAstTranslator extends AstTranslator {
JavaScriptTypes.Root);
context.cfg()
.addInstruction(((JSInstructionFactory)insts).IsDefinedInstruction(result, ref, fieldRef));
.addInstruction(((JSInstructionFactory)insts).IsDefinedInstruction(context.cfg().getCurrentInstruction(), result, ref, fieldRef));
} else {
context.cfg()
.addInstruction(((JSInstructionFactory)insts).IsDefinedInstruction(result, ref, getValue(f)));
.addInstruction(((JSInstructionFactory)insts).IsDefinedInstruction(context.cfg().getCurrentInstruction(), result, ref, getValue(f)));
}
}
@ -378,7 +378,7 @@ public class JSAstTranslator extends AstTranslator {
visit(n.getChild(1), context, visitor);
int type = getValue(n.getChild(1));
context.cfg().addInstruction(new JavaScriptInstanceOf(result, value, type));
context.cfg().addInstruction(new JavaScriptInstanceOf(context.cfg().getCurrentInstruction(), result, value, type));
}
protected void doPrologue(WalkContext context) {
@ -388,7 +388,7 @@ public class JSAstTranslator extends AstTranslator {
CAstSymbol args = new CAstSymbolImpl("arguments");
context.currentScope().declare(args, tempVal);
context.cfg().addInstruction(
((JSInstructionFactory)insts).PutInstruction(1, tempVal, "arguments"));
((JSInstructionFactory)insts).PutInstruction(context.cfg().getCurrentInstruction(), 1, tempVal, "arguments"));
}
protected boolean doVisit(CAstNode n, Context cntxt, CAstVisitor visitor) {
@ -401,7 +401,7 @@ public class JSAstTranslator extends AstTranslator {
int ref = getValue(n.getChild(0));
context.cfg().addInstruction(
((JSInstructionFactory)insts).TypeOfInstruction(result, ref));
((JSInstructionFactory)insts).TypeOfInstruction(context.cfg().getCurrentInstruction(), result, ref));
setValue(n, result);
return true;
@ -413,7 +413,7 @@ public class JSAstTranslator extends AstTranslator {
this.visit(n.getChild(0), context, this);
int ref = getValue(n.getChild(0));
context.cfg().addInstruction(((JSInstructionFactory)insts).WithRegion(ref, n.getKind()==JavaScriptCAstNode.ENTER_WITH));
context.cfg().addInstruction(((JSInstructionFactory)insts).WithRegion(context.cfg().getCurrentInstruction(), ref, n.getKind()==JavaScriptCAstNode.ENTER_WITH));
return true;
}