当前位置: 首页>>代码示例>>C#>>正文


C# Expression.Accept方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:48,代码来源:EmitAssembly.cs

示例2: EmitRawBranch

 void EmitRawBranch(bool branch, Expression expression, Label label)
 {
     expression.Accept(this); PopType();
     _il.Emit(branch ? OpCodes.Brtrue : OpCodes.Brfalse, label);
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:5,代码来源:EmitAssembly.cs

示例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);
            }
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:35,代码来源:EmitAssembly.cs

示例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);
     }
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:15,代码来源:EmitAssembly.cs

示例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);
		}
开发者ID:hlizard,项目名称:boo,代码行数:27,代码来源:EmitAssembly.cs

示例6: EmitRawBranchTrue

 void EmitRawBranchTrue(Expression expression, Label label)
 {
     expression.Accept(this); PopType();
     _il.Emit(OpCodes.Brtrue, label);
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:5,代码来源:EmitAssembly.cs

示例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);
     }
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:20,代码来源:EmitAssembly.cs

示例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);
     }
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:22,代码来源:EmitAssembly.cs


注:本文中的Boo.Lang.Compiler.Ast.Expression.Accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。