fixed one CG building bug with useLocalsForLexicalVars() disabled

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@4463 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
msridhar1 2012-02-17 20:14:51 +00:00
parent c9d914304d
commit 8982d35800
2 changed files with 17 additions and 4 deletions

View File

@ -45,6 +45,11 @@ import com.ibm.wala.util.strings.Atom;
public class JSAstTranslator extends AstTranslator {
private final static boolean DEBUG = false;
/**
* set to true to use new handling of lexical scoping
*/
public final static boolean NEW_LEXICAL = false;
public JSAstTranslator(JavaScriptLoader loader) {
super(loader);
}
@ -62,11 +67,12 @@ public class JSAstTranslator extends AstTranslator {
}
protected boolean useLocalValuesForLexicalVars() {
return true;
return !NEW_LEXICAL;
// return false;
}
protected boolean useLexicalAccessesForExposedVars() {
return false;
return NEW_LEXICAL;
}
protected TypeReference defaultCatchType() {

View File

@ -389,6 +389,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
Access A = new Access(name, entityName, result);
//>>>>>>> .r4421
context.cfg().addInstruction(new AstLexicalRead(A));
addAccess(context, context.top(), A);
return result;
}
}
@ -453,6 +454,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
// lexically-scoped variables must be written in their scope each time
Access A = new Access(name, context.getEntityName(E), rval);
context.cfg().addInstruction(new AstLexicalWrite(A));
addAccess(context, context.top(), A);
}
}
@ -480,6 +482,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
int result = context.currentScope().allocateTempValue();
Access A = new Access(name, null, result);
context.cfg().addInstruction(new AstLexicalRead(A));
addAccess(context, context.top(), A);
return result;
}
@ -516,6 +519,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
} else {
Access A = new Access(name, null, rval);
context.cfg().addInstruction(new AstLexicalWrite(A));
addAccess(context, context.top(), A);
}
// globals can be treated as a single static location
@ -2649,13 +2653,15 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
};
/**
* record that in entity e, the access is performed using a local variable. in
* record that in entity e, the access is performed.
*
* If {@link #useLocalValuesForLexicalVars()} is true, the access is performed
* using a local variable. in
* {@link #patchLexicalAccesses(SSAInstruction[], Set)}, this information is
* used to update an instruction that performs all the accesses at the
* beginning of the method and defines the locals.
*/
private void addAccess(WalkContext context, CAstEntity e, Access access) {
assert useLocalValuesForLexicalVars();
context.getAccesses(e).add(access);
}
@ -2833,6 +2839,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
// should just be AstLexicalRead for now; may add support for
// AstLexicalWrite later
assert instrs[i] instanceof AstLexicalRead;
assert useLocalValuesForLexicalVars();
if (AC != null) {
((AstLexicalAccess) instrs[i]).setAccesses(AC);
} else {