本文整理汇总了C#中System.Linq.Expressions.LabelTarget类的典型用法代码示例。如果您正苦于以下问题:C# LabelTarget类的具体用法?C# LabelTarget怎么用?C# LabelTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LabelTarget类属于System.Linq.Expressions命名空间,在下文中一共展示了LabelTarget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ForCSharpStatement
internal ForCSharpStatement(ReadOnlyCollection<ParameterExpression> variables, ReadOnlyCollection<Expression> initializers, Expression test, ReadOnlyCollection<Expression> iterators, Expression body, LabelTarget breakLabel, LabelTarget continueLabel)
: base(test, body, breakLabel, continueLabel)
{
Variables = variables;
Initializers = initializers;
Iterators = iterators;
}
示例2: Update
public Expression Update(LabelTarget labelTarget, Type type) {
if (LabelTarget.Equals(labelTarget) && Type.Equals(type)) {
return this;
}
return AstExpression.Label(_labelStatement, ParentScope, Visitor);
}
示例3: Update
public Expression Update(LabelTarget labelTarget, Type type) {
if (LabelTarget.Equals(labelTarget) && Type.Equals(type)) {
return this;
}
return AstExpression.Goto(_gotoStatement, this as IScope, Visitor);
}
示例4: BeforeVisit
public override void BeforeVisit(Function node)
{
base.BeforeVisit(node);
//_currentOutputExp = Expression.Parameter(typeof (TextWriter), CurrentOutputIdentifier);
//Create return target
_returnLabelTarget = Expression.Label(typeof(object), "lambdaReturn");
}
示例5: Compile
public override Expression Compile(ParameterExpression stateParameterExpression, LabelTarget returnTarget, LogicExpression valueExpression)
{
var value = this.Target.Compile(stateParameterExpression, returnTarget);
var convertedValue = Expression.Convert(value, typeof(LogicStructureInstance));
var valueVariable = Expression.Variable(typeof(LogicStructureInstance), "value");
var field = Expression.Variable(typeof(LogicField), "field");
Expression<Func<LogicStructureInstance, string, LogicField>> lookupField =
(x, z) => x.Fields.Keys.First(y => y.Name == z);
var assignValue = Expression.Assign(valueVariable, convertedValue);
var assignFieldName = Expression.Assign(
field,
Expression.Invoke(lookupField, valueVariable, Expression.Constant(this.Field)));
var assignField =
Expression.Assign(
Expression.Property(Expression.Property(valueVariable, "Fields"), "Item", field),
Expression.Convert(valueExpression.Compile(stateParameterExpression, returnTarget), typeof(object)));
var assignFieldSet =
Expression.Assign(
Expression.Property(Expression.Property(valueVariable, "FieldsSet"), "Item", field),
Expression.Constant(true));
return Expression.Block(
new[] { valueVariable, field },
assignValue,
assignFieldName,
assignField,
assignFieldSet);
}
示例6: GotoExpression
internal GotoExpression(GotoExpressionKind kind, LabelTarget target, Expression value, Type type)
{
_kind = kind;
_value = value;
_target = target;
_type = type;
}
示例7: Bind
public sealed override Expression Bind(object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel) {
if (args.Length == 0) {
throw new InvalidOperationException();
}
MetaObject[] mos;
if (args.Length != 1) {
mos = new MetaObject[args.Length - 1];
for (int i = 1; i < args.Length; i++) {
mos[i - 1] = MetaObject.ObjectToMetaObject(args[i], parameters[i]);
}
} else {
mos = MetaObject.EmptyMetaObjects;
}
MetaObject binding = Bind(
MetaObject.ObjectToMetaObject(args[0], parameters[0]),
mos
);
if (binding == null) {
throw Error.BindingCannotBeNull();
}
return GetMetaObjectRule(binding, returnLabel);
}
示例8: Loop
public static LoopExpression Loop(Expression body, LabelTarget @break, LabelTarget @continue) {
RequiresCanRead(body, "body");
// TODO: lift the restriction on break, and allow loops to have non-void type
ContractUtils.Requires(@break == null || @break.Type == typeof(void), "break", Strings.LabelTypeMustBeVoid);
ContractUtils.Requires(@continue == null || @continue.Type == typeof(void), "continue", Strings.LabelTypeMustBeVoid);
return new LoopExpression(body, @break, @continue);
}
示例9: Update
public ForEachExpression Update(ParameterExpression variable, Expression enumerable, Expression body, LabelTarget breakTarget, LabelTarget continueTarget)
{
if (this.variable == variable && this.enumerable == enumerable && this.body == body && break_target == breakTarget && continue_target == continueTarget)
return this;
return CustomExpression.ForEach(variable, enumerable, body, continueTarget, breakTarget);
}
示例10: Update
public Expression Update(LabelTarget target, Type type, Expression value) {
if (Target.Equals(target) && Type.Equals(type) && Value.Equals(value)) {
return this;
}
return AstExpression.Break(_breakStatement, ParentScope, Visitor);
}
示例11: AplusScope
public AplusScope(AplusScope parent,
string name,
Aplus runtime = null,
DLR.ParameterExpression runtimeParam = null,
DLR.ParameterExpression moduleParam = null,
DLR.LabelTarget returnTarget = null,
bool isEval = false,
bool isMethod = false,
bool isAssignment = false)
{
this.parent = parent;
this.name = name;
this.runtime = runtime;
this.runtimeParam = runtimeParam;
this.moduleParam = moduleParam;
this.returnTarget = returnTarget;
this.variables = new Dictionary<string, DLR.ParameterExpression>();
this.callbackInfo = new CallbackInfoStorage();
this.iseval = isEval;
this.ismethod = isMethod;
this.isAssignment = isAssignment;
InheritProperties(parent);
}
示例12: Update
public Expression Update(LabelTarget label, Type type) {
if (LabelTarget.Equals(label) && Type.Equals(type)) {
return this;
}
return AstExpression.Continue(_continueStatement, this as IScope, Visitor);
}
示例13: Update
public Expression Update(GotoExpressionKind kind, LabelTarget target, Expression value) {
if (Target.Equals(target) && ReferenceEquals(Value, value) && Kind == kind) {
return this;
}
return AstExpression.Return(_returnStatement, ParentScope, Visitor);
}
示例14: Update
public Expression Update(LabelTarget target, Expression defaultValue) {
if (Target.Equals(target) && DefaultValue == defaultValue) {
return this;
}
return AstExpression.Label(_caseLabel, ParentScope, Visitor);
}
示例15: Switch
public static SwitchExpression Switch(Expression value, LabelTarget label, IEnumerable<SwitchCase> cases) {
RequiresCanRead(value, "value");
ContractUtils.Requires(value.Type == typeof(int), "value", Strings.ValueMustBeInt);
ContractUtils.RequiresNotNull(cases, "cases");
var caseList = cases.ToReadOnly();
ContractUtils.RequiresNotEmpty(caseList, "cases");
ContractUtils.RequiresNotNullItems(caseList, "cases");
// TODO: does it make sense for switch to have non-void type?
ContractUtils.Requires(label == null || label.Type == typeof(void), "label", Strings.LabelTypeMustBeVoid);
bool @default = false;
int max = Int32.MinValue;
int min = Int32.MaxValue;
foreach (SwitchCase sc in caseList) {
if (sc.IsDefault) {
ContractUtils.Requires(@default == false, "cases", Strings.OnlyDefaultIsAllowed);
@default = true;
} else {
int val = sc.Value;
if (val > max) max = val;
if (val < min) min = val;
}
}
ContractUtils.Requires(UniqueCaseValues(caseList, min, max), "cases", Strings.CaseValuesMustBeUnique);
return new SwitchExpression(value, label, caseList);
}