本文整理汇总了C#中LabelTarget类的典型用法代码示例。如果您正苦于以下问题:C# LabelTarget类的具体用法?C# LabelTarget怎么用?C# LabelTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LabelTarget类属于命名空间,在下文中一共展示了LabelTarget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bind
// Just splat the args and dispatch through a nested site
public override Expression Bind(object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel) {
Debug.Assert(args.Length == 2);
int count = ((object[])args[1]).Length;
ParameterExpression array = parameters[1];
var nestedArgs = new ReadOnlyCollectionBuilder<Expression>(count + 1);
var delegateArgs = new Type[count + 3]; // args + target + returnType + CallSite
nestedArgs.Add(parameters[0]);
delegateArgs[0] = typeof(CallSite);
delegateArgs[1] = typeof(object);
for (int i = 0; i < count; i++) {
nestedArgs.Add(Expression.ArrayAccess(array, Expression.Constant(i)));
delegateArgs[i + 2] = typeof(object).MakeByRefType();
}
delegateArgs[delegateArgs.Length - 1] = typeof(object);
return Expression.IfThen(
Expression.Equal(Expression.ArrayLength(array), Expression.Constant(count)),
Expression.Return(
returnLabel,
Expression.MakeDynamic(
Expression.GetDelegateType(delegateArgs),
new ComInvokeAction(new CallInfo(count)),
nestedArgs
)
)
);
}
示例2: EnsureLabel
private LabelInfo EnsureLabel(LabelTarget node) {
LabelInfo result;
if (!_labelInfo.TryGetValue(node, out result)) {
_labelInfo.Add(node, result = new LabelInfo(_ilg, node, false));
}
return result;
}
示例3: Bind
public override Expression Bind(object[] args, System.Collections.ObjectModel.ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel) {
//For this sample, we just always return a constant.
return Expression.Return(
returnLabel,
Expression.Constant((int)args[0] + (int)args[1])
);
}
示例4: DefineLabel
private LabelInfo DefineLabel(LabelTarget node) {
if (node == null) {
return new LabelInfo(_ilg, null, false);
}
LabelInfo result = EnsureLabel(node);
result.Define(_ilg, _labelBlock);
return result;
}
示例5: LabelInfo
internal LabelInfo(ILGen il, LabelTarget node, bool canReturn) {
_ilg = il;
Node = node;
Label = il.DefineLabel();
_canReturn = canReturn;
if (node != null && node.Type != typeof(void)) {
Value = il.DeclareLocal(node.Type);
}
// Until we have more information, default to a leave instruction, which always works
_opCode = OpCodes.Leave;
}
示例6: Label
/// <summary>
/// Creates a <see cref="LabelExpression"/> representing a label with no default value.
/// </summary>
/// <param name="target">The <see cref="LabelTarget"/> which this <see cref="LabelExpression"/> will be associated with.</param>
/// <returns>A <see cref="LabelExpression"/> with no default value.</returns>
public static LabelExpression Label(LabelTarget target) {
return Label(target, null);
}
示例7: Update
/// <summary>
/// Creates a new expression that is like this one, but using the
/// supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="breakLabel">The <see cref="BreakLabel" /> property of the result.</param>
/// <param name="continueLabel">The <see cref="ContinueLabel" /> property of the result.</param>
/// <param name="body">The <see cref="Body" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public LoopExpression Update(LabelTarget breakLabel, LabelTarget continueLabel, Expression body) {
if (breakLabel == BreakLabel && continueLabel == ContinueLabel && body == Body) {
return this;
}
return Expression.Loop(body, breakLabel, continueLabel);
}
示例8: Return
/// <summary>
/// Creates a <see cref="GotoExpression"/> representing a return statement with the specified type.
/// </summary>
/// <param name="target">The <see cref="LabelTarget"/> that the <see cref="GotoExpression"/> will jump to.</param>
/// <param name="type">An <see cref="System.Type"/> to set the <see cref="P:Expression.Type"/> property equal to.</param>
/// <returns>
/// A <see cref="GotoExpression"/> with <see cref="P:GotoExpression.Kind"/> equal to Return,
/// the <see cref="P:GotoExpression.Target"/> property set to <paramref name="target"/>,
/// the <see cref="P:Expression.Type"/> property set to <paramref name="type"/>,
/// and a null value to be passed to the target label upon jumping.
/// </returns>
public static GotoExpression Return(LabelTarget target, Type type) {
return MakeGoto(GotoExpressionKind.Return, target, null, type);
}
示例9: ReferenceLabel
private LabelInfo ReferenceLabel(LabelTarget node) {
LabelInfo result = EnsureLabel(node);
result.Reference(_labelBlock);
return result;
}
示例10: LabelInfo
internal LabelInfo(ILGenerator il, LabelTarget node, bool canReturn) {
_ilg = il;
_node = node;
_canReturn = canReturn;
}
示例11: TryGetLabelInfo
internal bool TryGetLabelInfo(LabelTarget target, out LabelInfo info) {
if (Labels == null) {
info = null;
return false;
}
return Labels.TryGetValue(target, out info);
}
示例12: Update
/// <summary>
/// Creates a new expression that is like this one, but using the
/// supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="target">The <see cref="Target" /> property of the result.</param>
/// <param name="defaultValue">The <see cref="DefaultValue" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public LabelExpression Update(LabelTarget target, Expression defaultValue) {
if (target == Target && defaultValue == DefaultValue) {
return this;
}
return Expression.Label(target, defaultValue);
}
示例13: GotoExpression
internal GotoExpression(GotoExpressionKind kind, LabelTarget target, Expression value, Type type) {
_kind = kind;
_value = value;
_target = target;
_type = type;
}
示例14: ValidateGoto
private static void ValidateGoto(LabelTarget target, ref Expression value, string targetParameter, string valueParameter) {
ContractUtils.RequiresNotNull(target, targetParameter);
if (value == null) {
if (target.Type != typeof(void)) throw Error.LabelMustBeVoidOrHaveExpression();
} else {
ValidateGotoType(target.Type, ref value, valueParameter);
}
}
示例15: MakeGoto
/// <summary>
/// Creates a <see cref="GotoExpression"/> representing a jump of the specified <see cref="GotoExpressionKind"/>.
/// The value passed to the label upon jumping can also be specified.
/// </summary>
/// <param name="kind">The <see cref="GotoExpressionKind"/> of the <see cref="GotoExpression"/>.</param>
/// <param name="target">The <see cref="LabelTarget"/> that the <see cref="GotoExpression"/> will jump to.</param>
/// <param name="value">The value that will be passed to the associated label upon jumping.</param>
/// <param name="type">An <see cref="System.Type"/> to set the <see cref="P:Expression.Type"/> property equal to.</param>
/// <returns>
/// A <see cref="GotoExpression"/> with <see cref="P:GotoExpression.Kind"/> equal to <paramref name="kind"/>,
/// the <see cref="P:GotoExpression.Target"/> property set to <paramref name="target"/>,
/// the <see cref="P:Expression.Type"/> property set to <paramref name="type"/>,
/// and <paramref name="value"/> to be passed to the target label upon jumping.
/// </returns>
public static GotoExpression MakeGoto(GotoExpressionKind kind, LabelTarget target, Expression value, Type type) {
ValidateGoto(target, ref value, "target", "value");
return new GotoExpression(kind, target, value, type);
}