diff --git a/.gitignore b/.gitignore index 34065d937..debca9d4d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ com.ibm.wala.core.testdata/@dot/ com.ibm.wala.core.testdata/lib/ com.ibm.wala.core/dat/wala.properties com.ibm.wala.cast.js.html.nu_validator/lib/ +com.ibm.wala.cast.java.test/testdata/ diff --git a/README.md b/README.md index cb52a9247..27747ed99 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,2 @@ -This is a mirror of the WALA SVN repository. It -is maintained manually for now, but more official support may be added in the -future. For more details on WALA, see the -WALA home page. +This is the main source repository for WALA. For more details on WALA, see the WALA home page. diff --git a/com.ibm.wala.cast.java.jdt.test/META-INF/MANIFEST.MF b/com.ibm.wala.cast.java.jdt.test/META-INF/MANIFEST.MF index a7c7841c1..3249129f4 100644 --- a/com.ibm.wala.cast.java.jdt.test/META-INF/MANIFEST.MF +++ b/com.ibm.wala.cast.java.jdt.test/META-INF/MANIFEST.MF @@ -5,18 +5,18 @@ Bundle-SymbolicName: com.ibm.wala.cast.java.jdt.test Bundle-Version: 1.0.0 Bundle-Activator: com.ibm.wala.cast.java.jdt.test.Activator Bundle-Vendor: IBM -Require-Bundle: com.ibm.wala.cast;bundle-version="1.0.0", - com.ibm.wala.cast.java;bundle-version="1.0.0", - com.ibm.wala.cast.java.test;bundle-version="1.0.0", +Require-Bundle: com.ibm.wala.cast.java.test;bundle-version="1.0.0", com.ibm.wala.cast.test;bundle-version="1.0.0", - com.ibm.wala.core;bundle-version="1.1.3", + com.ibm.wala.ide.tests;bundle-version="1.1.3", com.ibm.wala.core.tests;bundle-version="1.1.3", com.ibm.wala.cast.java.jdt;bundle-version="1.0.0", - org.eclipse.core.runtime, + com.ibm.wala.cast.java;bundle-version="1.0.0", + com.ibm.wala.cast;bundle-version="1.0.0", com.ibm.wala.ide;bundle-version="1.1.3", + com.ibm.wala.core;bundle-version="1.1.3", org.eclipse.core.resources;bundle-version="3.4.1", - com.ibm.wala.ide.tests;bundle-version="1.1.3", org.eclipse.jdt.core;bundle-version="3.4.2", - org.junit4;bundle-version="4.3.1" + org.junit4;bundle-version="4.8.1", + org.eclipse.core.runtime Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/com.ibm.wala.cast.java.jdt.test/launchers/JDTJava15IRTests.launch b/com.ibm.wala.cast.java.jdt.test/launchers/JDTJava15IRTests.launch index 2314e8e51..1896f3978 100644 --- a/com.ibm.wala.cast.java.jdt.test/launchers/JDTJava15IRTests.launch +++ b/com.ibm.wala.cast.java.jdt.test/launchers/JDTJava15IRTests.launch @@ -1,4 +1,4 @@ - + @@ -11,7 +11,8 @@ - + + @@ -24,16 +25,21 @@ + - + + + + + diff --git a/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests (Manu).launch b/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests (Manu).launch new file mode 100644 index 000000000..dcd40c821 --- /dev/null +++ b/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests (Manu).launch @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests.launch b/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests.launch index 79a80c11e..b7b136cde 100644 --- a/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests.launch +++ b/com.ibm.wala.cast.java.jdt.test/launchers/JDTJavaIRTests.launch @@ -1,4 +1,4 @@ - + @@ -11,7 +11,8 @@ - + + @@ -24,16 +25,21 @@ + - + + + + + diff --git a/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJava15IRTests.java b/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJava15IRTests.java index 6cbec7670..3311d5b78 100644 --- a/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJava15IRTests.java +++ b/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJava15IRTests.java @@ -24,11 +24,11 @@ import com.ibm.wala.cast.java.test.ide.IDEIRTestUtil; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.plugin.CoreTestsPlugin; import com.ibm.wala.ide.tests.util.EclipseTestUtil; +import com.ibm.wala.ide.util.EclipseFileProvider; import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.impl.Util; import com.ibm.wala.ipa.cha.IClassHierarchy; -import com.ibm.wala.util.io.FileProvider; public class JDTJava15IRTests extends IRTests { @@ -62,7 +62,7 @@ public class JDTJava15IRTests extends IRTests { }; try { - engine.setExclusionsFile(FileProvider + engine.setExclusionsFile((new EclipseFileProvider()) .getFileFromPlugin(CoreTestsPlugin.getDefault(), CallGraphTestUtil.REGRESSION_EXCLUSIONS).getAbsolutePath()); } catch (IOException e) { Assert.assertFalse("Cannot find exclusions file", true); diff --git a/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJavaIRTests.java b/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJavaIRTests.java index cdb318467..8884ee843 100644 --- a/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJavaIRTests.java +++ b/com.ibm.wala.cast.java.jdt.test/source/com/ibm/wala/cast/java/test/JDTJavaIRTests.java @@ -54,11 +54,11 @@ import com.ibm.wala.cast.java.test.ide.IDEIRTestUtil; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.plugin.CoreTestsPlugin; import com.ibm.wala.ide.tests.util.EclipseTestUtil; +import com.ibm.wala.ide.util.EclipseFileProvider; import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.impl.Util; import com.ibm.wala.ipa.cha.IClassHierarchy; -import com.ibm.wala.util.io.FileProvider; public class JDTJavaIRTests extends JavaIRTests { @@ -96,7 +96,7 @@ public class JDTJavaIRTests extends JavaIRTests { }; try { - engine.setExclusionsFile(FileProvider + engine.setExclusionsFile((new EclipseFileProvider()) .getFileFromPlugin(CoreTestsPlugin.getDefault(), CallGraphTestUtil.REGRESSION_EXCLUSIONS).getAbsolutePath()); } catch (IOException e) { Assert.assertFalse("Cannot find exclusions file", true); diff --git a/com.ibm.wala.cast.java.jdt/source/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java b/com.ibm.wala.cast.java.jdt/source/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java index 901cac5d6..698cb9b72 100644 --- a/com.ibm.wala.cast.java.jdt/source/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java +++ b/com.ibm.wala.cast.java.jdt/source/com/ibm/wala/cast/java/translator/jdt/JDTJava2CAstTranslator.java @@ -128,10 +128,11 @@ import org.eclipse.jdt.core.dom.VariableDeclarationStatement; import org.eclipse.jdt.core.dom.WhileStatement; import com.ibm.wala.cast.ir.translator.AstTranslator.InternalCAstSymbol; +import com.ibm.wala.cast.ir.translator.TranslatorToCAst; +import com.ibm.wala.cast.ir.translator.TranslatorToCAst.DoLoopTranslator; import com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl; import com.ibm.wala.cast.java.loader.Util; import com.ibm.wala.cast.java.translator.JavaProcedureEntity; -import com.ibm.wala.cast.java.translator.TranslatorToCAst; import com.ibm.wala.cast.tree.CAst; import com.ibm.wala.cast.tree.CAstControlFlowMap; import com.ibm.wala.cast.tree.CAstEntity; @@ -175,7 +176,7 @@ import com.ibm.wala.util.debug.Assertions; // * enums (probably in simplename or something. but using resolveConstantExpressionValue() possible) @SuppressWarnings("unchecked") -public class JDTJava2CAstTranslator implements TranslatorToCAst { +public class JDTJava2CAstTranslator { protected final CAst fFactory = new CAstImpl(); // /////////////////////////////////////////// @@ -203,6 +204,8 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { protected ITypeBinding OutOfMemoryError; + protected DoLoopTranslator doLoopTranslator; + private String fullPath; private CompilationUnit cu; @@ -211,20 +214,7 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { // COMPILATION UNITS & TYPES // - public JDTJava2CAstTranslator(JavaSourceLoaderImpl sourceLoader) { - this.fSourceLoader = sourceLoader; - } - - public CAstEntity translate(Object astRoot, String fullPath) { - this.cu = (CompilationUnit) astRoot; - - this.fullPath = fullPath; - ast = cu.getAST(); - - // FIXME: we might need one AST (-> "Object" class) for all files. - fIdentityMapper = new JDTIdentityMapper(fSourceLoader.getReference(), ast); - fTypeDict = new JDTTypeDictionary(ast, fIdentityMapper); - + public JDTJava2CAstTranslator(JavaSourceLoaderImpl sourceLoader, CompilationUnit astRoot, String fullPath, boolean replicateForDoLoops) { fDivByZeroExcType = FakeExceptionTypeBinding.arithmetic; fNullPointerExcType = FakeExceptionTypeBinding.nullPointer; fClassCastExcType = FakeExceptionTypeBinding.classCast; @@ -232,12 +222,27 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { ExceptionInInitializerError = FakeExceptionTypeBinding.initException; OutOfMemoryError = FakeExceptionTypeBinding.outOfMemory; + this.fSourceLoader = sourceLoader; + this.cu = astRoot; + + this.fullPath = fullPath; + ast = cu.getAST(); + + this.doLoopTranslator = new DoLoopTranslator(replicateForDoLoops, fFactory); + + // FIXME: we might need one AST (-> "Object" class) for all files. + fIdentityMapper = new JDTIdentityMapper(fSourceLoader.getReference(), ast); + fTypeDict = new JDTTypeDictionary(ast, fIdentityMapper); + fRuntimeExcType = ast.resolveWellKnownType("java.lang.RuntimeException"); assert fRuntimeExcType != null; + } + + public CAstEntity translateToCAst() { List declEntities = new ArrayList(); - for (Iterator iter = cu.types().iterator(); iter.hasNext();) { + for (Iterator iter = cu.types().iterator(); iter.hasNext();) { AbstractTypeDeclaration decl = (AbstractTypeDeclaration) iter.next(); // can be of type AnnotationTypeDeclaration, EnumDeclaration, TypeDeclaration declEntities.add(visit(decl, new RootContext())); @@ -2095,7 +2100,6 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { // //////////////// private CAstNode visit(LabeledStatement n, WalkContext context) { - ASTNode breakTarget = makeBreakOrContinueTarget(n, n.getLabel().getIdentifier()); // find the first non-block statement ant set-up the label map (useful for breaking many fors) ASTNode stmt = n.getBody(); @@ -2108,10 +2112,12 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { CAstNode result; if (!(n.getBody() instanceof EmptyStatement)) { + ASTNode breakTarget = makeBreakOrContinueTarget(n, n.getLabel().getIdentifier()); + CAstNode breakNode = visitNode(breakTarget, context); WalkContext child = new BreakContext(context, n.getLabel().getIdentifier(), breakTarget); result = makeNode(context, fFactory, n, CAstNode.BLOCK_STMT, makeNode(context, fFactory, n, CAstNode.LABEL_STMT, fFactory - .makeConstant(n.getLabel().getIdentifier()), visitNode(n.getBody(), child)), visitNode(breakTarget, context)); + .makeConstant(n.getLabel().getIdentifier()), visitNode(n.getBody(), child)), breakNode); } else { result = makeNode(context, fFactory, n, CAstNode.LABEL_STMT, fFactory.makeConstant(n.getLabel().getIdentifier()), visitNode(n .getBody(), context)); @@ -2163,7 +2169,10 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { Statement body = n.getBody(); ASTNode breakTarget = makeBreakOrContinueTarget(n, "breakLabel" + n.getStartPosition()); + CAstNode breakNode = visitNode(breakTarget, context); + ASTNode continueTarget = makeBreakOrContinueTarget(n, "continueLabel" + n.getStartPosition()); + CAstNode continueNode = visitNode(continueTarget, context); String loopLabel = (String) context.getLabelMap().get(n); LoopContext lc = new LoopContext(context, loopLabel, breakTarget, continueTarget); @@ -2172,8 +2181,8 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { * The following loop is created sligtly differently than in jscore. It doesn't have a specific target for continue. */ return makeNode(context, fFactory, n, CAstNode.BLOCK_STMT, makeNode(context, fFactory, n, CAstNode.LOOP, visitNode(cond, - context), makeNode(context, fFactory, n, CAstNode.BLOCK_STMT, visitNode(body, lc), visitNode(continueTarget, context))), - visitNode(breakTarget, context)); + context), makeNode(context, fFactory, n, CAstNode.BLOCK_STMT, visitNode(body, lc), continueNode)), + breakNode); } private CAstNode getSwitchCaseConstant(SwitchCase n, WalkContext context) { @@ -2282,22 +2291,21 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { } private CAstNode visit(DoStatement n, WalkContext context) { - ASTNode header = ast.newEmptyStatement(); - ASTNode breakTarget = makeBreakOrContinueTarget(n, "breakLabel" + n.getStartPosition()); - ASTNode continueTarget = makeBreakOrContinueTarget(n, "continue" + "Label" + n.getStartPosition()); - - CAstNode loopGoto = makeNode(context, fFactory, n, CAstNode.IFGOTO, visitNode(n.getExpression(), context)); - - context.cfg().map(loopGoto, loopGoto); - context.cfg().add(loopGoto, header, Boolean.TRUE); - String loopLabel = (String) context.getLabelMap().get(n); // set by visit(LabeledStatement) - WalkContext loopContext = new LoopContext(context, loopLabel, breakTarget, continueTarget); + String token = loopLabel==null? "at_" + n.getStartPosition(): loopLabel; + + ASTNode breakTarget = makeBreakOrContinueTarget(n, "breakLabel_" + token); + CAstNode breakNode = visitNode(breakTarget, context); + ASTNode continueTarget = makeBreakOrContinueTarget(n, "continueLabel_" + token); CAstNode continueNode = visitNode(continueTarget, context); + + CAstNode loopTest = visitNode(n.getExpression(), context); - return makeNode(context, fFactory, n, CAstNode.BLOCK_STMT, visitNode(header, context), makeNode(context, fFactory, n, - CAstNode.BLOCK_STMT, visitNode(n.getBody(), loopContext), continueNode), loopGoto, visitNode(breakTarget, context)); + WalkContext loopContext = new LoopContext(context, loopLabel, breakTarget, continueTarget); + CAstNode loopBody = visitNode(n.getBody(), loopContext); + + return doLoopTranslator.translateDoLoop(loopTest, loopBody, continueNode, breakNode, context); } /** @@ -2861,7 +2869,6 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { } public CAstSourcePositionMap.Position getPosition() { - Assertions.UNREACHABLE("CompilationUnitEntity.getPosition()"); return null; } @@ -2889,24 +2896,12 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { * Contains things needed by in the visit() of some nodes to process the nodes. For example, pos() contains the source position * mapping which each node registers */ - public static interface WalkContext { - // LEFTOUT: plenty of stuff - public CAstControlFlowRecorder cfg(); - - public void addScopedEntity(CAstNode newNode, CAstEntity visit); + public static interface WalkContext extends TranslatorToCAst.WalkContext { public Collection> getCatchTargets(ITypeBinding type); - public CAstSourcePositionRecorder pos(); - - public CAstNodeTypeMapRecorder getNodeTypeMap(); - public Map getLabelMap(); - public ASTNode getContinueFor(String label); - - public ASTNode getBreakFor(String label); - public boolean needLValue(); } @@ -2914,46 +2909,21 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { * Default context functions. When one context doesn't handle something, it the next one up does. For example, there is only one * source pos. mapping per MethodContext, so loop contexts delegate it up. */ - public static class DelegatingContext implements WalkContext { - protected WalkContext parent; + public static class DelegatingContext extends TranslatorToCAst.DelegatingContext implements WalkContext { public DelegatingContext(WalkContext parent) { - this.parent = parent; - } - - public CAstControlFlowRecorder cfg() { - return parent.cfg(); - } - - public CAstSourcePositionRecorder pos() { - return parent.pos(); - } - - public CAstNodeTypeMapRecorder getNodeTypeMap() { - return parent.getNodeTypeMap(); + super(parent); } public Collection> getCatchTargets(ITypeBinding type) { return parent.getCatchTargets(type); } - public void addScopedEntity(CAstNode newNode, CAstEntity visit) { - parent.addScopedEntity(newNode, visit); - } - public Map getLabelMap() { return parent.getLabelMap(); } - public ASTNode getContinueFor(String label) { - return parent.getContinueFor(label); - } - - public ASTNode getBreakFor(String label) { - return parent.getBreakFor(label); - } - - public boolean needLValue() { + public boolean needLValue() { return parent.needLValue(); } } @@ -2961,27 +2931,8 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { /* * Root context. Doesn't do anything. */ - public static class RootContext implements WalkContext { - public void addScopedEntity(CAstNode newNode, CAstEntity visit) { - Assertions.UNREACHABLE("Rootcontext.addScopedEntity()"); - } - - public CAstControlFlowRecorder cfg() { - Assertions.UNREACHABLE("RootContext.cfg()"); - return null; - } - - public CAstSourcePositionRecorder pos() { - Assertions.UNREACHABLE("RootContext.pos()"); - return null; - } - - public CAstNodeTypeMapRecorder getNodeTypeMap() { - Assertions.UNREACHABLE("RootContext.getNodeTypeMap()"); - return null; - } - - public Collection> getCatchTargets(ITypeBinding type) { + public static class RootContext extends TranslatorToCAst.RootContext implements WalkContext { + public Collection> getCatchTargets(ITypeBinding type) { Assertions.UNREACHABLE("RootContext.getCatchTargets()"); return null; } @@ -2991,16 +2942,6 @@ public class JDTJava2CAstTranslator implements TranslatorToCAst { return null; } - public ASTNode getBreakFor(String label) { - Assertions.UNREACHABLE("RootContext.getBreakFor()"); - return null; - } - - public ASTNode getContinueFor(String label) { - Assertions.UNREACHABLE("RootContext.getContinueFor()"); - return null; - } - public boolean needLValue() { Assertions.UNREACHABLE("Rootcontext.needLValue()"); return false; diff --git a/com.ibm.wala.cast.java.jdt/source/com/ibm/wala/cast/java/translator/jdt/JDTSourceModuleTranslator.java b/com.ibm.wala.cast.java.jdt/source/com/ibm/wala/cast/java/translator/jdt/JDTSourceModuleTranslator.java index 04bd8600f..1b4f1d3c9 100644 --- a/com.ibm.wala.cast.java.jdt/source/com/ibm/wala/cast/java/translator/jdt/JDTSourceModuleTranslator.java +++ b/com.ibm.wala.cast.java.jdt/source/com/ibm/wala/cast/java/translator/jdt/JDTSourceModuleTranslator.java @@ -115,8 +115,6 @@ public class JDTSourceModuleTranslator implements SourceModuleTranslator { public void loadAllSources(Set modules) { // TODO: we might need one AST (-> "Object" class) for all files. // TODO: group by project and send 'em in - JDTJava2CAstTranslator jdt2cast = makeCAstTranslator(); - final Java2IRTranslator java2ir = makeIRTranslator(jdt2cast); System.out.println(modules); @@ -143,7 +141,9 @@ public class JDTSourceModuleTranslator implements SourceModuleTranslator { public void acceptAST(ICompilationUnit source, CompilationUnit ast) { try { - java2ir.translate(proj.getValue().get(source), ast, source.getUnderlyingResource().getLocation().toOSString()); + JDTJava2CAstTranslator jdt2cast = makeCAstTranslator(ast, source.getUnderlyingResource().getLocation().toOSString()); + final Java2IRTranslator java2ir = makeIRTranslator(); + java2ir.translate(proj.getValue().get(source), jdt2cast.translateToCAst()); } catch (JavaModelException e) { e.printStackTrace(); } @@ -165,12 +165,12 @@ public class JDTSourceModuleTranslator implements SourceModuleTranslator { } } - protected Java2IRTranslator makeIRTranslator(JDTJava2CAstTranslator jdt2cast) { - return new Java2IRTranslator(jdt2cast, sourceLoader); + protected Java2IRTranslator makeIRTranslator() { + return new Java2IRTranslator(sourceLoader); } - protected JDTJava2CAstTranslator makeCAstTranslator() { - return new JDTJava2CAstTranslator(sourceLoader); + protected JDTJava2CAstTranslator makeCAstTranslator(CompilationUnit cu, String fullPath) { + return new JDTJava2CAstTranslator(sourceLoader, cu, fullPath, false); } } diff --git a/com.ibm.wala.cast.java.polyglot.test/.classpath b/com.ibm.wala.cast.java.polyglot.test/.classpath index a8881a45c..d78eb009a 100644 --- a/com.ibm.wala.cast.java.polyglot.test/.classpath +++ b/com.ibm.wala.cast.java.polyglot.test/.classpath @@ -1,8 +1,8 @@ - + diff --git a/com.ibm.wala.cast.java.polyglot.test/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.java.polyglot.test/.settings/org.eclipse.jdt.core.prefs index 3e6680a6f..687c6efd3 100644 --- a/com.ibm.wala.cast.java.polyglot.test/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.java.polyglot.test/.settings/org.eclipse.jdt.core.prefs @@ -1,10 +1,5 @@ -#Thu Feb 03 10:12:26 EST 2011 +#Mon Jul 02 13:01:58 EDT 2012 eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/com.ibm.wala.cast.java.polyglot.test/launchers/PolyglotJavaIRTests.launch b/com.ibm.wala.cast.java.polyglot.test/launchers/PolyglotJavaIRTests.launch index b38b725e9..4d9837fd2 100644 --- a/com.ibm.wala.cast.java.polyglot.test/launchers/PolyglotJavaIRTests.launch +++ b/com.ibm.wala.cast.java.polyglot.test/launchers/PolyglotJavaIRTests.launch @@ -1,4 +1,4 @@ - + @@ -13,5 +13,6 @@ + diff --git a/com.ibm.wala.cast.java.polyglot/.classpath b/com.ibm.wala.cast.java.polyglot/.classpath index c3f9b76bd..3c4fe4923 100644 --- a/com.ibm.wala.cast.java.polyglot/.classpath +++ b/com.ibm.wala.cast.java.polyglot/.classpath @@ -1,8 +1,8 @@ - - + + diff --git a/com.ibm.wala.cast.java.polyglot/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.cast.java.polyglot/.settings/org.eclipse.jdt.core.prefs index bdc44d798..6468112dd 100644 --- a/com.ibm.wala.cast.java.polyglot/.settings/org.eclipse.jdt.core.prefs +++ b/com.ibm.wala.cast.java.polyglot/.settings/org.eclipse.jdt.core.prefs @@ -1,263 +1,258 @@ -#Mon Apr 13 15:38:50 EDT 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=1 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=132 -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=132 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=2 -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +#Mon Apr 16 10:59:09 EDT 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=132 +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=132 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true diff --git a/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/client/polyglot/EclipseProjectSourceAnalysisEngine.java b/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/client/polyglot/EclipseProjectSourceAnalysisEngine.java index f40398eed..a1dd90d78 100644 --- a/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/client/polyglot/EclipseProjectSourceAnalysisEngine.java +++ b/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/client/polyglot/EclipseProjectSourceAnalysisEngine.java @@ -25,7 +25,8 @@ import com.ibm.wala.classLoader.BinaryDirectoryTreeModule; import com.ibm.wala.classLoader.ClassLoaderFactory; import com.ibm.wala.classLoader.Module; import com.ibm.wala.classLoader.SourceDirectoryTreeModule; -import com.ibm.wala.core.plugin.CorePlugin; +import com.ibm.wala.ide.plugin.CorePlugin; +import com.ibm.wala.ide.util.EclipseFileProvider; import com.ibm.wala.ide.util.EclipseProjectPath; import com.ibm.wala.ide.util.EclipseProjectPath.Loader; import com.ibm.wala.ipa.callgraph.AnalysisCache; @@ -64,7 +65,7 @@ public class EclipseProjectSourceAnalysisEngine extends EclipseProjectAnalysisEn super(project); this.fileExt = fileExt; try { - setExclusionsFile(FileProvider.getFileFromPlugin(CorePlugin.getDefault(), "J2SEClassHierarchyExclusions.txt") + setExclusionsFile((new EclipseFileProvider()).getFileFromPlugin(CorePlugin.getDefault(), "J2SEClassHierarchyExclusions.txt") .getAbsolutePath()); } catch (IOException e) { Assertions.UNREACHABLE("Cannot find exclusions file"); diff --git a/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/translator/polyglot/IRGoal.java b/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/translator/polyglot/IRGoal.java index d104cb88b..e33f9951f 100644 --- a/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/translator/polyglot/IRGoal.java +++ b/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/translator/polyglot/IRGoal.java @@ -51,16 +51,18 @@ public class IRGoal extends SourceGoal_c /* PORT1.7 removed 'implements EndGoal' ExtensionInfo extInfo= job.extensionInfo(); fTranslator= new Java2IRTranslator( + fSourceLoader, + ((IRTranslatorExtension)extInfo).getCAstRewriterFactory()); + ModuleSource src = (ModuleSource) job.source(); + fTranslator.translate( + src.getModule(), new PolyglotJava2CAstTranslator( + job.ast(), fSourceLoader.getReference(), extInfo.nodeFactory(), extInfo.typeSystem(), new PolyglotIdentityMapper(fSourceLoader.getReference()), - ((IRTranslatorExtension)extInfo).getReplicateForDoLoops()), - fSourceLoader, - ((IRTranslatorExtension)extInfo).getCAstRewriterFactory()); - ModuleSource src = (ModuleSource) job.source(); - fTranslator.translate(src.getModule(),job.ast(), src.name()); + ((IRTranslatorExtension)extInfo).getReplicateForDoLoops()).translateToCAst()); return true; } diff --git a/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/translator/polyglot/PolyglotJava2CAstTranslator.java b/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/translator/polyglot/PolyglotJava2CAstTranslator.java index 337abf136..359e6a8ac 100644 --- a/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/translator/polyglot/PolyglotJava2CAstTranslator.java +++ b/com.ibm.wala.cast.java.polyglot/source/com/ibm/wala/cast/java/translator/polyglot/PolyglotJava2CAstTranslator.java @@ -20,6 +20,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -34,6 +35,7 @@ import polyglot.ast.ArrayTypeNode; import polyglot.ast.Assert; import polyglot.ast.Assign; import polyglot.ast.Binary; +import polyglot.ast.Binary.Operator; import polyglot.ast.Block; import polyglot.ast.BooleanLit; import polyglot.ast.Branch; @@ -49,6 +51,7 @@ import polyglot.ast.ClassLit; import polyglot.ast.ClassMember; import polyglot.ast.Conditional; import polyglot.ast.ConstructorCall; +import polyglot.ast.ConstructorCall.Kind; import polyglot.ast.ConstructorDecl; import polyglot.ast.Do; import polyglot.ast.Empty; @@ -94,8 +97,6 @@ import polyglot.ast.TopLevelDecl; import polyglot.ast.Try; import polyglot.ast.Unary; import polyglot.ast.While; -import polyglot.ast.Binary.Operator; -import polyglot.ast.ConstructorCall.Kind; import polyglot.types.ArrayType; import polyglot.types.ClassType; import polyglot.types.CodeInstance; @@ -117,9 +118,11 @@ import polyglot.types.Types; import polyglot.util.Position; import com.ibm.wala.cast.ir.translator.AstTranslator.InternalCAstSymbol; +import com.ibm.wala.cast.ir.translator.TranslatorToCAst; +import com.ibm.wala.cast.ir.translator.TranslatorToCAst.DoLoopTranslator; +import com.ibm.wala.cast.ir.translator.TranslatorToCAst.WalkContext; import com.ibm.wala.cast.java.loader.Util; import com.ibm.wala.cast.java.translator.JavaProcedureEntity; -import com.ibm.wala.cast.java.translator.TranslatorToCAst; import com.ibm.wala.cast.java.types.JavaType; import com.ibm.wala.cast.tree.CAst; import com.ibm.wala.cast.tree.CAstControlFlowMap; @@ -132,12 +135,10 @@ import com.ibm.wala.cast.tree.CAstSymbol; import com.ibm.wala.cast.tree.CAstType; import com.ibm.wala.cast.tree.CAstTypeDictionary; import com.ibm.wala.cast.tree.impl.AbstractSourcePosition; -import com.ibm.wala.cast.tree.impl.CAstCloner; import com.ibm.wala.cast.tree.impl.CAstControlFlowRecorder; import com.ibm.wala.cast.tree.impl.CAstImpl; import com.ibm.wala.cast.tree.impl.CAstNodeTypeMapRecorder; import com.ibm.wala.cast.tree.impl.CAstOperator; -import com.ibm.wala.cast.tree.impl.CAstRewriter; import com.ibm.wala.cast.tree.impl.CAstSourcePositionRecorder; import com.ibm.wala.cast.tree.impl.CAstSymbolImpl; import com.ibm.wala.classLoader.CallSiteReference; @@ -155,8 +156,7 @@ import com.ibm.wala.util.collections.IteratorPlusOne; import com.ibm.wala.util.collections.Pair; import com.ibm.wala.util.debug.Assertions; -@SuppressWarnings("unchecked") -public class PolyglotJava2CAstTranslator implements TranslatorToCAst { +public class PolyglotJava2CAstTranslator { protected final CAst fFactory = new CAstImpl(); protected final NodeFactory fNodeFactory; @@ -179,10 +179,12 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { protected PolyglotIdentityMapper fIdentityMapper; - protected boolean replicateForDoLoops = false; + protected final DoLoopTranslator doLoopTranslator; protected final boolean DEBUG = true; - + + private final Node ast; + final protected TranslatingVisitor getTranslator() { if (fTranslator == null) fTranslator = createTranslator(); @@ -1133,42 +1135,17 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { String loopLabel = (String) wc.getLabelMap().get(d); CAstNode continueNode = walkNodes(continueTarget, wc); - CAstNode breakBody = walkNodes(breakTarget, wc); + CAstNode breakNode = walkNodes(breakTarget, wc); - WalkContext lc = new LoopContext(wc, loopLabel, breakTarget, continueTarget); - CAstNode loopBody = walkNodes(d.body(), lc); - if (replicateForDoLoops) { - CAstRewriter.Rewrite x = (new CAstCloner(fFactory, false)).copy(loopBody, wc.cfg(), wc.pos(), wc.getNodeTypeMap(), null); - CAstNode otherBody = x.newRoot(); - - wc.cfg().addAll(x.newCfg()); - wc.pos().addAll(x.newPos()); - wc.getNodeTypeMap().addAll(x.newTypes()); + WalkContext lc = new LoopContext(wc, loopLabel, breakTarget, continueTarget); + CAstNode loopExpr = walkNodes(d.cond(), wc); + CAstNode loopBody = walkNodes(d.body(), lc); - return makeNode(wc, fFactory, d, CAstNode.BLOCK_STMT, - loopBody, - makeNode(wc, fFactory, d, CAstNode.LOOP, - walkNodes(d.cond(), wc), - makeNode(wc, fFactory, d, CAstNode.BLOCK_STMT, otherBody, continueNode)), - breakBody); - - } else { - Node header = fNodeFactory.Empty(Position.COMPILER_GENERATED); - - CAstNode loopGoto = makeNode(wc, fFactory, d, CAstNode.IFGOTO, walkNodes(d.cond(), wc)); - - wc.cfg().map(loopGoto, loopGoto); - wc.cfg().add(loopGoto, header, Boolean.TRUE); - - return makeNode(wc, fFactory, d, CAstNode.BLOCK_STMT, - walkNodes(header, wc), - makeNode(wc, fFactory, d, CAstNode.BLOCK_STMT, loopBody, continueNode), - loopGoto, - breakBody); - } + return doLoopTranslator.translateDoLoop(loopExpr, loopBody, continueNode, breakNode, wc); } + public CAstNode visit(For f, WalkContext wc) { Node breakTarget = makeBreakTarget(f); Node continueTarget = makeContinueTarget(f); @@ -1434,7 +1411,6 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { } public CAstSourcePositionMap.Position getPosition() { - Assertions.UNREACHABLE("CompilationUnitEntity.getPosition()"); return null; } @@ -1529,12 +1505,8 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { protected abstract static class CodeBodyEntity implements CAstEntity { private final Map> fEntities; - public CodeBodyEntity(Map entities) { - fEntities = new LinkedHashMap>(); - for (Iterator keys = entities.keySet().iterator(); keys.hasNext();) { - CAstNode key = keys.next(); - fEntities.put(key, Collections.singleton(entities.get(key))); - } + public CodeBodyEntity(Map> entities) { + fEntities = new LinkedHashMap>(entities); } public Map> getAllScopedEntities() { @@ -1674,7 +1646,7 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { private final String[] argumentNames; public ProcedureEntity(CAstNode pdast, TypeSystem system, CodeInstance pd, Type declaringType, String[] argumentNames, - Map entities, MethodContext mc) { + Map> entities, MethodContext mc) { super(entities); fPdast = pdast; fSystem = system; @@ -1685,7 +1657,7 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { } public ProcedureEntity(CAstNode pdast, TypeSystem system, CodeInstance pd, String[] argumentNames, - Map entities, MethodContext mc) { + Map> entities, MethodContext mc) { //PORT1.7 used to be this(pdast, system, pd, ((MemberInstance) pd).container(), argumentNames, entities, mc); this(pdast, system, pd, ((MemberDef) pd.def()).container().get(), argumentNames, entities, mc); } @@ -1916,21 +1888,9 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { } } - public interface WalkContext { - void addScopedEntity(CAstNode node, CAstEntity e); - - CAstControlFlowRecorder cfg(); - - CAstSourcePositionRecorder pos(); - - CAstNodeTypeMapRecorder getNodeTypeMap(); - + public interface WalkContext extends TranslatorToCAst.WalkContext { Collection> getCatchTargets(Type label); - Node getContinueFor(String label); - - Node getBreakFor(String label); - Node getFinally(); CodeInstance getEnclosingMethod(); @@ -1948,49 +1908,15 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { boolean needLVal(); } - protected static class DelegatingContext implements WalkContext { - private final WalkContext parent; - - public WalkContext getParent() { - return parent; - } - + protected static class DelegatingContext extends TranslatorToCAst.DelegatingContext implements WalkContext { protected DelegatingContext(WalkContext parent) { - this.parent = parent; - } - - public void addScopedEntity(CAstNode node, CAstEntity e) { - parent.addScopedEntity(node, e); - } - - // public Map/**/ getScopedEntities() { - // return parent.getScopedEntities(); - // } - - public CAstControlFlowRecorder cfg() { - return parent.cfg(); - } - - public CAstSourcePositionRecorder pos() { - return parent.pos(); - } - - public CAstNodeTypeMapRecorder getNodeTypeMap() { - return parent.getNodeTypeMap(); + super(parent); } public Collection> getCatchTargets(Type label) { return parent.getCatchTargets(label); } - public Node getContinueFor(String label) { - return parent.getContinueFor(label); - } - - public Node getBreakFor(String label) { - return parent.getBreakFor(label); - } - public Node getFinally() { return parent.getFinally(); } @@ -2121,9 +2047,9 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { private final Map labelMap = HashMapFactory.make(2); - private final Map fEntities; + private final Map> fEntities; - public CodeBodyContext(WalkContext parent, Map entities) { + public CodeBodyContext(WalkContext parent, Map> entities) { super(parent); fEntities = entities; } @@ -2141,10 +2067,11 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { } public void addScopedEntity(CAstNode node, CAstEntity entity) { - fEntities.put(node, entity); + if (! fEntities.containsKey(node)) { fEntities.put(node, new HashSet(1)); } + fEntities.get(node).add(entity); } - public Map/* */ getScopedEntities() { + public Map> getScopedEntities() { return fEntities; } @@ -2160,7 +2087,7 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { public class MethodContext extends CodeBodyContext { final CodeInstance fPI; - public MethodContext(CodeInstance pi, Map entities, WalkContext parent) { + public MethodContext(CodeInstance pi, Map> entities, WalkContext parent) { super(parent, entities); fPI = pi; } @@ -2188,8 +2115,8 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { this.tryNode = tryNode; this.context = context; - for (Iterator catchIter = tryNode.catchBlocks().iterator(); catchIter.hasNext();) { - Catch c = (Catch) catchIter.next(); + for (Iterator catchIter = tryNode.catchBlocks().iterator(); catchIter.hasNext();) { + Catch c = catchIter.next(); Pair p = Pair.make(c.catchType(), (Object)c); fCatchNodes.add(p); @@ -2217,7 +2144,7 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { continue; } } - catchNodes.addAll(getParent().getCatchTargets(label)); + catchNodes.addAll(parent.getCatchTargets(label)); return catchNodes; } @@ -2230,53 +2157,23 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { } } - protected static class RootContext implements WalkContext { + protected static class RootContext extends TranslatorToCAst.RootContext implements WalkContext { final CAstTypeDictionary fTypeDict; public RootContext(CAstTypeDictionary typeDict) { fTypeDict = typeDict; } - public void addScopedEntity(CAstNode node, CAstEntity e) { - Assertions.UNREACHABLE("Attempt to call addScopedEntity() on a RootContext."); - } - - public CAstControlFlowRecorder cfg() { - Assertions.UNREACHABLE("RootContext.cfg()"); - return null; - } - public Collection> getCatchTargets(Type label) { Assertions.UNREACHABLE("RootContext.getCatchTargets()"); return null; } - public CAstNodeTypeMapRecorder getNodeTypeMap() { - Assertions.UNREACHABLE("RootContext.getNodeTypeMap()"); - return null; - } - public Node getFinally() { Assertions.UNREACHABLE("RootContext.getFinally()"); return null; } - public CAstSourcePositionRecorder pos() { - // No AST, so no AST map - Assertions.UNREACHABLE("RootContext.pos()"); - return null; - } - - public Node getContinueFor(String label) { - Assertions.UNREACHABLE("RootContext.getContinueFor()"); - return null; - } - - public Node getBreakFor(String label) { - Assertions.UNREACHABLE("RootContext.getBreakFor()"); - return null; - } - public CodeInstance getEnclosingMethod() { Assertions.UNREACHABLE("RootContext.getEnclosingMethod()"); return null; @@ -2360,12 +2257,13 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { } } - public PolyglotJava2CAstTranslator(ClassLoaderReference clr, NodeFactory nf, TypeSystem ts, PolyglotIdentityMapper identityMapper, boolean replicateForDoLoops) { + public PolyglotJava2CAstTranslator(Node ast, ClassLoaderReference clr, NodeFactory nf, TypeSystem ts, PolyglotIdentityMapper identityMapper, boolean replicateForDoLoops) { + this.ast = ast; fClassLoaderRef = clr; fTypeSystem = ts; fNodeFactory = nf; fIdentityMapper = identityMapper; - this.replicateForDoLoops = replicateForDoLoops; + doLoopTranslator = new DoLoopTranslator(replicateForDoLoops, fFactory); fNPEType = fTypeSystem.NullPointerException(); fCCEType = fTypeSystem.ClassCastException(); fREType = fTypeSystem.RuntimeException(); @@ -2530,8 +2428,8 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { return cn; } - public CAstEntity translate(Object ast, String fileName) { - return walkEntity((Node) ast, new RootContext(getTypeDict())); + public CAstEntity translateToCAst() { + return walkEntity(ast, new RootContext(getTypeDict())); } /** @@ -2623,7 +2521,7 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { InitializerDef initDef = fTypeSystem.initializerDef(n.position(), Types.ref(classType), Flags.STATIC); InitializerInstance initInstance = fTypeSystem.createInitializerInstance(n.position(), Types.ref(initDef)); - Map childEntities = HashMapFactory.make(); + Map> childEntities = HashMapFactory.make(); final MethodContext mc = new MethodContext(initInstance, childEntities, classContext); List inits = classContext.getStaticInitializers(); @@ -2644,7 +2542,7 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { for (Iterator iter = superConstructors.iterator(); iter.hasNext();) { ConstructorInstance superCtor = (ConstructorInstance) iter.next(); - Map childEntities = HashMapFactory.make(); + Map> childEntities = HashMapFactory.make(); final MethodContext mc = new MethodContext(superCtor, childEntities, classContext); String[] fakeArguments = new String[superCtor.formalTypes().size() + 1]; @@ -2713,7 +2611,7 @@ public class PolyglotJava2CAstTranslator implements TranslatorToCAst { return new ClassEntity(classContext, memberEntities, anonType, anonTypeName, n.position()); } else if (rootNode instanceof ProcedureDecl) { final ProcedureDecl pd = (ProcedureDecl) rootNode; - final Map memberEntities = new LinkedHashMap(); + final Map> memberEntities = HashMapFactory.make(); final MethodContext mc = new MethodContext(pd.procedureInstance().asInstance(), memberEntities, context); CAstNode pdAST = null; diff --git a/com.ibm.wala.cast.java.test.data/.gitignore b/com.ibm.wala.cast.java.test.data/.gitignore new file mode 100644 index 000000000..3a279a54f --- /dev/null +++ b/com.ibm.wala.cast.java.test.data/.gitignore @@ -0,0 +1,103 @@ +/p +/A.class +/AnonymousClass.class +/AnonymousClass.java +/AnonymousClass$1.class +/AnonymousClass$1FooImpl.class +/AnonymousClass$2.class +/AnonymousClass$Foo.class +/Array1.class +/Array1.java +/ArrayLiteral1.class +/ArrayLiteral1.java +/ArrayLiteral2.class +/ArrayLiteral2.java +/B.class +/BadLanguageExceptionEx1.class +/BadLanguageExceptionF1.class +/Bar.class +/Base.class +/Breaks.class +/Breaks.java +/Breaks$1.class +/Breaks$Ref.class +/CastFromNull.class +/CastFromNull.java +/Casts.class +/Casts.java +/Derived.class +/Exception1.class +/Exception1.java +/Exception2.class +/Exception2.java +/Finally1.class +/Finally1.java +/FooEx1.class +/FooEx2.class +/FooF1.class +/FooIT1.class +/FooQ.class +/IFoo.class +/Inheritance1.class +/Inheritance1.java +/InheritedField.class +/InheritedField.java +/InnerClass.class +/InnerClass.java +/InnerClass$WhatsIt.class +/InnerClass$WhatsIt$NotAgain.class +/InnerClass$WhatsThat.class +/InnerClassA.class +/InnerClassA.java +/InnerClassA$AA.class +/InnerClassA$AB.class +/InnerClassA$AB$ABA.class +/InnerClassA$AB$ABA$ABAA.class +/InnerClassA$AB$ABA$ABAB.class +/InnerClassA$AB$ABSubA.class +/InnerClassA$AB$ABSubA$ABSubAA.class +/InnerClassSuper.class +/InnerClassSuper.java +/InnerClassSuper$SuperOuter.class +/InterfaceTest1.class +/InterfaceTest1.java +/IntWrapper.class +/LocalClass.class +/LocalClass.java +/LocalClass$1Foo.class +/LocalClass$2Foo.class +/MiniaturList.class +/MiniaturList.java +/MiniaturSliceBug.class +/MiniaturSliceBug.java +/Monitor.class +/Monitor.java +/NullArrayInit.class +/NullArrayInit.java +/PrimitiveWrapper.class +/QualifiedStatic.class +/QualifiedStatic.java +/R.class +/Scoping1.class +/Scoping1.java +/Scoping2.class +/Scoping2.java +/Scoping2$1.class +/Simple1.class +/Simple1.java +/StaticInitializers.class +/StaticInitializers.java +/StaticInitializers$X.class +/StaticNesting.class +/StaticNesting.java +/StaticNesting$WhatsIt.class +/Sub.class +/Sub$SubInner.class +/Switch1.class +/Switch1.java +/Thread1.class +/Thread1.java +/TwoClasses.class +/TwoClasses.java +/WhileTest1.class +/WhileTest1.java diff --git a/com.ibm.wala.cast.java.test.data/build.xml b/com.ibm.wala.cast.java.test.data/build.xml index f85fb608d..1551c115a 100644 --- a/com.ibm.wala.cast.java.test.data/build.xml +++ b/com.ibm.wala.cast.java.test.data/build.xml @@ -1,70 +1,89 @@ - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/examples/ast/SynchronizedBlockDuplicator.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/examples/ast/SynchronizedBlockDuplicator.java index 06c07d8b2..27a628bc5 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/examples/ast/SynchronizedBlockDuplicator.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/examples/ast/SynchronizedBlockDuplicator.java @@ -186,7 +186,7 @@ public class SynchronizedBlockDuplicator extends return null; } - protected CAstNode copyNodes(CAstNode n, RewriteContext c, Map, CAstNode> nodeMap) { + protected CAstNode copyNodes(CAstNode n, final CAstControlFlowMap cfg, RewriteContext c, Map, CAstNode> nodeMap) { String varName; // don't copy operators or constants (presumably since they are immutable?) if (n instanceof CAstOperator) { @@ -204,15 +204,15 @@ public class SynchronizedBlockDuplicator extends Ast.makeNode(CAstNode.VAR, Ast.makeConstant(varName))); // the new if conditional - return Ast.makeNode(CAstNode.IF_STMT, test, copyNodes(n, new SyncContext(true, n, c), nodeMap), - copyNodes(n, new SyncContext(false, n, c), nodeMap)); + return Ast.makeNode(CAstNode.IF_STMT, test, copyNodes(n, cfg, new SyncContext(true, n, c), nodeMap), + copyNodes(n, cfg, new SyncContext(false, n, c), nodeMap)); } else { // invoke copyNodes() on the children with context c, ensuring, e.g., that // the body of a synchronized block gets cloned CAstNode[] newChildren = new CAstNode[n.getChildCount()]; for (int i = 0; i < newChildren.length; i++) - newChildren[i] = copyNodes(n.getChild(i), c, nodeMap); + newChildren[i] = copyNodes(n.getChild(i), cfg, c, nodeMap); CAstNode newN = Ast.makeNode(n.getKind(), newChildren); diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaSSAPropagationCallGraphBuilder.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaSSAPropagationCallGraphBuilder.java index 1a29296f4..1c4963bca 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaSSAPropagationCallGraphBuilder.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaSSAPropagationCallGraphBuilder.java @@ -272,7 +272,7 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall } public void visitJavaInvoke(AstJavaInvokeInstruction instruction) { - visitInvokeInternal(instruction); + visitInvokeInternal(instruction, new DefaultInvariantComputer()); } } 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 1398a36a5..2d11c037f 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 @@ -10,21 +10,26 @@ *****************************************************************************/ package com.ibm.wala.cast.java.ipa.callgraph; +import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import java.util.Set; import com.ibm.wala.cast.ipa.callgraph.ScopeMappingInstanceKeys; +import com.ibm.wala.cast.ipa.callgraph.ScopeMappingInstanceKeys.ScopeMappingInstanceKey; 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.LexicalParent; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; +import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; import com.ibm.wala.ipa.callgraph.propagation.InstanceKeyFactory; import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.util.collections.HashSetFactory; +import com.ibm.wala.util.collections.Pair; public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys { @@ -75,4 +80,11 @@ public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys { return result; } + + @Override + protected Collection getConstructorCallers(ScopeMappingInstanceKey smik, Pair name) { + // for Java, the creator node is exactly what we want + return Collections.singleton(smik.getCreator()); + } + } diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/Java2IRTranslator.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/Java2IRTranslator.java index 3a60728ed..0dd6ae558 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/Java2IRTranslator.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/Java2IRTranslator.java @@ -15,6 +15,7 @@ package com.ibm.wala.cast.java.translator; import java.io.PrintWriter; +import com.ibm.wala.cast.ir.translator.TranslatorToCAst; import com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl; import com.ibm.wala.cast.tree.CAst; import com.ibm.wala.cast.tree.CAstEntity; @@ -29,34 +30,29 @@ public class Java2IRTranslator { protected final JavaSourceLoaderImpl fLoader; - protected final TranslatorToCAst fSourceTranslator; - CAstRewriterFactory castRewriterFactory = null; - public Java2IRTranslator(TranslatorToCAst sourceTranslator, JavaSourceLoaderImpl srcLoader) { - this(sourceTranslator, srcLoader, false); + public Java2IRTranslator(JavaSourceLoaderImpl srcLoader) { + this(srcLoader, false); } - public Java2IRTranslator(TranslatorToCAst sourceTranslator, JavaSourceLoaderImpl srcLoader, boolean debug) { - this(sourceTranslator, srcLoader, null, debug); + public Java2IRTranslator(JavaSourceLoaderImpl srcLoader, boolean debug) { + this(srcLoader, null, debug); } - public Java2IRTranslator(TranslatorToCAst sourceTranslator, JavaSourceLoaderImpl srcLoader, + public Java2IRTranslator(JavaSourceLoaderImpl srcLoader, CAstRewriterFactory castRewriterFactory) { - this(sourceTranslator, srcLoader, castRewriterFactory, false); + this(srcLoader, castRewriterFactory, false); } - public Java2IRTranslator(TranslatorToCAst sourceTranslator, JavaSourceLoaderImpl srcLoader, + public Java2IRTranslator(JavaSourceLoaderImpl srcLoader, CAstRewriterFactory castRewriterFactory, boolean debug) { DEBUG = debug; fLoader = srcLoader; - fSourceTranslator = sourceTranslator; this.castRewriterFactory = castRewriterFactory; } - public void translate(ModuleEntry module, Object ast, String N) { - CAstEntity ce = fSourceTranslator.translate(ast, N); - + public void translate(ModuleEntry module, CAstEntity ce) { if (DEBUG) { PrintWriter printWriter = new PrintWriter(System.out); CAstPrinter.printTo(ce, printWriter); 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 223e3e96c..a2f721d29 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 @@ -304,26 +304,24 @@ public class JavaCAst2IRTranslator extends AstTranslator { return ((JavaSourceLoaderImpl) loader).defineType(type, type.getType().getName(), parentType) != null; } - protected void leaveThis(CAstNode n, Context c, CAstVisitor visitor) { + protected void leaveThis(CAstNode n, WalkContext c, CAstVisitor visitor) { if (n.getChildCount() == 0) { super.leaveThis(n, c, visitor); } else { - WalkContext wc = (WalkContext) c; - int result = wc.currentScope().allocateTempValue(); - setValue(n, result); - wc.cfg().addInstruction(new EnclosingObjectReference(result, (TypeReference) n.getChild(0).getValue())); + int result = c.currentScope().allocateTempValue(); + c.setValue(n, result); + c.cfg().addInstruction(new EnclosingObjectReference(result, (TypeReference) n.getChild(0).getValue())); } } - protected boolean visitCast(CAstNode n, Context c, CAstVisitor visitor) { - WalkContext context = (WalkContext)c; + protected boolean visitCast(CAstNode n, WalkContext context, CAstVisitor visitor) { int result = context.currentScope().allocateTempValue(); - setValue(n, result); + context.setValue(n, result); return false; } - protected void leaveCast(CAstNode n, Context c, CAstVisitor visitor) { - WalkContext context = (WalkContext)c; - int result = getValue(n); + + protected void leaveCast(CAstNode n, WalkContext context, CAstVisitor visitor) { + int result = context.getValue(n); CAstType toType = (CAstType) n.getChild(0).getValue(); TypeReference toRef = makeType(toType); @@ -334,7 +332,7 @@ public class JavaCAst2IRTranslator extends AstTranslator { context.cfg().addInstruction( insts.ConversionInstruction( result, - getValue(n.getChild(1)), + context.getValue(n.getChild(1)), fromRef, toRef, false)); @@ -343,43 +341,42 @@ public class JavaCAst2IRTranslator extends AstTranslator { context.cfg().addInstruction( insts.CheckCastInstruction( result, - getValue(n.getChild(1)), + context.getValue(n.getChild(1)), toRef, true)); processExceptions(n, context); } } - protected boolean visitInstanceOf(CAstNode n, Context c, CAstVisitor visitor) { - WalkContext context = (WalkContext)c; + + protected boolean visitInstanceOf(CAstNode n, WalkContext context, CAstVisitor visitor) { int result = context.currentScope().allocateTempValue(); - setValue(n, result); + context.setValue(n, result); return false; } - protected void leaveInstanceOf(CAstNode n, Context c, CAstVisitor visitor) { - WalkContext context = (WalkContext)c; - int result = getValue(n); + + protected void leaveInstanceOf(CAstNode n, WalkContext context, CAstVisitor visitor) { + int result = context.getValue(n); CAstType type = (CAstType) n.getChild(0).getValue(); TypeReference ref = makeType( type ); context.cfg().addInstruction( insts.InstanceofInstruction( result, - getValue(n.getChild(1)), + context.getValue(n.getChild(1)), ref)); } - protected boolean doVisit(CAstNode n, Context context, CAstVisitor visitor) { - WalkContext wc = (WalkContext) context; + protected boolean doVisit(CAstNode n, WalkContext wc, CAstVisitor visitor) { if (n.getKind() == CAstNode.MONITOR_ENTER) { visitor.visit(n.getChild(0), wc, visitor); - wc.cfg().addInstruction(insts.MonitorInstruction(getValue(n.getChild(0)), true)); + wc.cfg().addInstruction(insts.MonitorInstruction(wc.getValue(n.getChild(0)), true)); processExceptions(n, wc); return true; } else if (n.getKind() == CAstNode.MONITOR_EXIT) { visitor.visit(n.getChild(0), wc, visitor); - wc.cfg().addInstruction(insts.MonitorInstruction(getValue(n.getChild(0)), false)); + wc.cfg().addInstruction(insts.MonitorInstruction(wc.getValue(n.getChild(0)), false)); processExceptions(n, wc); return true; } else { @@ -387,4 +384,6 @@ processExceptions(n, context); } } + + } diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/TranslatorToCAst.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/TranslatorToCAst.java deleted file mode 100644 index 5218c8e05..000000000 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/TranslatorToCAst.java +++ /dev/null @@ -1,19 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2002 - 2006 IBM Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *****************************************************************************/ -package com.ibm.wala.cast.java.translator; - -import com.ibm.wala.cast.tree.CAstEntity; - -public interface TranslatorToCAst { - - public CAstEntity translate(Object astRoot, String unitName); - -} diff --git a/com.ibm.wala.cast.js.html.nu_validator/.classpath b/com.ibm.wala.cast.js.html.nu_validator/.classpath index abd692151..9950a85d6 100644 --- a/com.ibm.wala.cast.js.html.nu_validator/.classpath +++ b/com.ibm.wala.cast.js.html.nu_validator/.classpath @@ -2,8 +2,8 @@ - - + + diff --git a/com.ibm.wala.cast.js.html.nu_validator/META-INF/MANIFEST.MF b/com.ibm.wala.cast.js.html.nu_validator/META-INF/MANIFEST.MF index 5503cf8b1..f86d202dd 100644 --- a/com.ibm.wala.cast.js.html.nu_validator/META-INF/MANIFEST.MF +++ b/com.ibm.wala.cast.js.html.nu_validator/META-INF/MANIFEST.MF @@ -8,5 +8,7 @@ Require-Bundle: com.ibm.wala.cast.js;bundle-version="1.0.0", com.ibm.wala.cast.js.rhino.test;bundle-version="1.0.0", com.ibm.wala.cast.js.test;bundle-version="1.0.0", com.ibm.wala.cast.test;bundle-version="1.0.0", + com.ibm.wala.cast;bundle-version="1.0.0", com.ibm.wala.core.tests;bundle-version="1.1.3", - com.ibm.wala.core;bundle-version="1.1.3" + com.ibm.wala.core;bundle-version="1.1.3", + org.junit;bundle-version="4.8.1" diff --git a/com.ibm.wala.cast.js.html.nu_validator/src/com/ibm/wala/cast/js/html/nu_validator/NuValidatorHtmlParser.java b/com.ibm.wala.cast.js.html.nu_validator/src/com/ibm/wala/cast/js/html/nu_validator/NuValidatorHtmlParser.java index 0a7749a96..2a5aef99f 100644 --- a/com.ibm.wala.cast.js.html.nu_validator/src/com/ibm/wala/cast/js/html/nu_validator/NuValidatorHtmlParser.java +++ b/com.ibm.wala.cast.js.html.nu_validator/src/com/ibm/wala/cast/js/html/nu_validator/NuValidatorHtmlParser.java @@ -14,6 +14,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.LineNumberReader; import java.io.StringReader; +import java.net.MalformedURLException; +import java.net.URL; import java.util.AbstractMap; import java.util.HashSet; import java.util.Map; @@ -32,10 +34,21 @@ import org.xml.sax.SAXException; import com.ibm.wala.cast.js.html.IHtmlCallback; import com.ibm.wala.cast.js.html.IHtmlParser; import com.ibm.wala.cast.js.html.ITag; +import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position; +import com.ibm.wala.cast.tree.impl.LineNumberPosition; +import com.ibm.wala.util.collections.Pair; public class NuValidatorHtmlParser implements IHtmlParser { - public void parse(final InputStream reader, final IHtmlCallback handler, String fileName) { + public void parse(final URL url, final InputStream reader, final IHtmlCallback handler, final String fileName) { + URL xx = null; + try { + xx = new URL("file://" + fileName); + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + final URL localFileName = xx; + HtmlParser parser = new HtmlParser(); parser.setXmlPolicy(XmlViolationPolicy.ALLOW); parser.setContentHandler(new ContentHandler() { @@ -57,38 +70,46 @@ public class NuValidatorHtmlParser implements IHtmlParser { } public void startElement(String uri, final String localName, String qName, final Attributes atts) throws SAXException { - final int line = locator.getLineNumber(); + final Position line = new LineNumberPosition(url, localFileName, locator.getLineNumber()); tags.push(new ITag() { public String getName() { return localName; } - public String getAttributeByName(String name) { - return atts.getValue(name); + public Pair getAttributeByName(String name) { + if (atts.getValue(name) != null) { + return Pair.make(atts.getValue(name), line); + } else { + return null; + } } - public Map getAllAttributes() { - return new AbstractMap() { - private Set> es = null; + public Map> getAllAttributes() { + return new AbstractMap>() { + private Set>> es = null; @Override - public Set> entrySet() { + public Set>> entrySet() { if (es == null) { - es = new HashSet>(); + es = new HashSet>>(); for(int i = 0; i < atts.getLength(); i++) { final int index = i; - es.add(new Map.Entry() { + es.add(new Map.Entry>() { public String getKey() { - return atts.getLocalName(index); + return atts.getLocalName(index).toLowerCase(); } - public String getValue() { - return atts.getValue(index); + public Pair getValue() { + if (atts.getValue(index) != null) { + return Pair.make(atts.getValue(index), line); + } else { + return null; + } } - public String setValue(String value) { + public Pair setValue(Pair value) { throw new UnsupportedOperationException(); } }); @@ -99,10 +120,15 @@ public class NuValidatorHtmlParser implements IHtmlParser { }; } - public int getStartingLineNum() { + public Position getElementPosition() { return line; } + + public Position getContentPosition() { + return line; + } }); + handler.handleStartTag(tags.peek()); } @@ -111,11 +137,11 @@ public class NuValidatorHtmlParser implements IHtmlParser { } public void characters(char[] ch, int start, int length) throws SAXException { - handler.handleText(locator.getLineNumber() - countLines(ch, start, length), new String(ch, start, length)); + handler.handleText(new LineNumberPosition(url, localFileName, locator.getLineNumber() - countLines(ch, start, length)), new String(ch, start, length)); } public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { - handler.handleText(locator.getLineNumber(), new String(ch, start, length)); + handler.handleText(new LineNumberPosition(url, localFileName, locator.getLineNumber()), new String(ch, start, length)); } public void startDocument() throws SAXException { diff --git a/com.ibm.wala.cast.js.rhino.test/.classpath b/com.ibm.wala.cast.js.rhino.test/.classpath index 54426554b..dfd67a548 100644 --- a/com.ibm.wala.cast.js.rhino.test/.classpath +++ b/com.ibm.wala.cast.js.rhino.test/.classpath @@ -1,6 +1,6 @@ - + diff --git a/com.ibm.wala.cast.js.rhino.test/.gitignore b/com.ibm.wala.cast.js.rhino.test/.gitignore new file mode 100644 index 000000000..689a85716 --- /dev/null +++ b/com.ibm.wala.cast.js.rhino.test/.gitignore @@ -0,0 +1,17 @@ +/apollo-example.html +/crawl.html +/iframeTest2.html +/list.html +/nojs.html +/page1.html +/page11.html +/page11b.html +/page12.html +/page13.html +/page15.html +/page16.html +/page17.html +/page2.html +/page3.html +/page4.html +/windowx.html diff --git a/com.ibm.wala.cast.js.rhino.test/META-INF/MANIFEST.MF b/com.ibm.wala.cast.js.rhino.test/META-INF/MANIFEST.MF index a29cbbf82..8b7eefa49 100644 --- a/com.ibm.wala.cast.js.rhino.test/META-INF/MANIFEST.MF +++ b/com.ibm.wala.cast.js.rhino.test/META-INF/MANIFEST.MF @@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.core.runtime, com.ibm.wala.cast.js.test;bundle-version="1.0.0", com.ibm.wala.cast.test;bundle-version="1.0.0", com.ibm.wala.core.tests;bundle-version="1.1.3", - org.junit4;bundle-version="4.3.1" + org.junit4;bundle-version="4.3.1", + com.ibm.wala.ide;bundle-version="1.1.3" Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Export-Package: com.ibm.wala.cast.js.test diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java new file mode 100644 index 000000000..7b89b50d7 --- /dev/null +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/rhino/test/HTMLCGBuilder.java @@ -0,0 +1,206 @@ +/******************************************************************************* + * Copyright (c) 2002 - 2006 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package com.ibm.wala.cast.js.rhino.test; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Properties; + +import junit.framework.Assert; + +import org.eclipse.core.runtime.NullProgressMonitor; + +import com.ibm.wala.cast.ir.translator.AstTranslator; +import com.ibm.wala.cast.js.ipa.callgraph.ForInContextSelector; +import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder; +import com.ibm.wala.cast.js.ipa.callgraph.JavaScriptFunctionDotCallTargetSelector; +import com.ibm.wala.cast.js.ipa.callgraph.RecursionCheckContextSelector; +import com.ibm.wala.cast.js.ipa.callgraph.correlations.extraction.CorrelatedPairExtractorFactory; +import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil; +import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil.CGBuilderType; +import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; +import com.ibm.wala.ide.util.ProgressMaster; +import com.ibm.wala.ide.util.ProgressMonitorDelegate; +import com.ibm.wala.ipa.callgraph.CGNode; +import com.ibm.wala.ipa.callgraph.CallGraph; +import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException; +import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis; +import com.ibm.wala.ipa.cha.ClassHierarchyException; +import com.ibm.wala.util.collections.Iterator2Iterable; +import com.ibm.wala.util.io.CommandLine; +import com.ibm.wala.util.io.FileProvider; + +/** + * Utility class for building call graphs of HTML pages. + * + * @author mschaefer + * + */ +public class HTMLCGBuilder { + public static final int DEFAULT_TIMEOUT = 120; + + /** + * Simple struct-like type to hold results of call graph construction. + * + * @author mschaefer + * + */ + public static class CGBuilderResult { + /** time it took to build the call graph; {@code -1} if timeout occurred */ + public long construction_time; + + /** builder responsible for building the call graph*/ + public JSCFABuilder builder; + + /** pointer analysis results; partial if {@link #construction_time} is {@code -1} */ + public PointerAnalysis pa; + + /** call graph; partial if {@link #construction_time} is {@code -1} */ + public CallGraph cg; + } + + /** + * Build a call graph for an HTML page, optionally with a timeout. + * + * @param src + * the HTML page to analyse, can either be a path to a local file or a URL + * @param timeout + * analysis timeout in seconds, -1 means no timeout + * @param automated_extraction + * whether to automatically extract correlated pairs + * @throws IOException + * @throws ClassHierarchyException + */ + public static CGBuilderResult buildHTMLCG(String src, int timeout, boolean automated_extraction, CGBuilderType builderType) + throws ClassHierarchyException, IOException { + CGBuilderResult res = new CGBuilderResult(); + URL url = null; + try { + url = toUrl(src); + } catch (MalformedURLException e1) { + Assert.fail("Could not find page to analyse: " + src); + } + com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); + if(automated_extraction) + com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setPreprocessor(new CorrelatedPairExtractorFactory(new CAstRhinoTranslatorFactory(), url)); + JSCFABuilder builder = null; + try { + builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url, builderType); + builder.setContextSelector(new ForInContextSelector(2, builder.getContextSelector())); + builder.setContextSelector(new ForInContextSelector(3, builder.getContextSelector())); + // TODO we need to find a better way to do this ContextSelector delegation; + // the code below belongs somewhere else!!! + // the bound of 4 is what is needed to pass our current framework tests + if (AstTranslator.NEW_LEXICAL) { +// builder.setContextSelector(new RecursionBoundContextSelector(builder.getContextSelector(), 4)); + builder.setContextSelector(new RecursionCheckContextSelector(builder.getContextSelector())); + } + ProgressMaster master = ProgressMaster.make(new NullProgressMonitor()); + if (timeout > 0) { + master.setMillisPerWorkItem(timeout * 1000); + master.beginTask("runSolver", 1); + } + long start = System.currentTimeMillis(); + CallGraph cg = timeout > 0 ? builder.makeCallGraph(builder.getOptions(), + ProgressMonitorDelegate.createProgressMonitorDelegate(master)) : builder.makeCallGraph(builder.getOptions()); + long end = System.currentTimeMillis(); + master.done(); + res.construction_time = (end - start); + res.cg = cg; + res.pa = builder.getPointerAnalysis(); + res.builder = builder; + return res; + } catch (CallGraphBuilderCancelException e) { + res.construction_time = -1; + res.cg = e.getPartialCallGraph(); + res.pa = e.getPartialPointerAnalysis(); + res.builder = builder; + return res; + } catch (Exception e) { + throw new Error(e); + } + } + + private static URL toUrl(String src) throws MalformedURLException { + // first try interpreting as local file name, if that doesn't work just + // assume it's a URL + try { + File f = (new FileProvider()).getFileFromClassLoader(src, HTMLCGBuilder.class.getClassLoader()); + URL url = f.toURI().toURL(); + return url; + } catch (FileNotFoundException fnfe) { + return new URL(src); + } + } + + /** + * Usage: HTMLCGBuilder -src path_to_html_file -timeout timeout_in_seconds -reachable function_name + * timeout argument is optional and defaults to {@link #DEFAULT_TIMEOUT}. + * reachable argument is optional. if provided, and some reachable function name contains function_name, + * will print "REACHABLE" + * @throws IOException + * @throws ClassHierarchyException + * + */ + public static void main(String[] args) throws ClassHierarchyException, IOException { + Properties parsedArgs = CommandLine.parse(args); + String src = parsedArgs.getProperty("src"); + if (src == null) { + throw new IllegalArgumentException("-src argument is required"); + } + int timeout; + if (parsedArgs.containsKey("timeout")) { + timeout = Integer.parseInt(parsedArgs.getProperty("timeout")); + } else { + timeout = DEFAULT_TIMEOUT; + } + String reachableName = null; + if (parsedArgs.containsKey("reachable")) { + reachableName = parsedArgs.getProperty("reachable"); + } + + String srcNode = null, dstNode = null; + if (parsedArgs.containsKey("edgeExists")) { + String[] nodes = parsedArgs.getProperty("edgeExists").split(":"); + srcNode = nodes[0]; + dstNode = nodes[1]; + } + // suppress debug output + JavaScriptFunctionDotCallTargetSelector.WARN_ABOUT_IMPRECISE_CALLGRAPH = false; + CGBuilderResult res = buildHTMLCG(src, timeout, true, AstTranslator.NEW_LEXICAL ? CGBuilderType.ONE_CFA_PRECISE_LEXICAL : CGBuilderType.ZERO_ONE_CFA); + if(res.construction_time == -1) + System.out.println("TIMED OUT"); + else + System.out.println("Call graph construction took " + res.construction_time/1000.0 + " seconds"); + if (reachableName != null) { + for (CGNode node : res.cg) { + if (node.getMethod().getDeclaringClass().getName().toString().contains(reachableName)) { + System.out.println("REACHABLE"); + break; + } + } + } + if (srcNode != null) { + for (CGNode node : res.cg) { + if (node.getMethod().getDeclaringClass().getName().toString().endsWith(srcNode)) { + for (CGNode callee : Iterator2Iterable.make(res.cg.getSuccNodes(node))) { + if (callee.getMethod().getDeclaringClass().getName().toString().endsWith(dstNode)) { + System.out.println("EDGE EXISTS"); + } + } + } + } + } + } +} diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestAjaxsltCallGraphShapeRhino.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestAjaxsltCallGraphShapeRhino.java index 578a5840d..0e52c9ccf 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestAjaxsltCallGraphShapeRhino.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestAjaxsltCallGraphShapeRhino.java @@ -22,7 +22,7 @@ public class TestAjaxsltCallGraphShapeRhino extends TestAjaxsltCallGraphShape { @Before public void setUp() { - com.ibm.wala.cast.js.ipa.callgraph.Util.setTranslatorFactory(new CAstRhinoTranslatorFactory()); + com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); } diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestArgumentSensitivityRhino.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestArgumentSensitivityRhino.java new file mode 100644 index 000000000..b34cac1f8 --- /dev/null +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestArgumentSensitivityRhino.java @@ -0,0 +1,16 @@ +package com.ibm.wala.cast.js.test; + +import org.junit.Before; + +import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil; +import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; + +public class TestArgumentSensitivityRhino extends TestArgumentSensitivity { + + @Before + public void setUp() { + JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); + } + + +} diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestCorrelatedPairExtractionRhino.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestCorrelatedPairExtractionRhino.java index 9c79a5a7e..ba9575b6c 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestCorrelatedPairExtractionRhino.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestCorrelatedPairExtractionRhino.java @@ -15,10 +15,10 @@ import java.io.IOException; import com.ibm.wala.cast.js.ipa.callgraph.correlations.CorrelationFinder; import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; +import com.ibm.wala.cast.js.translator.RhinoToAstTranslator; import com.ibm.wala.cast.tree.CAstEntity; import com.ibm.wala.cast.tree.impl.CAstImpl; import com.ibm.wala.classLoader.SourceModule; -import org.mozilla.javascript.RhinoToAstTranslator; public class TestCorrelatedPairExtractionRhino extends TestCorrelatedPairExtraction { protected CorrelationFinder makeCorrelationFinder() { @@ -26,9 +26,8 @@ public class TestCorrelatedPairExtractionRhino extends TestCorrelatedPairExtract } protected CAstEntity parseJS(CAstImpl ast, SourceModule module) throws IOException { - RhinoToAstTranslator.resetGensymCounters(); - RhinoToAstTranslator translator = new RhinoToAstTranslator(ast, module, module.getName()); - CAstEntity entity = translator.translate(); + RhinoToAstTranslator translator = new RhinoToAstTranslator(ast, module, module.getName(), false); + CAstEntity entity = translator.translateToCAst(); return entity; } } diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestForInBodyExtractionRhino.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestForInBodyExtractionRhino.java index 661221223..13a401e4b 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestForInBodyExtractionRhino.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestForInBodyExtractionRhino.java @@ -13,17 +13,16 @@ package com.ibm.wala.cast.js.test; import java.io.IOException; -import org.mozilla.javascript.RhinoToAstTranslator; +import com.ibm.wala.cast.js.translator.RhinoToAstTranslator; import com.ibm.wala.cast.tree.CAstEntity; import com.ibm.wala.cast.tree.impl.CAstImpl; import com.ibm.wala.classLoader.SourceModule; public class TestForInBodyExtractionRhino extends TestForInBodyExtraction { protected CAstEntity parseJS(CAstImpl ast, SourceModule module) throws IOException { - RhinoToAstTranslator.resetGensymCounters(); - RhinoToAstTranslator translator = new RhinoToAstTranslator(ast, module, module.getName()); - CAstEntity entity = translator.translate(); + RhinoToAstTranslator translator = new RhinoToAstTranslator(ast, module, module.getName(), false); + CAstEntity entity = translator.translateToCAst(); return entity; } } diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestForInLoopHackRhino.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestForInLoopHackRhino.java index b7c2de1c8..f11827a1c 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestForInLoopHackRhino.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestForInLoopHackRhino.java @@ -8,7 +8,7 @@ public class TestForInLoopHackRhino extends TestForInLoopHack { @Before public void setUp() { - com.ibm.wala.cast.js.ipa.callgraph.Util.setTranslatorFactory(new CAstRhinoTranslatorFactory()); + com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); } } diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestJQueryExamplesRhino.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestJQueryExamplesRhino.java new file mode 100644 index 000000000..3df88afd2 --- /dev/null +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestJQueryExamplesRhino.java @@ -0,0 +1,19 @@ +package com.ibm.wala.cast.js.test; + +import org.junit.Before; + +import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil; +import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; + +public class TestJQueryExamplesRhino extends TestJQueryExamples { + + public static void main(String[] args) { + justThisTest(TestJQueryExamplesRhino.class); + } + + @Before + public void setUp() { + JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); + } + +} diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestMediawikiCallGraphShapeRhino.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestMediawikiCallGraphShapeRhino.java index 4db01aeb6..fb9d14596 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestMediawikiCallGraphShapeRhino.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestMediawikiCallGraphShapeRhino.java @@ -22,7 +22,7 @@ public class TestMediawikiCallGraphShapeRhino extends TestMediawikiCallGraphShap @Before public void setUp() { - com.ibm.wala.cast.js.ipa.callgraph.Util.setTranslatorFactory(new CAstRhinoTranslatorFactory()); + com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); } } diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestMozillaBugPagesRhino.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestMozillaBugPagesRhino.java index 1704ff458..fc9c7ab11 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestMozillaBugPagesRhino.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestMozillaBugPagesRhino.java @@ -12,7 +12,7 @@ public class TestMozillaBugPagesRhino extends TestMozillaBugPages { @Before public void setUp() { - com.ibm.wala.cast.js.ipa.callgraph.Util.setTranslatorFactory(new CAstRhinoTranslatorFactory()); + com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); } } diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestRhinoSourceMap.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestRhinoSourceMap.java new file mode 100644 index 000000000..dcbdd2fcb --- /dev/null +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestRhinoSourceMap.java @@ -0,0 +1,170 @@ +package com.ibm.wala.cast.js.test; + +import static com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.makeHierarchy; +import static com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.makeLoaders; +import static com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory; +import static com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil.makeScriptScope; + +import java.io.IOException; +import java.util.Map; + +import junit.framework.Assert; + +import org.junit.Before; +import org.junit.Test; + +import com.ibm.wala.cast.js.loader.JavaScriptLoaderFactory; +import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; +import com.ibm.wala.cast.loader.AstMethod; +import com.ibm.wala.cast.types.AstMethodReference; +import com.ibm.wala.cast.util.SourceBuffer; +import com.ibm.wala.classLoader.IClass; +import com.ibm.wala.ipa.callgraph.AnalysisScope; +import com.ibm.wala.ipa.cha.ClassHierarchyException; +import com.ibm.wala.ipa.cha.IClassHierarchy; +import com.ibm.wala.util.CancelException; +import com.ibm.wala.util.collections.HashMapFactory; + +public class TestRhinoSourceMap { + + @Before + public void setUp() { + setTranslatorFactory(new CAstRhinoTranslatorFactory()); + } + + private static final String[][] jquery_spec_testSource = new String[][]{ + new String[]{ + "Ltests/jquery_spec_test.js/anonymous__0/isEmptyDataObject", + "function isEmptyDataObject(obj) {\n" + +" for (var name in obj) {\n" + +" if (name !== \"toJSON\") {\n" + +" return false;\n" + +" }\n" + +" }\n" + +" return true;\n" + +" }" + }, + new String[]{ + "Ltests/jquery_spec_test.js/anonymous__0/anonymous__59/anonymous__62/anonymous__63/anonymous__64/anonymous__65", + "function anonymous__65() {\n" + +" returned = fn.apply(this, arguments);\n" + +" if (returned && jQuery.isFunction(returned.promise)) {\n" + +" returned.promise().then(newDefer.resolve, newDefer.reject);\n" + +" } else {\n" + +" newDefer[action](returned);\n" + +" }\n" + +" }" + }, + new String[]{ + "Ltests/jquery_spec_test.js/anonymous__0/anonymous__386/anonymous__392", + "function anonymous__392(map) {\n" + +" if (map) {\n" + +" var tmp;\n" + +" if (state < 2) {\n" + +" for (tmp in map) {\n" + +" statusCode[tmp] = [ statusCode[tmp], map[tmp] ];\n" + +" }\n" + +" } else {\n" + +" tmp = map[jqXHR.status];\n" + +" jqXHR.then(tmp, tmp);\n" + +" }\n" + +" }\n" + +" return this;\n" + +" }" + }, + new String[]{ + "Ltests/jquery_spec_test.js/anonymous__0/getWindow", + "function getWindow(elem) {\n" + +" return jQuery.isWindow(elem) ? elem : elem.nodeType === 9 ? elem.defaultView || elem.parentWindow : false;\n" + +" }" + }, + new String[]{ + "Ltests/jquery_spec_test.js/anonymous__0/anonymous__1/anonymous__7", + "function anonymous__7(elems, name, selector) {\n" + +" var ret = this.constructor();\n" + +" if (jQuery.isArray(elems)) {\n" + +" push.apply(ret, elems);\n" + +" } else {\n" + +" jQuery.merge(ret, elems);\n" + +" }\n" + +" ret.prevObject = this;\n" + +" ret.context = this.context;\n" + +" if (name === \"find\") {\n" + +" ret.selector = this.selector + (this.selector ? \" \" : \"\") + selector;\n" + +" } else if (name) {\n" + +" ret.selector = this.selector + \".\" + name + \"(\" + selector + \")\";\n" + +" }\n" + +" return ret;\n" + +" }" + }, + new String[]{ + "Ltests/jquery_spec_test.js/anonymous__0/anonymous__1/anonymous__17", + "function anonymous__17() {\n" + +" var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false;\n" + +" if (typeof target === \"boolean\") {\n" + +" deep = target;\n" + +" target = arguments[1] || {};\n" + +" i = 2;\n" + +" }\n" + +" if (typeof target !== \"object\" && !jQuery.isFunction(target)) {\n" + +" target = {};\n" + +" }\n" + +" if (length === i) {\n" + +" target = this;\n" + +" --i;\n" + +" }\n" + +" for (; i < length; i++) {\n" + +" if ((options = arguments[i]) != null) {\n" + +" for (name in options) {\n" + +" (function _forin_body_extra_1(name) { var src = target[name];\n" + +" var copy = options[name];\n" + +" if (target === copy) {\n" + +" return; //continue;\n" + +" }\n" + +" if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) {\n" + +" if (copyIsArray) {\n" + +" copyIsArray = false;\n" + +" clone = src && jQuery.isArray(src) ? src : [];\n" + +" } else {\n" + +" clone = src && jQuery.isPlainObject(src) ? src : {};\n" + +" }\n" + +" target[name] = jQuery.extend(deep, clone, copy);\n" + +" } else if (copy !== undefined) {\n" + +" target[name] = copy;\n" + +" } })(name);\n" + +" }\n" + +" }\n" + +" }\n" + +" return target;\n" + +" }"} + }; + + @Test + public void testJquerySpecTestSourceMappings() throws IllegalArgumentException, IOException, CancelException, ClassHierarchyException { + checkFunctionBodies("jquery_spec_test.js", jquery_spec_testSource); + } + + private void checkFunctionBodies(String fileName, String[][] assertions) throws IOException, ClassHierarchyException { + Map sources = HashMapFactory.make(); + for(String[] assertion : assertions) { + sources.put(assertion[0], assertion[1]); + } + + JavaScriptLoaderFactory loaders = makeLoaders(); + AnalysisScope scope = makeScriptScope("tests", fileName, loaders); + IClassHierarchy cha = makeHierarchy(scope, loaders); + for(IClass cls : cha) { + if (cls.getName().toString().contains(fileName)) { + AstMethod fun = (AstMethod)cls.getMethod(AstMethodReference.fnSelector); + //System.err.println(fun.getDeclaringClass().getName() + " " + fun.getSourcePosition()); + SourceBuffer sb = new SourceBuffer(fun.getSourcePosition()); + //System.err.println(sb); + if (sources.containsKey(fun.getDeclaringClass().getName().toString())) { + System.err.println("checking source of " + fun.getDeclaringClass().getName() + " at " + fun.getSourcePosition()); + Assert.assertEquals(sources.get(fun.getDeclaringClass().getName().toString()), sb.toString()); + } + } + } + } + +} diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimpleCallGraphShapeRhino.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimpleCallGraphShapeRhino.java index e106a04ef..2b71f159e 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimpleCallGraphShapeRhino.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimpleCallGraphShapeRhino.java @@ -28,12 +28,12 @@ public class TestSimpleCallGraphShapeRhino extends TestSimpleCallGraphShape { @Before public void setUp() { - com.ibm.wala.cast.js.ipa.callgraph.Util.setTranslatorFactory(new CAstRhinoTranslatorFactory()); + com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); } @Test public void test214631() throws IOException, IllegalArgumentException, CancelException { - JSCFABuilder b = Util.makeScriptCGBuilder("tests", "214631.js"); + JSCFABuilder b = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "214631.js"); b.makeCallGraph(b.getOptions()); PointerAnalysis PA = b.getPointerAnalysis(); // just make sure this does not crash @@ -42,22 +42,27 @@ public class TestSimpleCallGraphShapeRhino extends TestSimpleCallGraphShape { @Test public void testRewriterDoesNotChangeLablesBug() throws IOException, IllegalArgumentException, CancelException { - Util.makeScriptCG("tests", "rewrite_does_not_change_lables_bug.js"); + JSCallGraphBuilderUtil.makeScriptCG("tests", "rewrite_does_not_change_lables_bug.js"); // all we need is for it to finish building CG successfully. } @Test public void testRepr() throws IllegalArgumentException, IOException, CancelException { - Util.makeScriptCG("tests", "repr.js"); + JSCallGraphBuilderUtil.makeScriptCG("tests", "repr.js"); } @Test public void testTranslateToCAstCrash1() throws IllegalArgumentException, IOException, CancelException { - Util.makeScriptCG("tests", "rhino_crash1.js"); + JSCallGraphBuilderUtil.makeScriptCG("tests", "rhino_crash1.js"); } @Test public void testTranslateToCAstCrash2() throws IllegalArgumentException, IOException, CancelException { - Util.makeScriptCG("tests", "rhino_crash2.js"); + JSCallGraphBuilderUtil.makeScriptCG("tests", "rhino_crash2.js"); + } + + @Test + public void testTranslateToCAstCrash3() throws IllegalArgumentException, IOException, CancelException { + JSCallGraphBuilderUtil.makeScriptCG("tests", "rhino_crash3.js"); } } diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShapeRhino.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShapeRhino.java index 47cdabd27..f25365df6 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShapeRhino.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShapeRhino.java @@ -32,7 +32,7 @@ public abstract class TestSimplePageCallGraphShapeRhino extends TestSimplePageCa @Test public void testPage3() throws IOException, IllegalArgumentException, CancelException { URL url = getClass().getClassLoader().getResource("pages/page3.html"); - CallGraph CG = Util.makeHTMLCG(url); + CallGraph CG = JSCallGraphBuilderUtil.makeHTMLCG(url); verifyGraphAssertions(CG, assertionsForPage3); } @@ -44,7 +44,7 @@ public abstract class TestSimplePageCallGraphShapeRhino extends TestSimplePageCa @Before public void setUp() { - com.ibm.wala.cast.js.ipa.callgraph.Util.setTranslatorFactory(new CAstRhinoTranslatorFactory()); + com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); WebUtil.setFactory(new IHtmlParserFactory() { public IHtmlParser getParser() { return TestSimplePageCallGraphShapeRhino.this.getParser(); diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShapeRhinoJericho.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShapeRhinoJericho.java index 4e073940a..8e1744298 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShapeRhinoJericho.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimplePageCallGraphShapeRhinoJericho.java @@ -15,7 +15,7 @@ public class TestSimplePageCallGraphShapeRhinoJericho extends TestSimplePageCall @Test public void testCrawl() throws IOException, IllegalArgumentException, CancelException { URL url = getClass().getClassLoader().getResource("pages/crawl.html"); - CallGraph CG = Util.makeHTMLCG(url); + CallGraph CG = JSCallGraphBuilderUtil.makeHTMLCG(url); verifyGraphAssertions(CG, null); } diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java index 64ecc1daa..b295927c7 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.net.URL; import java.util.Set; +import com.ibm.wala.cast.ir.ssa.AstIRFactory; import com.ibm.wala.cast.js.html.DefaultSourceExtractor; import com.ibm.wala.cast.js.html.DomLessSourceExtractor; import com.ibm.wala.cast.js.html.IdentityUrlResolver; @@ -14,7 +15,7 @@ import com.ibm.wala.cast.js.html.WebUtil; import com.ibm.wala.cast.js.html.jericho.JerichoHtmlParser; import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder; import com.ibm.wala.cast.js.loader.JavaScriptLoader; -import com.ibm.wala.cast.js.test.Util; +import com.ibm.wala.cast.js.test.JSCallGraphBuilderUtil; import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory; import com.ibm.wala.classLoader.SourceFileModule; import com.ibm.wala.classLoader.SourceModule; @@ -23,7 +24,7 @@ import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis; import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.util.CancelException; -public class JsViewerDriver extends Util { +public class JsViewerDriver extends JSCallGraphBuilderUtil { public static void main(String args[]) throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException { if (args.length != 1){ @@ -35,13 +36,13 @@ public class JsViewerDriver extends Util { URL url = new URL(args[0]); // computing CG + PA - Util.setTranslatorFactory(new CAstRhinoTranslatorFactory()); + JSCallGraphBuilderUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory()); JavaScriptLoader.addBootstrapFile(WebUtil.preamble); SourceModule[] sources = getSources(domless, url); - JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory), sources, false, true); - builder.setBaseURL(url); + JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory), sources, CGBuilderType.ZERO_ONE_CFA, AstIRFactory.makeDefaultFactory()); + builder.setBaseURL(url); CallGraph cg = builder.makeCallGraph(builder.getOptions()); PointerAnalysis pa = builder.getPointerAnalysis(); diff --git a/com.ibm.wala.cast.js.rhino/build.xml b/com.ibm.wala.cast.js.rhino/build.xml index f3c689484..36e049dbb 100644 --- a/com.ibm.wala.cast.js.rhino/build.xml +++ b/com.ibm.wala.cast.js.rhino/build.xml @@ -39,9 +39,9 @@ - - - + + + diff --git a/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/CAstRhinoTranslator.java b/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/CAstRhinoTranslator.java index c919a4e7c..b771a8f7e 100644 --- a/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/CAstRhinoTranslator.java +++ b/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/CAstRhinoTranslator.java @@ -14,14 +14,9 @@ import java.io.IOException; import java.util.LinkedList; import java.util.List; -import org.mozilla.javascript.RhinoToAstTranslator; - import com.ibm.wala.cast.ir.translator.TranslatorToCAst; -import com.ibm.wala.cast.js.translator.PropertyReadExpander.ExpanderKey; -import com.ibm.wala.cast.tree.CAst; import com.ibm.wala.cast.tree.CAstEntity; import com.ibm.wala.cast.tree.impl.CAstImpl; -import com.ibm.wala.cast.tree.impl.CAstRewriter; import com.ibm.wala.cast.tree.impl.CAstRewriter.CopyKey; import com.ibm.wala.cast.tree.impl.CAstRewriter.RewriteContext; import com.ibm.wala.cast.tree.impl.CAstRewriterFactory; @@ -31,15 +26,12 @@ import com.ibm.wala.classLoader.SourceModule; public class CAstRhinoTranslator implements TranslatorToCAst { private final List rewriters = new LinkedList(); private final SourceModule M; - - public CAstRhinoTranslator(SourceModule M) { + private final boolean replicateForDoLoops; + + public CAstRhinoTranslator(SourceModule M, boolean replicateForDoLoops) { this.M = M; - this.addRewriter(new CAstRewriterFactory() { - public CAstRewriter createCAstRewriter(CAst ast) { - return new PropertyReadExpander(ast); - } - }, true); - } + this.replicateForDoLoops = replicateForDoLoops; + } public , K extends CopyKey> void addRewriter(CAstRewriterFactory factory, boolean prepend) { if(prepend) @@ -57,9 +49,10 @@ public class CAstRhinoTranslator implements TranslatorToCAst { } CAstImpl Ast = new CAstImpl(); - CAstEntity entity = new RhinoToAstTranslator(Ast, M, N).translate(); + CAstEntity entity = new RhinoToAstTranslator(Ast, M, N, replicateForDoLoops).translateToCAst(); for(CAstRewriterFactory rwf : rewriters) entity = rwf.createCAstRewriter(Ast).rewrite(entity); return entity; } + } diff --git a/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/CAstRhinoTranslatorFactory.java b/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/CAstRhinoTranslatorFactory.java index aa2dba7b0..99e9f963a 100644 --- a/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/CAstRhinoTranslatorFactory.java +++ b/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/CAstRhinoTranslatorFactory.java @@ -7,7 +7,7 @@ import com.ibm.wala.classLoader.SourceModule; public class CAstRhinoTranslatorFactory implements JavaScriptTranslatorFactory { public TranslatorToCAst make(CAst ast, SourceModule M) { - return new CAstRhinoTranslator(M); + return new CAstRhinoTranslator(M, false); } } diff --git a/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java b/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java new file mode 100755 index 000000000..c7516a797 --- /dev/null +++ b/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java @@ -0,0 +1,2290 @@ +/****************************************************************************** + * Copyright (c) 2002 - 2006 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *****************************************************************************/ +package com.ibm.wala.cast.js.translator; + +import java.io.Reader; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.mozilla.javascript.CompilerEnvirons; +import org.mozilla.javascript.Node; +import org.mozilla.javascript.Parser; +import org.mozilla.javascript.Token; +import org.mozilla.javascript.ast.ArrayComprehension; +import org.mozilla.javascript.ast.ArrayComprehensionLoop; +import org.mozilla.javascript.ast.ArrayLiteral; +import org.mozilla.javascript.ast.Assignment; +import org.mozilla.javascript.ast.AstNode; +import org.mozilla.javascript.ast.AstRoot; +import org.mozilla.javascript.ast.Block; +import org.mozilla.javascript.ast.BreakStatement; +import org.mozilla.javascript.ast.CatchClause; +import org.mozilla.javascript.ast.Comment; +import org.mozilla.javascript.ast.ConditionalExpression; +import org.mozilla.javascript.ast.ContinueStatement; +import org.mozilla.javascript.ast.DoLoop; +import org.mozilla.javascript.ast.ElementGet; +import org.mozilla.javascript.ast.EmptyExpression; +import org.mozilla.javascript.ast.ErrorNode; +import org.mozilla.javascript.ast.ExpressionStatement; +import org.mozilla.javascript.ast.ForInLoop; +import org.mozilla.javascript.ast.ForLoop; +import org.mozilla.javascript.ast.FunctionCall; +import org.mozilla.javascript.ast.FunctionNode; +import org.mozilla.javascript.ast.IfStatement; +import org.mozilla.javascript.ast.InfixExpression; +import org.mozilla.javascript.ast.Jump; +import org.mozilla.javascript.ast.KeywordLiteral; +import org.mozilla.javascript.ast.Label; +import org.mozilla.javascript.ast.LabeledStatement; +import org.mozilla.javascript.ast.LetNode; +import org.mozilla.javascript.ast.Name; +import org.mozilla.javascript.ast.NewExpression; +import org.mozilla.javascript.ast.NumberLiteral; +import org.mozilla.javascript.ast.ObjectLiteral; +import org.mozilla.javascript.ast.ObjectProperty; +import org.mozilla.javascript.ast.ParenthesizedExpression; +import org.mozilla.javascript.ast.PropertyGet; +import org.mozilla.javascript.ast.RegExpLiteral; +import org.mozilla.javascript.ast.ReturnStatement; +import org.mozilla.javascript.ast.Scope; +import org.mozilla.javascript.ast.ScriptNode; +import org.mozilla.javascript.ast.StringLiteral; +import org.mozilla.javascript.ast.SwitchCase; +import org.mozilla.javascript.ast.SwitchStatement; +import org.mozilla.javascript.ast.Symbol; +import org.mozilla.javascript.ast.ThrowStatement; +import org.mozilla.javascript.ast.TryStatement; +import org.mozilla.javascript.ast.UnaryExpression; +import org.mozilla.javascript.ast.VariableDeclaration; +import org.mozilla.javascript.ast.VariableInitializer; +import org.mozilla.javascript.ast.WhileLoop; +import org.mozilla.javascript.ast.WithStatement; +import org.mozilla.javascript.ast.XmlDotQuery; +import org.mozilla.javascript.ast.XmlElemRef; +import org.mozilla.javascript.ast.XmlExpression; +import org.mozilla.javascript.ast.XmlFragment; +import org.mozilla.javascript.ast.XmlLiteral; +import org.mozilla.javascript.ast.XmlMemberGet; +import org.mozilla.javascript.ast.XmlPropRef; +import org.mozilla.javascript.ast.XmlRef; +import org.mozilla.javascript.ast.XmlString; +import org.mozilla.javascript.ast.Yield; +import org.mozilla.javascript.tools.ToolErrorReporter; + +import com.ibm.wala.cast.ir.translator.TranslatorToCAst.DoLoopTranslator; +import com.ibm.wala.cast.js.html.MappedSourceModule; +import com.ibm.wala.cast.js.ipa.callgraph.JSSSAPropagationCallGraphBuilder; +import com.ibm.wala.cast.js.loader.JavaScriptLoader; +import com.ibm.wala.cast.js.types.JavaScriptTypes; +import com.ibm.wala.cast.tree.CAst; +import com.ibm.wala.cast.tree.CAstControlFlowMap; +import com.ibm.wala.cast.tree.CAstEntity; +import com.ibm.wala.cast.tree.CAstNode; +import com.ibm.wala.cast.tree.CAstNodeTypeMap; +import com.ibm.wala.cast.tree.CAstQualifier; +import com.ibm.wala.cast.tree.CAstSourcePositionMap; +import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position; +import com.ibm.wala.cast.tree.CAstType; +import com.ibm.wala.cast.tree.impl.CAstOperator; +import com.ibm.wala.cast.tree.impl.CAstSymbolImpl; +import com.ibm.wala.classLoader.SourceModule; +import com.ibm.wala.util.collections.EmptyIterator; +import com.ibm.wala.util.collections.HashMapFactory; +import com.ibm.wala.util.debug.Assertions; + +public class RhinoToAstTranslator { + + /** + * a dummy name to use for standard function calls, only used to distinguish + * them from constructor calls + */ + public static final String STANDARD_CALL_FN_NAME = "do"; + + /** + * name used for constructor calls, used to distinguish them from standard + * function calls + */ + public static final String CTOR_CALL_FN_NAME = "ctor"; + + private final boolean DEBUG = false; + + /** + * shared interface for all objects storing contextual information during the + * Rhino AST traversal + * + */ + private interface WalkContext extends JavaScriptTranslatorToCAst.WalkContext { + + } + + /** + * default implementation of WalkContext; methods do nothing / return null + * + */ + private static class RootContext extends JavaScriptTranslatorToCAst.RootContext implements WalkContext { + + } + + /** + * context used for function / script declarations + */ + private static class FunctionContext extends JavaScriptTranslatorToCAst.FunctionContext implements WalkContext { + FunctionContext(WalkContext parent, Node s) { + super(parent, s); + } + + } + + /** + * context used for top-level script declarations + */ + private static class ScriptContext extends FunctionContext { + private final String script; + + ScriptContext(WalkContext parent, ScriptNode s, String script) { + super(parent, s); + this.script = script; + } + + @Override + public String script() { + return script; + } + } + + private static class MemberDestructuringContext extends JavaScriptTranslatorToCAst.MemberDestructuringContext implements WalkContext { + + protected MemberDestructuringContext(WalkContext parent, Node initialBaseFor, int operationIndex) { + super(parent, initialBaseFor, operationIndex); + } + + } + + private static class BreakContext extends JavaScriptTranslatorToCAst.BreakContext implements WalkContext { + + BreakContext(WalkContext parent, Node breakTo, String label) { + super(parent, breakTo, label); + } + + } + + private static class LoopContext extends JavaScriptTranslatorToCAst.LoopContext implements WalkContext { + + LoopContext(WalkContext parent, Node breakTo, Node continueTo, String label) { + super(parent, breakTo, continueTo, label); + } + + } + + private static class TryCatchContext extends JavaScriptTranslatorToCAst.TryCatchContext implements WalkContext { + + TryCatchContext(WalkContext parent, CAstNode catchNode) { + super(parent, catchNode); + } + + } + + private String operationReceiverName(int operationIndex) { + return "$$destructure$rcvr" + operationIndex; + } + + private CAstNode operationReceiverVar(int operationIndex) { + return Ast.makeNode(CAstNode.VAR, Ast.makeConstant(operationReceiverName(operationIndex))); + } + + private String operationElementName(int operationIndex) { + return "$$destructure$elt" + operationIndex; + } + + private CAstNode operationElementVar(int operationIndex) { + return Ast.makeNode(CAstNode.VAR, Ast.makeConstant(operationElementName(operationIndex))); + } + + private CAstNode translateOpcode(int nodeType) { + switch (nodeType) { + case Token.POS: + case Token.ADD: + case Token.ASSIGN_ADD: + return CAstOperator.OP_ADD; + case Token.DIV: + case Token.ASSIGN_DIV: + return CAstOperator.OP_DIV; + case Token.ASSIGN_LSH: + case Token.LSH: + return CAstOperator.OP_LSH; + case Token.MOD: + case Token.ASSIGN_MOD: + return CAstOperator.OP_MOD; + case Token.MUL: + case Token.ASSIGN_MUL: + return CAstOperator.OP_MUL; + case Token.RSH: + case Token.ASSIGN_RSH: + return CAstOperator.OP_RSH; + case Token.SUB: + case Token.NEG: + case Token.ASSIGN_SUB: + return CAstOperator.OP_SUB; + case Token.URSH: + case Token.ASSIGN_URSH: + return CAstOperator.OP_URSH; + case Token.BITAND: + case Token.ASSIGN_BITAND: + return CAstOperator.OP_BIT_AND; + case Token.BITOR: + case Token.ASSIGN_BITOR: + return CAstOperator.OP_BIT_OR; + case Token.BITXOR: + case Token.ASSIGN_BITXOR: + return CAstOperator.OP_BIT_XOR; + + case Token.EQ: + return CAstOperator.OP_EQ; + case Token.SHEQ: + return CAstOperator.OP_STRICT_EQ; + case Token.IFEQ: + return CAstOperator.OP_EQ; + case Token.GE: + return CAstOperator.OP_GE; + case Token.GT: + return CAstOperator.OP_GT; + case Token.LE: + return CAstOperator.OP_LE; + case Token.LT: + return CAstOperator.OP_LT; + case Token.NE: + return CAstOperator.OP_NE; + case Token.SHNE: + return CAstOperator.OP_STRICT_NE; + case Token.IFNE: + return CAstOperator.OP_NE; + + case Token.BITNOT: + return CAstOperator.OP_BITNOT; + case Token.NOT: + return CAstOperator.OP_NOT; + + default: + Assertions.UNREACHABLE(); + return null; + } + } + + private CAstNode makeBuiltinNew(String typeName) { + return Ast.makeNode(CAstNode.NEW, Ast.makeConstant(typeName)); + } + + private CAstNode handleNew(WalkContext context, String globalName, CAstNode arguments[]) { + return handleNew(context, readName(context, globalName), arguments); + } + + private CAstNode handleNew(WalkContext context, CAstNode value, CAstNode arguments[]) { + return makeCtorCall(value, arguments, context); + } + + private boolean isPrologueScript(WalkContext context) { + return JavaScriptLoader.bootstrapFileNames.contains(context.script()); + } + + private Node getCallTarget(FunctionCall n) { + return n.getTarget(); + } + /** + * is n a call to "primitive" within our synthetic modeling code? + */ + private boolean isPrimitiveCall(WalkContext context, FunctionCall n) { + return isPrologueScript(context) && n.getType() == Token.CALL && getCallTarget(n).getType() == Token.NAME + && getCallTarget(n).getString().equals("primitive"); + } + + private Node getNewTarget(NewExpression n) { + return n.getTarget(); + } + + private boolean isPrimitiveCreation(WalkContext context, NewExpression n) { + Node target = getNewTarget(n); + return isPrologueScript(context) && n.getType() == Token.NEW && target.getType() == Token.NAME + && target.getString().equals("Primitives"); + } + + private CAstNode makeCall(CAstNode fun, CAstNode thisptr, CAstNode args[], WalkContext context) { + return makeCall(fun, thisptr, args, context, STANDARD_CALL_FN_NAME); + } + + private CAstNode makeCtorCall(CAstNode thisptr, CAstNode args[], WalkContext context) { + return makeCall(thisptr, null, args, context, CTOR_CALL_FN_NAME); + } + + private CAstNode makeCall(CAstNode fun, CAstNode thisptr, CAstNode args[], WalkContext context, String callee) { + int children = (args == null)? 0 : args.length; + + // children of CAst CALL node are the expression that evaluates to the + // function, followed by a name (either STANDARD_CALL_FN_NAME or + // CTOR_CALL_FN_NAME), followed by the actual + // parameters + int nargs = (thisptr == null) ? children + 2 : children + 3; + int i = 0; + CAstNode arguments[] = new CAstNode[nargs]; + arguments[i++] = fun; + // assert callee.equals(STANDARD_CALL_FN_NAME) || callee.equals(CTOR_CALL_FN_NAME); + arguments[i++] = Ast.makeConstant(callee); + if (thisptr != null) + arguments[i++] = thisptr; + if (args != null) { + for (CAstNode arg : args) { + arguments[i++] = arg; + } + } + + CAstNode call = Ast.makeNode(CAstNode.CALL, arguments); + + context.cfg().map(call, call); + if (context.getCatchTarget() != null) { + context.cfg().add(call, context.getCatchTarget(), null); + } + + return call; + } + + /** + * Used to represent a script or function in the CAst; see walkEntity(). + * + */ + private static class ScriptOrFnEntity implements CAstEntity { + private final String[] arguments; + + private final String name; + + private final int kind; + + private final Map> subs; + + private final CAstNode ast; + + private final CAstControlFlowMap map; + + private final CAstSourcePositionMap pos; + + private final Position entityPosition; + + private ScriptOrFnEntity(AstNode n, Map> subs, CAstNode ast, CAstControlFlowMap map, CAstSourcePositionMap pos, String name) { + this.name = name; + this.entityPosition = pos.getPosition(ast); + + if (n instanceof FunctionNode) { + FunctionNode f = (FunctionNode) n; + f.flattenSymbolTable(false); + int i = 0; + arguments = new String[f.getParamCount() + 2]; + arguments[i++] = name; + arguments[i++] = "this"; + for (int j = 0; j < f.getParamCount(); j++) { + arguments[i++] = f.getParamOrVarName(j); + } + } else { + arguments = new String[0]; + } + kind = (n instanceof FunctionNode) ? CAstEntity.FUNCTION_ENTITY : CAstEntity.SCRIPT_ENTITY; + this.subs = subs; + this.ast = ast; + this.map = map; + this.pos = pos; + } + + @Override + public String toString() { + return ""; + } + + public String getName() { + return name; + } + + public String getSignature() { + Assertions.UNREACHABLE(); + return null; + } + + public int getKind() { + return kind; + } + + public String[] getArgumentNames() { + return arguments; + } + + public CAstNode[] getArgumentDefaults() { + return new CAstNode[0]; + } + + public int getArgumentCount() { + return arguments.length; + } + + public Map> getAllScopedEntities() { + return Collections.unmodifiableMap(subs); + } + + public Iterator getScopedEntities(CAstNode construct) { + if (subs.containsKey(construct)) + return subs.get(construct).iterator(); + else + return EmptyIterator.instance(); + } + + public CAstNode getAST() { + return ast; + } + + public CAstControlFlowMap getControlFlow() { + return map; + } + + public CAstSourcePositionMap getSourceMap() { + return pos; + } + + public CAstSourcePositionMap.Position getPosition() { + return entityPosition; + } + + public CAstNodeTypeMap getNodeTypeMap() { + return null; + } + + public Collection getQualifiers() { + Assertions.UNREACHABLE("JuliansUnnamedCAstEntity$2.getQualifiers()"); + return null; + } + + public CAstType getType() { + Assertions.UNREACHABLE("JuliansUnnamedCAstEntity$2.getType()"); + return null; + } + } + + private CAstEntity walkEntity(final AstNode n, List body, String name, WalkContext child) { + CAstNode[] stmts = body.toArray(new CAstNode[body.size()]); + + // add variable / constant / function declarations, if any + if (!child.getNameDecls().isEmpty()) { + // new first statement will be a block declaring all names. + CAstNode[] newStmts = new CAstNode[stmts.length + 1]; + + newStmts[0] = Ast.makeNode(CAstNode.BLOCK_STMT, child.getNameDecls().toArray(new CAstNode[child.getNameDecls().size()])); + + System.arraycopy(stmts, 0, newStmts, 1, stmts.length); + + stmts = newStmts; + } + + final CAstNode ast = noteSourcePosition(child, Ast.makeNode(CAstNode.BLOCK_STMT, stmts), n); + final CAstControlFlowMap map = child.cfg(); + final CAstSourcePositionMap pos = child.pos(); + + // not sure if we need this copy --MS + final Map> subs = HashMapFactory.make(child.getScopedEntities()); + + return new ScriptOrFnEntity(n, subs, ast, map, pos, name); + } + + private Position makePosition(AstNode n) { + URL url = sourceModule.getURL(); + int line = n.getLineno(); + Position pos = new RangePosition(url, line, n.getAbsolutePosition(), n.getAbsolutePosition()+n.getLength()); + + if (sourceModule instanceof MappedSourceModule) { + Position np = ((MappedSourceModule) sourceModule).getMapping().getIncludedPosition(pos); + if (np != null) { + return np; + } + } + + return pos; + } + + private void pushSourcePosition(WalkContext context, CAstNode n, Position p) { + if (context.pos().getPosition(n) == null && !(n.getKind()==CAstNode.FUNCTION_EXPR || n.getKind()==CAstNode.FUNCTION_STMT)) { + context.pos().setPosition(n, p); + for(int i = 0; i < n.getChildCount(); i++) { + pushSourcePosition(context, n.getChild(i), p); + } + } + } + private CAstNode noteSourcePosition(WalkContext context, CAstNode n, AstNode p) { + if (p.getLineno() != -1 && context.pos().getPosition(n) == null) { + pushSourcePosition(context, n, makePosition(p)); + } + return n; + } + + private CAstNode readName(WalkContext context, String name) { + CAstNode cn = makeVarRef(name); + context.cfg().map(cn, cn); + CAstNode target = context.getCatchTarget(); + if (target != null) { + context.cfg().add(cn, target, JavaScriptTypes.ReferenceError); + } else { + context.cfg().add(cn, CAstControlFlowMap.EXCEPTION_TO_EXIT, JavaScriptTypes.ReferenceError); + } + return cn; + } + + private List