本文整理汇总了C#中LabelTarget类的典型用法代码示例。如果您正苦于以下问题:C# LabelTarget类的具体用法?C# LabelTarget怎么用?C# LabelTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LabelTarget类属于命名空间,在下文中一共展示了LabelTarget类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
)
)
);
}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:30,代码来源:ComInvokeAction.cs
示例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;
}
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:LambdaCompiler.ControlFlow.cs
示例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])
);
}
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:7,代码来源:CMakeDynamic.cs
示例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;
}
开发者ID:mscottford,项目名称:ironruby,代码行数:8,代码来源:LambdaCompiler.ControlFlow.cs
示例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;
}
开发者ID:mscottford,项目名称:ironruby,代码行数:12,代码来源:LabelInfo.cs
示例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);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:LabelExpression.cs
示例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);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:15,代码来源:LoopExpression.cs
示例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);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:14,代码来源:GotoExpression.cs
示例9: ReferenceLabel
private LabelInfo ReferenceLabel(LabelTarget node) {
LabelInfo result = EnsureLabel(node);
result.Reference(_labelBlock);
return result;
}
开发者ID:mscottford,项目名称:ironruby,代码行数:5,代码来源:LambdaCompiler.ControlFlow.cs
示例10: LabelInfo
internal LabelInfo(ILGenerator il, LabelTarget node, bool canReturn) {
_ilg = il;
_node = node;
_canReturn = canReturn;
}
开发者ID:octavioh,项目名称:ironruby,代码行数:5,代码来源:LabelInfo.cs
示例11: TryGetLabelInfo
internal bool TryGetLabelInfo(LabelTarget target, out LabelInfo info) {
if (Labels == null) {
info = null;
return false;
}
return Labels.TryGetValue(target, out info);
}
开发者ID:octavioh,项目名称:ironruby,代码行数:8,代码来源:LabelInfo.cs
示例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);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:14,代码来源:LabelExpression.cs
示例13: GotoExpression
internal GotoExpression(GotoExpressionKind kind, LabelTarget target, Expression value, Type type) {
_kind = kind;
_value = value;
_target = target;
_type = type;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:6,代码来源:GotoExpression.cs
示例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);
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:8,代码来源:GotoExpression.cs
示例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);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:18,代码来源:GotoExpression.cs
示例16: Goto
/// <summary>
/// Creates a <see cref="GotoExpression"/> representing a goto with the specified type.
/// The value passed to the label upon jumping can be specified.
/// </summary>
/// <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 Goto,
/// 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 Goto(LabelTarget target, Expression value, Type type) {
return MakeGoto(GotoExpressionKind.Goto, target, value, type);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:16,代码来源:GotoExpression.cs
示例17: LabelExpression
internal LabelExpression(LabelTarget label, Expression defaultValue) {
_target = label;
_defaultValue = defaultValue;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:4,代码来源:LabelExpression.cs
示例18: Bind
/// <summary>
/// Performs the runtime binding of the dynamic operation on a set of arguments.
/// </summary>
/// <param name="args">An array of arguments to the dynamic operation.</param>
/// <param name="parameters">The array of <see cref="ParameterExpression"/> instances that represent the parameters of the call site in the binding process.</param>
/// <param name="returnLabel">A LabelTarget used to return the result of the dynamic binding.</param>
/// <returns>
/// An Expression that performs tests on the dynamic operation arguments, and
/// performs the dynamic operation if hte tests are valid. If the tests fail on
/// subsequent occurrences of the dynamic operation, Bind will be called again
/// to produce a new <see cref="Expression"/> for the new argument types.
/// </returns>
public sealed override Expression Bind(object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel) {
ContractUtils.RequiresNotNull(args, "args");
ContractUtils.RequiresNotNull(parameters, "parameters");
ContractUtils.RequiresNotNull(returnLabel, "returnLabel");
if (args.Length == 0) {
throw Error.OutOfRange("args.Length", 1);
}
if (parameters.Count == 0) {
throw Error.OutOfRange("parameters.Count", 1);
}
if (args.Length != parameters.Count) {
throw new ArgumentOutOfRangeException("args");
}
// Ensure that the binder's ReturnType matches CallSite's return
// type. We do this so meta objects and language binders can
// compose trees together without needing to insert converts.
Type expectedResult;
if (IsStandardBinder) {
expectedResult = ReturnType;
if (returnLabel.Type != typeof(void) &&
!TypeUtils.AreReferenceAssignable(returnLabel.Type, expectedResult)) {
throw Error.BinderNotCompatibleWithCallSite(expectedResult, this, returnLabel.Type);
}
} else {
// Even for non-standard binders, we have to at least make sure
// it works with the CallSite's type to build the return.
expectedResult = returnLabel.Type;
}
DynamicMetaObject target = DynamicMetaObject.Create(args[0], parameters[0]);
DynamicMetaObject[] metaArgs = CreateArgumentMetaObjects(args, parameters);
DynamicMetaObject binding = Bind(target, metaArgs);
if (binding == null) {
throw Error.BindingCannotBeNull();
}
Expression body = binding.Expression;
BindingRestrictions restrictions = binding.Restrictions;
// Ensure the result matches the expected result type.
if (expectedResult != typeof(void) &&
!TypeUtils.AreReferenceAssignable(expectedResult, body.Type)) {
//
// Blame the last person that handled the result: assume it's
// the dynamic object (if any), otherwise blame the language.
//
if (target.Value is IDynamicMetaObjectProvider) {
throw Error.DynamicObjectResultNotAssignable(body.Type, target.Value.GetType(), this, expectedResult);
} else {
throw Error.DynamicBinderResultNotAssignable(body.Type, this, expectedResult);
}
}
// if the target is IDO, standard binders ask it to bind the rule so we may have a target-specific binding.
// it makes sense to restrict on the target's type in such cases.
// ideally IDO metaobjects should do this, but they often miss that type of "this" is significant.
if (IsStandardBinder && args[0] as IDynamicMetaObjectProvider != null) {
if (restrictions == BindingRestrictions.Empty) {
throw Error.DynamicBindingNeedsRestrictions(target.Value.GetType(), this);
}
}
restrictions = AddRemoteObjectRestrictions(restrictions, args, parameters);
// Add the return
if (body.NodeType != ExpressionType.Goto) {
body = Expression.Return(returnLabel, body);
}
// Finally, add restrictions
if (restrictions != BindingRestrictions.Empty) {
body = Expression.IfThen(restrictions.ToExpression(), body);
}
return body;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:93,代码来源:DynamicMetaObjectBinder.cs
示例19: ContainsTarget
internal bool ContainsTarget(LabelTarget target) {
if (Labels == null) {
return false;
}
return Labels.ContainsKey(target);
}
开发者ID:octavioh,项目名称:ironruby,代码行数:7,代码来源:LabelInfo.cs
示例20: Loop
/// <summary>
/// Creates a <see cref="LoopExpression"/> with the given body.
/// </summary>
/// <param name="body">The body of the loop.</param>
/// <param name="break">The break target used by the loop body.</param>
/// <param name="continue">The continue target used by the loop body.</param>
/// <returns>The created <see cref="LoopExpression"/>.</returns>
public static LoopExpression Loop(Expression body, LabelTarget @break, LabelTarget @continue) {
RequiresCanRead(body, "body");
ContractUtils.Requires(@continue == null || @continue.Type == typeof(void), "continue", Strings.LabelTypeMustBeVoid);
return new LoopExpression(body, @break, @continue);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:12,代码来源:LoopExpression.cs
注:本文中的LabelTarget类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论