further work

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@4465 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
msridhar1 2012-02-17 20:15:26 +00:00
parent c9ee502acc
commit 78ef6e3a03
4 changed files with 15 additions and 30 deletions

View File

@ -384,9 +384,6 @@ processExceptions(n, context);
}
}
@Override
protected boolean useLexicalAccessesForExposedVars() {
return false;
}
}

View File

@ -45,11 +45,6 @@ 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);
}
@ -67,12 +62,7 @@ public class JSAstTranslator extends AstTranslator {
}
protected boolean useLocalValuesForLexicalVars() {
return !NEW_LEXICAL;
// return false;
}
protected boolean useLexicalAccessesForExposedVars() {
return NEW_LEXICAL;
return !AstTranslator.NEW_LEXICAL;
}
protected TypeReference defaultCatchType() {

View File

@ -600,7 +600,7 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
System.err.println(("looking up lexical parent " + definer));
boolean foundOnStack = false;
if (r != null) {
if (r != null && !AstTranslator.NEW_LEXICAL) {
if (! funargsOnly) {
if (r.isReadOnly(accesses[i].getName())) {
assert isLoad;

View File

@ -115,12 +115,6 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
*/
protected abstract boolean useLocalValuesForLexicalVars();
/**
* should variables accessed by nested entities be accessed with lexical
* access instructions in the declaring entity?
*/
protected abstract boolean useLexicalAccessesForExposedVars();
protected boolean topLevelFunctionsInGlobalScope() {
return true;
}
@ -257,15 +251,14 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
// variables at the beginning of the method.
if (useLocalValuesForLexicalVars()) {
context.cfg().addInstruction(new AstLexicalRead(new Access[0]));
}
if (useLexicalAccessesForExposedVars()) {
} else {
// perform a lexical write to copy the value stored in the local
// associated with each parameter to the lexical name
final CAstEntity entity = context.top();
Set<String> exposedNames = entity2ExposedNames.get(entity);
if (exposedNames != null) {
for (String arg : entity.getArgumentNames()) {
if (exposedNames.contains(arg)) {
// perform a lexical write to copy the value stored in the local
// associated with the parameter to the lexical name
final Scope currentScope = context.currentScope();
Symbol symbol = currentScope.lookup(arg);
assert symbol.getDefiningScope() == currentScope;
@ -290,7 +283,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
* caller is responsible for ensuring that name is defined in the local scope.
*/
protected int doLocalRead(WalkContext context, String name) {
if (useLexicalAccessesForExposedVars()) {
if (!useLocalValuesForLexicalVars()) {
CAstEntity entity = context.top();
Set<String> exposed = entity2ExposedNames.get(entity);
if (exposed != null && exposed.contains(name) && Arrays.asList(entity.getArgumentNames()).contains(name)) {
@ -306,7 +299,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
* that nm is defined in the local scope.
*/
protected void doLocalWrite(WalkContext context, String nm, int rval) {
if (useLexicalAccessesForExposedVars()) {
if (!useLocalValuesForLexicalVars()) {
CAstEntity entity = context.top();
Set<String> exposed = entity2ExposedNames.get(entity);
if (exposed != null && exposed.contains(nm) && Arrays.asList(entity.getArgumentNames()).contains(nm)) {
@ -389,7 +382,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);
markExposedInEnclosingEntities(context, name, definingScope, E, entityName, false);
return result;
}
}
@ -454,7 +447,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);
markExposedInEnclosingEntities(context, name, definingScope, E, context.getEntityName(E), true);
}
}
@ -4262,6 +4255,11 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
walkEntities(N, new RootContext(N, module));
}
/**
* set to true to use new handling of lexical scoping
*/
public final static boolean NEW_LEXICAL = false;
public void translate(final CAstEntity N, final WalkContext context) {
walkEntities(N, context);
}