本文整理汇总了C#中Boo.Lang.Compiler.Ast.Expression.Accept方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.Accept方法的具体用法?C# Expression.Accept怎么用?C# Expression.Accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Boo.Lang.Compiler.Ast.Expression
的用法示例。
在下文中一共展示了Expression.Accept方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetProperty
void SetProperty(IProperty property, Expression reference, Expression value, bool leaveValueOnStack)
{
OpCode callOpCode = OpCodes.Call;
MethodInfo setMethod = GetMethodInfo(property.GetSetMethod());
IType targetType = null;
if (null != reference)
{
if (!setMethod.IsStatic)
{
Expression target = ((MemberReferenceExpression)reference).Target;
targetType = target.ExpressionType;
if (setMethod.DeclaringType.IsValueType || targetType is IGenericParameter)
LoadAddress(target);
else
{
callOpCode = GetCallOpCode(target, property.GetSetMethod());
target.Accept(this);
PopType();
}
}
}
value.Accept(this);
EmitCastIfNeeded(property.Type, PopType());
LocalBuilder local = null;
if (leaveValueOnStack)
{
_il.Emit(OpCodes.Dup);
local = _il.DeclareLocal(GetSystemType(property.Type));
_il.Emit(OpCodes.Stloc, local);
}
if (targetType is IGenericParameter)
{
_il.Emit(OpCodes.Constrained, GetSystemType(targetType));
callOpCode = OpCodes.Callvirt;
}
_il.EmitCall(callOpCode, setMethod, null);
if (leaveValueOnStack)
{
_il.Emit(OpCodes.Ldloc, local);
PushType(property.Type);
}
}
示例2: EmitRawBranch
void EmitRawBranch(bool branch, Expression expression, Label label)
{
expression.Accept(this); PopType();
_il.Emit(branch ? OpCodes.Brtrue : OpCodes.Brfalse, label);
}
示例3: SetField
void SetField(Node sourceNode, IField field, Expression reference, Expression value, bool leaveValueOnStack)
{
OpCode opSetField = OpCodes.Stsfld;
if (!field.IsStatic)
{
opSetField = OpCodes.Stfld;
if (null != reference)
{
LoadMemberTarget(
((MemberReferenceExpression)reference).Target,
field);
}
}
value.Accept(this);
EmitCastIfNeeded(field.Type, PopType());
LocalBuilder local = null;
if (leaveValueOnStack)
{
_il.Emit(OpCodes.Dup);
local = _il.DeclareLocal(GetSystemType(field.Type));
_il.Emit(OpCodes.Stloc, local);
}
if (field.IsVolatile)
_il.Emit(OpCodes.Volatile);
_il.Emit(opSetField, GetFieldInfo(field));
if (leaveValueOnStack)
{
_il.Emit(OpCodes.Ldloc, local);
PushType(field.Type);
}
}
示例4: EmitDefaultBranch
void EmitDefaultBranch(bool branch, Expression expression, Label label)
{
expression.Accept(this);
IType type = PopType();
if (type == TypeSystemServices.DoubleType || type == TypeSystemServices.SingleType)
{
EmitDefaultValue(type);
_il.Emit(branch ? OpCodes.Bne_Un : OpCodes.Beq, label);
}
else
{
EmitToBoolIfNeeded(expression);
_il.Emit(branch ? OpCodes.Brtrue : OpCodes.Brfalse, label);
}
}
示例5: EmitDefaultBranch
void EmitDefaultBranch(bool branch, Expression condition, Label label)
{
if (branch && IsOneEquivalent(condition))
{
_il.Emit(OpCodes.Br, label);
return;
}
if (!branch && IsZeroEquivalent(condition))
{
_il.Emit(OpCodes.Br, label);
return;
}
condition.Accept(this);
var type = PopType();
if (TypeSystemServices.IsFloatingPointNumber(type))
{
EmitDefaultValue(type);
_il.Emit(branch ? OpCodes.Bne_Un : OpCodes.Beq, label);
return;
}
EmitToBoolIfNeeded(condition);
_il.Emit(branch ? OpCodes.Brtrue : OpCodes.Brfalse, label);
}
示例6: EmitRawBranchTrue
void EmitRawBranchTrue(Expression expression, Label label)
{
expression.Accept(this); PopType();
_il.Emit(OpCodes.Brtrue, label);
}
示例7: DefaultBranchTrue
void DefaultBranchTrue(Expression expression, Label label)
{
expression.Accept(this);
IType type = PopType();
if (TypeSystemServices.DoubleType == type)
{
_il.Emit(OpCodes.Ldc_R8, 0.0);
_il.Emit(OpCodes.Bne_Un, label);
}
else if (TypeSystemServices.SingleType == type)
{
_il.Emit(OpCodes.Ldc_R4, 0.0f);
_il.Emit(OpCodes.Bne_Un, label);
}
else
{
EmitToBoolIfNeeded(expression);
_il.Emit(OpCodes.Brtrue, label);
}
}
示例8: DefaultBranchFalse
void DefaultBranchFalse(Expression expression, Label label)
{
expression.Accept(this);
IType type = PopType();
if (TypeSystemServices.DoubleType == type)
{
_il.Emit(OpCodes.Ldc_R8, (double)0.0);
_il.Emit(OpCodes.Ceq);
_il.Emit(OpCodes.Brtrue, label);
}
else if (TypeSystemServices.SingleType == type)
{
_il.Emit(OpCodes.Ldc_R4, (float)0.0);
_il.Emit(OpCodes.Ceq);
_il.Emit(OpCodes.Brtrue, label);
}
else
{
EmitToBoolIfNeeded(expression);
_il.Emit(OpCodes.Brfalse, label);
}
}