2013-05-22 22:39:19 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2013 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
|
|
|
|
*******************************************************************************/
|
2007-08-08 12:01:12 +00:00
|
|
|
package com.ibm.wala.cast.ipa.modref;
|
|
|
|
|
2007-11-16 20:57:45 +00:00
|
|
|
import java.util.Collection;
|
2007-08-08 12:01:12 +00:00
|
|
|
|
2014-07-11 15:55:02 +00:00
|
|
|
import com.ibm.wala.cast.ipa.callgraph.AstHeapModel;
|
2009-04-09 20:31:14 +00:00
|
|
|
import com.ibm.wala.cast.ir.ssa.AstAssertInstruction;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstEchoInstruction;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstGlobalRead;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstGlobalWrite;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstInstructionVisitor;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstIsDefinedInstruction;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstLexicalRead;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.AstLexicalWrite;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction;
|
|
|
|
import com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction;
|
2007-11-16 20:57:45 +00:00
|
|
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
2014-05-20 20:00:06 +00:00
|
|
|
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
2007-11-16 20:57:45 +00:00
|
|
|
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
|
|
|
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
|
|
|
|
import com.ibm.wala.ipa.modref.ExtendedHeapModel;
|
|
|
|
import com.ibm.wala.ipa.modref.ModRef;
|
2007-08-08 12:01:12 +00:00
|
|
|
|
2016-02-14 22:18:21 +00:00
|
|
|
public class AstModRef<T extends InstanceKey> extends ModRef<T> {
|
2007-08-08 12:01:12 +00:00
|
|
|
|
2014-07-11 15:55:02 +00:00
|
|
|
@Override
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
public ExtendedHeapModel makeHeapModel(PointerAnalysis<T> pa) {
|
2014-07-11 15:55:02 +00:00
|
|
|
return (AstHeapModel)pa.getHeapModel();
|
|
|
|
}
|
|
|
|
|
2016-02-14 22:18:21 +00:00
|
|
|
protected static class AstRefVisitor<T extends InstanceKey> extends RefVisitor<T, AstHeapModel> implements AstInstructionVisitor {
|
2007-08-08 12:01:12 +00:00
|
|
|
|
2016-02-14 22:18:21 +00:00
|
|
|
protected AstRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<T> pa, AstHeapModel h) {
|
2007-08-08 12:01:12 +00:00
|
|
|
super(n, result, pa, h);
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitAstLexicalRead(AstLexicalRead instruction) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitAstLexicalWrite(AstLexicalWrite instruction) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitAstGlobalRead(AstGlobalRead instruction) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitAstGlobalWrite(AstGlobalWrite instruction) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitAssert(AstAssertInstruction instruction) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitEachElementGet(EachElementGetInstruction inst) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitEachElementHasNext(EachElementHasNextInstruction inst) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitIsDefined(AstIsDefinedInstruction inst) {
|
|
|
|
|
|
|
|
}
|
2007-12-10 04:26:21 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-12-10 04:26:21 +00:00
|
|
|
public void visitEcho(AstEchoInstruction inst) {
|
|
|
|
|
|
|
|
}
|
2007-08-08 12:01:12 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2017-05-04 02:37:58 +00:00
|
|
|
protected RefVisitor<T, ? extends ExtendedHeapModel> makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<T> pa, ExtendedHeapModel h) {
|
2017-03-12 03:20:51 +00:00
|
|
|
return new AstRefVisitor<>(n, result, pa, (AstHeapModel)h);
|
2007-08-08 12:01:12 +00:00
|
|
|
}
|
|
|
|
|
2016-02-14 22:18:21 +00:00
|
|
|
protected static class AstModVisitor<T extends InstanceKey>
|
|
|
|
extends ModVisitor<T, AstHeapModel>
|
2007-08-08 12:01:12 +00:00
|
|
|
implements AstInstructionVisitor
|
|
|
|
{
|
|
|
|
|
2016-02-14 22:18:21 +00:00
|
|
|
protected AstModVisitor(CGNode n, Collection<PointerKey> result, AstHeapModel h, PointerAnalysis<T> pa) {
|
2008-01-25 13:46:23 +00:00
|
|
|
super(n, result, h, pa, true);
|
2007-08-08 12:01:12 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitAstLexicalRead(AstLexicalRead instruction) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitAstLexicalWrite(AstLexicalWrite instruction) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitAstGlobalRead(AstGlobalRead instruction) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitAstGlobalWrite(AstGlobalWrite instruction) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitAssert(AstAssertInstruction instruction) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitEachElementGet(EachElementGetInstruction inst) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitEachElementHasNext(EachElementHasNextInstruction inst) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-08-08 12:01:12 +00:00
|
|
|
public void visitIsDefined(AstIsDefinedInstruction inst) {
|
|
|
|
|
|
|
|
}
|
2007-12-10 04:26:21 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-12-10 04:26:21 +00:00
|
|
|
public void visitEcho(AstEchoInstruction inst) {
|
|
|
|
|
|
|
|
}
|
2007-08-08 12:01:12 +00:00
|
|
|
}
|
|
|
|
|
2008-01-25 13:55:18 +00:00
|
|
|
@Override
|
2017-05-04 02:37:58 +00:00
|
|
|
protected ModVisitor<T, ? extends ExtendedHeapModel> makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<T> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
|
2017-03-15 05:04:21 +00:00
|
|
|
return new AstModVisitor<>(n, result, (AstHeapModel)h, pa);
|
2007-08-08 12:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|