本文整理汇总了C#中IDecompiler.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IDecompiler.HasAttribute方法的具体用法?C# IDecompiler.HasAttribute怎么用?C# IDecompiler.HasAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDecompiler
的用法示例。
在下文中一共展示了IDecompiler.HasAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rewrite
public override bool Rewrite(CodeDescriptor decompilee, Expression waitObject, IDecompiler stack, IFunctionBuilder builder)
{
if (stack.HasAttribute<Analysis.M2M.HLS>())
{
return true;
}
var curps = DesignContext.Instance.CurrentProcess;
SLSignal clk = (SLSignal)curps.Sensitivity[0].Owner;
SignalRef srEdge;
if (curps.Predicate.Equals((Func<bool>)clk.RisingEdge))
srEdge = SignalRef.Create(clk.Descriptor, SignalRef.EReferencedProperty.RisingEdge);
else
srEdge = SignalRef.Create(clk.Descriptor, SignalRef.EReferencedProperty.FallingEdge);
var lrEdge = new LiteralReference(srEdge);
int nwait = 0;
var nwaitEx = waitObject.Children[0];
bool nwaitConst = nwaitEx.IsConst();
if (nwaitConst)
{
nwait = (int)TypeConversions.ConvertValue(
nwaitEx.Eval(DefaultEvaluator.DefaultConstEvaluator),
typeof(int));
}
var fspec = new FunctionSpec(typeof(void))
{
IntrinsicRep = IntrinsicFunctions.Wait(WaitParams.EWaitKind.WaitUntil)
};
Variable v = null;
LiteralReference lrV = null;
if (!nwaitConst || nwait > 3)
{
v = new Variable(typeof(int))
{
Name = "_wait_i" + (ictr++)
};
builder.DeclareLocal(v);
lrV = new LiteralReference(v);
builder.Store(v, LiteralReference.CreateConstant((int)0));
var loop = builder.Loop();
builder.If(Expression.Equal(lrV, nwaitEx));
{
builder.Break(loop);
}
builder.EndIf();
}
int ncalls = 1;
if (nwaitConst && nwait <= 3)
ncalls = nwait;
for (int i = 0; i < ncalls; i++)
{
builder.Call(fspec, lrEdge);
}
if (!nwaitConst || nwait > 3)
{
builder.Store(v, lrV + LiteralReference.CreateConstant((int)1));
builder.EndLoop();
}
return true;
}