本文整理汇总了Java中natlab.tame.callgraph.StaticFunction类的典型用法代码示例。如果您正苦于以下问题:Java StaticFunction类的具体用法?Java StaticFunction怎么用?Java StaticFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StaticFunction类属于natlab.tame.callgraph包,在下文中一共展示了StaticFunction类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
public static void main(String args[]) {
String fileName = "/home/sameer/interview/mclab/fft/drv_fft.m";//args[0];
// Get the callgraph of the main function
Callgraph<SimpleMatrixValue> callgraph = TamerTool.getCallgraph(
new FileEnvironment(GenericFile.create(fileName)), Collections
.singletonList(new SimpleMatrixValue(null,
PrimitiveClassReference.DOUBLE)),
new SimpleMatrixValueFactory());
List<StaticFunction> functionList = callgraph.getAnalysis()
.getFunctionCollection().getAllFunctions();
for (StaticFunction function : functionList) {
//TamerPlusUtils.debugMode();
System.out.println(function.getAst().getPrettyPrinted());
System.err.println(TransformationEngine.forAST(function.getAst())
.getTIRToMcSAFIRWithoutTemp().getTransformedTree()
.getPrettyPrinted());
}
}
示例2: runTest
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
public static Res<?> runTest(GenericFile testFile){
//load the unit test
FileEnvironment fileEnvironment = new FileEnvironment(testFile);
SimpleFunctionCollection functions = new SimpleFunctionCollection(fileEnvironment);
StaticFunction aFunction = functions.getAsInlinedStaticFunction();
IntraproceduralValueAnalysis<AggrValue<SimpleMatrixValue>> classAnalysis =
new IntraproceduralValueAnalysis<AggrValue<SimpleMatrixValue>>(null,
aFunction,SimpleMatrixValue.FACTORY,
Args.<AggrValue<SimpleMatrixValue>>newInstance(new SimpleMatrixValue(PrimitiveClassReference.DOUBLE)));
try{
FlowAnalysisTestTool test = new FlowAnalysisTestTool(classAnalysis);
String s = test.run(true,true);
//System.out.println(s);
} catch (UnsupportedOperationException e){
System.err.println(e.getMessage());
return Res.<AggrValue<SimpleMatrixValue>>newInstance();
}
System.out.println("test result for "+testFile.getName()+": "+classAnalysis.getResult());
return classAnalysis.getResult();
}
示例3: getVariableList
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
public static ArrayList<String> getVariableList(UDDUWeb web,
StaticFunction function) {
/*
* This is definitely an unoptimized way of doing it. Replace it with a
* better way. Other things: 1. Considers only those variables which are
* used somewhere.
*/
DUChain vDUChain = web.getDUChain();
Map<String, HashSet<TIRNode>> varUses;
ArrayList<String> varList = new ArrayList<String>();
// Make a list of variables
LinkedList<TIRNode> allStatements = web.getVisitedStmtsLinkedList();
for (TIRNode statement : allStatements) {
if (debug) {
System.out.println("~~" + statement + "\n");
}
varUses = vDUChain.getUsesMapForDefinitionStmt(statement);
if (null != varUses) {
for (String var : varUses.keySet()) {
// if (!function.getAst().getOutParamSet().contains(var))
{
// Do not rename return variable
// if (debug)
// System.out.println("==" + statement.toString()
// + " defines " + var + "==");
if (!varList.contains(var)) {
varList.add(var);
}
}
}
}
}
return varList;
}
示例4: newFunctionAnalysis
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
@Override
public CallStringAnalysis newFunctionAnalysis(
StaticFunction function,
CallString<?> argumentSet,
InterproceduralAnalysisNode<CallStringAnalysis, CallString<?>, CallStrings> node) {
return new CallStringAnalysis(function,node);
}
示例5: CallStringAnalysis
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
private CallStringAnalysis(StaticFunction function,
InterproceduralAnalysisNode<CallStringAnalysis, CallString<?>, CallStrings> node) {
super(function.getAst());
this.node = node;
this.callstring = node.getCallString();
this.function = function;
this.result = newInitialFlow();
result.add(callstring);
}
示例6: IntraproceduralValueAnalysis
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
public IntraproceduralValueAnalysis(InterproceduralAnalysisNode<IntraproceduralValueAnalysis<V>, Args<V>, Res<V>> node,
StaticFunction function, ValueFactory<V> factory) {
super(function.getAst());
this.node = node;
this.function = function;
this.factory = factory;
this.valuePropagator = factory.getValuePropagator();
this.classRepository = node.getInterproceduralAnalysis().getFunctionCollection().getClassRepository();
}
示例7: newFunctionAnalysis
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
public IntraproceduralLiveVariableAnalysis newFunctionAnalysis(
StaticFunction function,
LiveInput argumentSet,
InterproceduralAnalysisNode<IntraproceduralLiveVariableAnalysis, LiveInput, List<LiveValue>> node) {
return new IntraproceduralLiveVariableAnalysis(node, argumentSet);
}
示例8: getFunction
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
public StaticFunction getFunction() {
return function;
}
示例9: newFunctionAnalysis
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
public F newFunctionAnalysis(
StaticFunction function, A argumentSet,
InterproceduralAnalysisNode<F, A,R> node);
示例10: FileEnvironment
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
/**
* tames a matlab project, by inlining all the code into one function,
* using the tame IR, and then running the value analysis.
* Returns an IntraproceduralValueAnalysis node, which contains
* both the function (via getTree()), and the value flowmap associated
* with every statement (via getInFlowSets() and getOutFlowSets(), which
* return maps that associate flow maps with every statement).
*
* The inputs are the location of the entry point (main file), and the
* abstract values of the incoming arguments to the entry point, as a
* list of AggrValue<SimpleMatrixValue>, i.e. SimpleMatrixValue. One can
* use the constructors provided by SimpleMatrixValue or SimpleMatrixValueFactory
* to generate such abstract values. Alternatively, one can use the
* tameMatlabToSingleFunctionFromClassReferences method, which only needs
* the PrimitiveClassReferences of arguments.
*
* This is a rough approximation of matlab, and does not support
* recursion (do to full inlining), early returns, or overloading. There may also
* be issues with variable names. This is intended to start playing with
* simple Matlab projects, to get a sense on how to approach a possible backend.
*
* This uses The Builtin information provided by the natlab.tame.builtin package
*/
public IntraproceduralValueAnalysis<AggrValue<SimpleMatrixValue>>
tameMatlabToSingleFunction(java.io.File mainFile, List<AggrValue<SimpleMatrixValue>> inputValues){
GenericFile gFile = GenericFile.create(mainFile); //file -> generic file
FileEnvironment env = new FileEnvironment(gFile); //get path environment obj
SimpleFunctionCollection callgraph = new SimpleFunctionCollection(env); //build simple callgraph
StaticFunction function = callgraph.getAsInlinedStaticFunction(); //inline all
//build intra-analysis
IntraproceduralValueAnalysis<AggrValue<SimpleMatrixValue>> analysis =
new IntraproceduralValueAnalysis<AggrValue<SimpleMatrixValue>>(
null, function, new SimpleMatrixValueFactory(),
Args.<AggrValue<SimpleMatrixValue>>newInstance(inputValues));
analysis.analyze(); //run analysis
return analysis;
}
示例11: newFunctionAnalysis
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
public IntraproceduralValueAnalysis<V> newFunctionAnalysis(
StaticFunction function,
Args<V> argumentSet,
InterproceduralAnalysisNode<IntraproceduralValueAnalysis<V>, Args<V>, Res<V>> node) {
return new IntraproceduralValueAnalysis<V>(node,function,valueFactory,argumentSet);
}
示例12: getFunction
import natlab.tame.callgraph.StaticFunction; //导入依赖的package包/类
public StaticFunction getFunction(){
return function;
}