本文整理汇总了C#中System.Compiler.Method类的典型用法代码示例。如果您正苦于以下问题:C# Method类的具体用法?C# Method怎么用?C# Method使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Method类属于System.Compiler命名空间,在下文中一共展示了Method类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: contractRename
static string contractRename(Method meth, ArrayList a, ArrayList b)
{
MethodContract mc = meth.Contract;
File.AppendAllText("g:\\test3.txt", meth.HelpText + "\r\n");
return "";
}
示例2: CurrentState
private CurrentState(TypeNode type, Dictionary<string, object> typeSuppressed, Method method)
{
this.Type = type;
this.typeSuppressed = typeSuppressed;
this.Method = method;
this.methodSuppressed = null;
}
示例3: CollectOldExpressions
public CollectOldExpressions(Module module, Method method, ContractNodes contractNodes, Dictionary<TypeNode, Local> closureLocals,
int localCounterStart, Class initialClosureClass)
: this(module, method, contractNodes, closureLocals, localCounterStart)
{
this.topLevelClosureClass = initialClosureClass;
this.currentClosureClass = initialClosureClass;
}
示例4: check
static public void check(TypeSystem t, Method m){
ModifiesChecker mChecker=new ModifiesChecker(t);
ControlFlowGraph cfg=ControlFlowGraph.For(m);
mChecker.Run(cfg,
null // TBD
);
}
示例5: CreateTryFinallyBlock
internal static Block CreateTryFinallyBlock(Method method, Block tryBody, Block finallyBody)
{
Contract.Requires(method != null);
Contract.Requires(tryBody != null);
Contract.Requires(finallyBody != null);
if (method.ExceptionHandlers == null) method.ExceptionHandlers = new ExceptionHandlerList();
Block result = new Block(new StatementList());
Block afterFinally = new Block(new StatementList());
tryBody.Statements.Add(new Branch(null, afterFinally, false, true, true));
finallyBody.Statements.Add(new EndFinally());
result.Statements.Add(tryBody);
result.Statements.Add(finallyBody);
result.Statements.Add(afterFinally);
ExceptionHandler fb = new ExceptionHandler();
fb.TryStartBlock = tryBody;
fb.BlockAfterTryEnd = finallyBody;
fb.HandlerStartBlock = finallyBody;
fb.BlockAfterHandlerEnd = afterFinally;
fb.HandlerType = NodeType.Finally;
method.ExceptionHandlers.Add(fb);
return result;
}
示例6: CurrentState
public CurrentState(AssemblyNode assembly) {
this.Assembly = assembly;
this.Type = null;
this.Method = null;
this.assemblySuppressed = null;
this.typeSuppressed = null;
this.methodSuppressed = null;
}
示例7: VisitMethod
public override Method VisitMethod(Method method)
{
if (method == null) return null;
this.VisitAttributeList(method.Attributes);
this.VisitAttributeList(method.ReturnAttributes);
// don't visit further into the method.
return method;
}
示例8: CheckMethodSpecAdmissibility
public void CheckMethodSpecAdmissibility(Expression exp, Method method, bool reportWFonly, bool dontReport) {
DeclaringMethod = method;
ReportWFErrorOnly = reportWFonly; // true for Pure methods: we only want to enforce well-foundedness on them
DontReportError = dontReport;
StateStack = new System.Collections.Stack();
ResetCurrentState();
this.VisitExpression(exp);
}
示例9: DuplicatorForContractsAndClosures
public DuplicatorForContractsAndClosures(Module module, Method sourceMethod, Method targetMethod,
ContractNodes contractNodes, bool mapParameters)
: base(module, targetMethod.DeclaringType)
{
this.sourceMethod = sourceMethod;
this.targetMethod = targetMethod;
this.RemoveNameForLocals = true;
Duplicator dup = this;
if (mapParameters)
{
if (sourceMethod.ThisParameter != null)
{
if (targetMethod.ThisParameter != null)
{
dup.DuplicateFor[sourceMethod.ThisParameter.UniqueKey] = targetMethod.ThisParameter;
}
else
{
// target is a static wrapper. But duplicator cannot handle This -> Parameter conversion
// so we handle it explicitly here in this visitor.
replaceThisWithParameter = targetMethod.Parameters[0];
}
}
if (sourceMethod.Parameters != null && targetMethod.Parameters != null
&& sourceMethod.Parameters.Count == targetMethod.Parameters.Count)
{
for (int i = 0, n = sourceMethod.Parameters.Count; i < n; i++)
{
dup.DuplicateFor[sourceMethod.Parameters[i].UniqueKey] = targetMethod.Parameters[i];
}
}
}
var originalType = HelperMethods.IsContractTypeForSomeOtherType(sourceMethod.DeclaringType, contractNodes);
if (originalType != null)
{
var contractType = this.contractClass = sourceMethod.DeclaringType;
while (contractType.Template != null)
{
contractType = contractType.Template;
}
while (originalType.Template != null)
{
originalType = originalType.Template;
}
// forward ContractType<A,B> -> originalType<A',B'>
this.contractClassToForward = contractType;
this.targetTypeToForwardTo = originalType;
//dup.DuplicateFor[contractType.UniqueKey] = originalType;
}
}
示例10: VisitMethod
public override Method VisitMethod(Method method)
{
if (method == null) return null;
ZMethod result = (ZMethod)base.VisitMethod(method);
result.ResetLocals();
return result;
}
示例11: CurrentState
public CurrentState(TypeNode type, CurrentState oldState)
{
this.Type = type;
this.Method = null;
this.typeSuppressed = null;
this.methodSuppressed = null;
this.Assembly = oldState.Assembly;
this.assemblySuppressed = oldState.assemblySuppressed;
}
示例12: CleanupEnsures
/// <summary>
/// Visits the ensures clauses to clean up Old expressions
/// </summary>
/// <param name="m"></param>
public void CleanupEnsures(Method m)
{
if (m.Contract != null)
{
this.VisitEnsuresList(m.Contract.Ensures);
this.VisitEnsuresList(m.Contract.AsyncEnsures);
this.VisitEnsuresList(m.Contract.ModelEnsures);
}
}
示例13: Contains
/// <summary>
/// actualReturn type is null if Task is not generic, otherwise ,the Task result type.
/// </summary>
public static bool Contains(Node node, ContractNodes contractNodes, Method currentMethod,
TypeNode actualReturnType)
{
var v = new AsyncReturnValueQuery(contractNodes, currentMethod, actualReturnType);
v.Visit(node);
return v.foundReturnValueTaskResult;
}
示例14: RewriteContractCall
// Requires:
// statement.Expression is MethodCall
// statement.Expression.Callee is MemberBinding
// statement.Expression.Callee.BoundMember is Method
// statement.Expression.Callee.BoundMember == "Requires" or "Ensures"
//
// inline <==> replacementMethod == null
// replacementMethod != null
// ==> replacementMethod.ReturnType == methodToReplace.ReturnType
// && replacementMethod.Parameters.Count == 1
// && methodToReplace.Parameters.Count == 1
// && replacementMethod.Parameters[0].Type == methodToReplace.Parameters[0].Type
//
private static Statement RewriteContractCall(
ExpressionStatement statement,
Method /*!*/ methodToReplace,
Method /*?*/ replacementMethod,
Literal /*?*/ sourceTextToUseAsSecondArg)
{
Contract.Requires(statement != null);
MethodCall call = statement.Expression as MethodCall;
if (call == null || call.Callee == null)
{
return statement;
}
MemberBinding mb = call.Callee as MemberBinding;
if (mb == null)
{
return statement;
}
Method m = mb.BoundMember as Method;
if (m == null)
{
return statement;
}
if (m != methodToReplace)
{
return statement;
}
mb.BoundMember = replacementMethod;
if (call.Operands.Count == 3)
{
// then the invariant was found in a reference assembly
// it already has all of its arguments
return statement;
}
if (call.Operands.Count == 1)
{
call.Operands.Add(Literal.Null);
}
Literal extraArg = sourceTextToUseAsSecondArg;
if (extraArg == null)
{
extraArg = Literal.Null;
//extraArg = new Literal("No other information available", SystemTypes.String);
}
call.Operands.Add(extraArg);
return statement;
}
示例15: VisitMethod
public override Method VisitMethod(Method method)
{
Method re = base.VisitMethod(method);
System.Compiler.TypeNode sigTmp = re.ReturnType;
if(sigTmp.TypeCode!=TypeCode.Empty)
signatureType = sigTmp;
return re;
}