From 577d3b9875951588ac5cc5b0fdad9b33cf2b6e25 Mon Sep 17 00:00:00 2001 From: dolby-oss Date: Tue, 2 Dec 2008 14:08:57 +0000 Subject: [PATCH] enhancements to handling of lexical scoping; fixes for X10 git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3110 f5eafffb-2e1d-0410-98e4-8ec43c5233c4 --- .../ipa/callgraph/JavaScopeMappingInstanceKeys.java | 1 + .../wala/cast/java/loader/JavaSourceLoaderImpl.java | 13 +++++++------ .../cast/java/translator/JavaCAst2IRTranslator.java | 2 +- .../polyglot/PolyglotJava2CAstTranslator.java | 8 ++++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/JavaScopeMappingInstanceKeys.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/JavaScopeMappingInstanceKeys.java index 8983d0024..b7864da02 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/JavaScopeMappingInstanceKeys.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/JavaScopeMappingInstanceKeys.java @@ -17,6 +17,7 @@ import com.ibm.wala.cast.ipa.callgraph.ScopeMappingInstanceKeys; import com.ibm.wala.cast.ir.translator.AstTranslator; import com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl.JavaClass; import com.ibm.wala.cast.loader.AstMethod; +import com.ibm.wala.cast.loader.AstMethod.LexicalInformation; import com.ibm.wala.cast.loader.AstMethod.LexicalParent; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/loader/JavaSourceLoaderImpl.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/loader/JavaSourceLoaderImpl.java index 4f43b958b..7ad755cee 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/loader/JavaSourceLoaderImpl.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/loader/JavaSourceLoaderImpl.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Set; import com.ibm.wala.cast.ir.translator.AstTranslator; +import com.ibm.wala.cast.ir.translator.AstTranslator.AstLexicalInformation; import com.ibm.wala.cast.java.translator.SourceModuleTranslator; import com.ibm.wala.cast.loader.AstClass; import com.ibm.wala.cast.loader.AstField; @@ -118,7 +119,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl { } private void addMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, - TypeReference[][] catchTypes, LexicalInformation lexicalInfo, DebuggingInformation debugInfo) { + TypeReference[][] catchTypes, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { declaredMethods.put(Util.methodEntityToSelector(methodEntity), new ConcreteJavaMethod(methodEntity, owner, cfg, symtab, hasCatchBlock, catchTypes, lexicalInfo, debugInfo)); } @@ -169,7 +170,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl { private final TypeReference[] exceptionTypes; public JavaEntityMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, - TypeReference[][] catchTypes, LexicalInformation lexicalInfo, DebuggingInformation debugInfo) { + TypeReference[][] catchTypes, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { super(owner, methodEntity.getQualifiers(), cfg, symtab, MethodReference.findOrCreate(owner.getReference(), Util .methodEntityToSelector(methodEntity)), hasCatchBlock, catchTypes, lexicalInfo, debugInfo); this.parameterTypes = computeParameterTypes(methodEntity); @@ -280,7 +281,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl { */ public class ConcreteJavaMethod extends JavaEntityMethod { public ConcreteJavaMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, - TypeReference[][] catchTypes, LexicalInformation lexicalInfo, DebuggingInformation debugInfo) { + TypeReference[][] catchTypes, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { super(methodEntity, owner, cfg, symtab, hasCatchBlock, catchTypes, lexicalInfo, debugInfo); } @@ -301,13 +302,13 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl { Trace.println("resolving parents of " + this); } - if (lexicalInfo == null) { + if (lexicalInfo() == null) { if (AstTranslator.DEBUG_LEXICAL) Trace.println("no info"); return new LexicalParent[0]; } - final String[] parents = lexicalInfo.getScopingParents(); + final String[] parents = lexicalInfo().getScopingParents(); if (parents == null) { if (AstTranslator.DEBUG_LEXICAL) @@ -404,7 +405,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl { protected abstract SourceModuleTranslator getTranslator(); public void defineFunction(CAstEntity n, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, - TypeReference[][] catchTypes, LexicalInformation lexicalInfo, DebuggingInformation debugInfo) { + TypeReference[][] catchTypes, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { ((JavaClass) owner).addMethod(n, owner, cfg, symtab, hasCatchBlock, catchTypes, lexicalInfo, debugInfo); } diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java index f8733a5b7..5f4a423dd 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java @@ -252,7 +252,7 @@ public class JavaCAst2IRTranslator extends AstTranslator { SymbolTable symtab, boolean hasCatchBlock, TypeReference[][] caughtTypes, - LexicalInformation lexicalInfo, + AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { // N.B.: base class may actually ask to create a synthetic type to wrap // code bodies, so we may see other things than TYPE_ENTITY here. diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/polyglot/PolyglotJava2CAstTranslator.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/polyglot/PolyglotJava2CAstTranslator.java index a1d222ee6..2291e2a49 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/polyglot/PolyglotJava2CAstTranslator.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/polyglot/PolyglotJava2CAstTranslator.java @@ -1097,12 +1097,12 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { return lcdNode; } - private Node makeBreakTarget(Node loop) { + protected Node makeBreakTarget(Node loop) { return fNodeFactory.Labeled(Position.COMPILER_GENERATED, "breakLabel" + loop.position().toString().replace('.', '_'), fNodeFactory.Empty(Position.COMPILER_GENERATED)); } - private Node makeContinueTarget(Node loop) { + protected Node makeContinueTarget(Node loop) { return fNodeFactory.Labeled(Position.COMPILER_GENERATED, "continueLabel" + loop.position().toString().replace('.', '_'), fNodeFactory.Empty(Position.COMPILER_GENERATED)); } @@ -2251,10 +2251,10 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { } } - private class LoopContext extends BreakContext { + public class LoopContext extends BreakContext { private final Node continueTo; - protected LoopContext(WalkContext parent, String label, Node breakTo, Node continueTo) { + public LoopContext(WalkContext parent, String label, Node breakTo, Node continueTo) { super(parent, label, breakTo); this.continueTo = continueTo; }