本文整理汇总了C#中Analyzer.GetCFG方法的典型用法代码示例。如果您正苦于以下问题:C# Analyzer.GetCFG方法的具体用法?C# Analyzer.GetCFG怎么用?C# Analyzer.GetCFG使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer
的用法示例。
在下文中一共展示了Analyzer.GetCFG方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
/// <summary>
/// Standard check function, except that it returns a PreDAStatus data structure
/// that contains the three tables mentioned above.
/// </summary>
/// <param name="t"></param>
/// <param name="method"></param>
/// <param name="analyzer"></param>
/// <returns>A PreDAStatus data structure, or a null if error occurs. </returns>
public static PreDAStatus Check(TypeSystem t, Method method, Analyzer analyzer) {
Debug.Assert(method != null && analyzer != null);
MethodReachingDefNNArrayChecker checker = new MethodReachingDefNNArrayChecker(t, analyzer, method);
ControlFlowGraph cfg = analyzer.GetCFG(method);
if (cfg == null)
return null;
InitializedVariables iv = new InitializedVariables(analyzer);
NNArrayStatus status = new NNArrayStatus(iv);
NNArrayStatus.Checker = checker;
checker.Run(cfg, status);
// Check whether there are arrays that have been created but not committed
NNArrayStatus exitStatus2 = checker.exitState as NNArrayStatus;
if (exitStatus2 != null) {
if (Analyzer.Debug) {
Console.WriteLine("exit state of {0} is", method.FullName);
exitStatus2.Dump();
}
ArrayList notCommitted = exitStatus2.CreatedButNotInitedArrays();
if (notCommitted != null && notCommitted.Count != 0) {
foreach (object o in notCommitted) {
string offendingString = "A non null element array";
Node offendingNode = method;
if (o is Variable) {
offendingString = "Variable \'" + o + "\'";
offendingNode = o as Variable;
}
if (o is Pair<Variable, Field>) {
Pair<Variable, Field> pair = o as Pair<Variable, Field>;
Variable var = pair.Fst;
Field fld = pair.Snd;
offendingString = "Field \'" + var + "." + fld + "\'";
if (NNArrayStatus.FieldsToMB.ContainsKey(pair)) {
offendingNode = NNArrayStatus.FieldsToMB[pair] as MemberBinding;
if (offendingNode == null) {
offendingNode = fld;
} else {
MemberBinding mb = offendingNode as MemberBinding;
if (mb.TargetObject == null || mb.SourceContext.SourceText == null) {
offendingNode = fld;
}
}
}
}
checker.HandleError(offendingNode, Error.ShouldCommit, offendingString);
}
}
ArrayList notCommittedOnAllPaths = exitStatus2.CreatedButNotFullyCommittedArrays();
if (notCommittedOnAllPaths != null && notCommittedOnAllPaths.Count != 0) {
foreach (object o in notCommittedOnAllPaths) {
string offendingString = "A non-null element array";
Node offendingNode = method;
if (o is Variable) {
offendingString = "variable \'" + o + "\'";
offendingNode = o as Variable;
} else if (o is Pair<Variable, Field>) {
Pair<Variable, Field> pair = o as Pair<Variable, Field>;
Variable var = pair.Fst;
Field fld = pair.Snd;
if (NNArrayStatus.FieldsToMB.ContainsKey(pair)) {
offendingNode = NNArrayStatus.FieldsToMB[pair] as MemberBinding;
if (offendingNode == null) {
offendingNode = fld;
} else {
MemberBinding mb = offendingNode as MemberBinding;
if (mb.TargetObject == null || mb.SourceContext.SourceText==null) {
offendingNode = fld;
}
}
}
offendingString = "field \'" + var + "." + fld + "\'";
}
checker.HandleError(offendingNode, Error.ShouldCommitOnAllPaths, offendingString);
}
}
if (checker.errors != null && checker.errors.Count != 0) {
checker.HandleError();
checker.errors.Clear();
return null;
}
}
return new PreDAStatus(checker.NotCommitted, checker.Committed, checker.OKTable, checker.NonDelayArrayTable);
}
示例2: Check
/// <summary>
/// Entry point to check a method.
/// </summary>
/// <param name="t"></param>
/// <param name="method"></param>
public static void Check(TypeSystem t, Method method, Analyzer analyzer) {
if(method==null)
return;
if (method.HasCompilerGeneratedSignature)
return; // REVIEW: this means we don't check default ctors, among other things.
ExposureChecker checker= new ExposureChecker(t,method);
Analyzer.WriteLine("");
ControlFlowGraph cfg=analyzer.GetCFG(method);
if(cfg!=null)
{
checker.Run( cfg, new ExposureState(t));
}
}
示例3: Check
/// <summary>
/// Entry point to check a method.
/// </summary>
/// <param name="t"></param>
/// <param name="method"></param>
public static INonNullInformation Check(TypeSystem t, Method method, Analyzer analyzer)
{
if(method==null)
return null;
NonNullChecker checker = new NonNullChecker(t, method, analyzer);
ControlFlowGraph cfg = analyzer.GetCFG(method);
if (cfg != null) {
checker.nonNullEdgeInfo = new IFunctionalMap[cfg.BlockCount];
checker.Run(cfg, new NonNullState(t, analyzer.DelayInfo));
checker.OptimizeMethodBody(method);
return checker;
}
return null;
}