コード例 #1
0
		public ConditionExpression( OpCode operation, Expression left, Expression right )
		{
			_trueStmts = new ArrayList();
			_falseStmts = new ArrayList();

			_operation = operation;
			_left = left;
			_right = right;
		}
コード例 #2
0
ファイル: ArgumentsUtil.cs プロジェクト: ralescano/castle
		public static Expression[] ConvertArgumentReferenceToExpression(ArgumentReference[] args)
		{
			Expression[] expressions = new Expression[args.Length];
			
			for(int i=0; i < args.Length; ++i)
			{
				expressions[i] = args[i].ToExpression();
			}

			return expressions;
		}
コード例 #3
0
ファイル: BinaryExpression.cs プロジェクト: ralescano/castle
		public BinaryExpression( OpCode operation, Expression left, Expression right )
		{
			_operation = operation;
			_left = left;
			_right = right;
		}
コード例 #4
0
ファイル: EasyCallable.cs プロジェクト: superliujian/Sxta
        private void GenerateCall()
        {
            ArgumentReference arg = new ArgumentReference( typeof(object[]) );
            _callmethod = CreateMethod( "Call",
                new ReturnReferenceExpression(typeof(object)), arg );

            // LocalReference localRef = method.CodeBuilder.DeclareLocal( typeof(object) );

            TypeReference[] dereferencedArguments = IndirectReference.WrapIfByRef(_args);
            LocalReference[] localCopies = new LocalReference[_args.Length];
            Expression[] invocationArguments = new Expression[_args.Length];

            // Load arguments from the object array.
            for (int i = 0; i < _args.Length; i++)
            {
                if (_args[i].Type.IsByRef)
                {
                    localCopies[i] = _callmethod.CodeBuilder.DeclareLocal(dereferencedArguments[i].Type);

                    _callmethod.CodeBuilder.AddStatement(new AssignStatement(localCopies[i],
                        new ConvertExpression(dereferencedArguments[i].Type,
                            new LoadRefArrayElementExpression(i, arg))));

                    invocationArguments[i] = localCopies[i].ToAddressOfExpression();
                }
                else
                {
                    invocationArguments[i] = new ConvertExpression(dereferencedArguments[i].Type,
                        new LoadRefArrayElementExpression(i, arg));
                }
            }

            // Invoke the method.
            MethodInvocationExpression methodInv = new MethodInvocationExpression(
                _invokeMethod,
                invocationArguments );

            Expression result = null;
            if (_returnType.Type == typeof(void))
            {
                _callmethod.CodeBuilder.AddStatement(new ExpressionStatement(methodInv));
                result = NullExpression.Instance;
            }
            else
            {
                LocalReference resultLocal = _callmethod.CodeBuilder.DeclareLocal(typeof(object));

                _callmethod.CodeBuilder.AddStatement(new AssignStatement(resultLocal,
                    new ConvertExpression(typeof(object), _returnType.Type, methodInv)));

                result = resultLocal.ToExpression();
            }

            // Save ByRef arguments into the object array.
            for (int i = 0; i < _args.Length; i++)
            {
                if (_args[i].Type.IsByRef)
                {
                    _callmethod.CodeBuilder.AddStatement(new AssignArrayStatement(arg, i,
                        new ConvertExpression(typeof(object), dereferencedArguments[i].Type,
                            localCopies[i].ToExpression())));
                }
            }

            // Return.
            _callmethod.CodeBuilder.AddStatement( new ReturnStatement( result ) );
        }
コード例 #5
0
		public ConditionExpression( OpCode operation, Expression left ) : this(operation, left, null)
		{
		}
コード例 #6
0
		public ConditionExpression( Expression left ) : this(OpCodes.Brfalse_S, left)
		{
		}
コード例 #7
0
        protected virtual MethodInfo GenerateCallbackMethodIfNecessary(MethodInfo method, Reference invocationTarget)
        {
            if (Context.HasMixins && _interface2mixinIndex.Contains(method.DeclaringType))
            {
                return method;
            }

            String name = String.Format("callback__{0}", method.Name);

            ParameterInfo[] parameters = method.GetParameters();

            ArgumentReference[] args = new ArgumentReference[parameters.Length];

            for(int i = 0; i < args.Length; i++)
            {
                args[i] = new ArgumentReference(parameters[i].ParameterType);
            }

            EasyMethod easymethod = MainTypeBuilder.CreateMethod(name,
                                                                 new ReturnReferenceExpression(method.ReturnType),
                                                                 MethodAttributes.HideBySig | MethodAttributes.Public, args);

            Expression[] exps = new Expression[parameters.Length];

            for(int i = 0; i < args.Length; i++)
            {
                exps[i] = args[i].ToExpression();
            }

            if (invocationTarget == null)
            {
                easymethod.CodeBuilder.AddStatement(
                    new ReturnStatement(
                        new MethodInvocationExpression(method, exps)));
            }
            else
            {
                easymethod.CodeBuilder.AddStatement(
                    new ReturnStatement(
                        new MethodInvocationExpression(invocationTarget, method, exps)));
            }

            return easymethod.MethodBuilder;
        }
コード例 #8
0
ファイル: AssignArrayStatement.cs プロジェクト: atczyc/castle
		public AssignArrayStatement( Reference targetArray, int targetPosition, Expression value )
		{
			_targetArray = targetArray;
			_targetPosition = targetPosition;
			_value = value;
		}
コード例 #9
0
ファイル: ReturnStatement.cs プロジェクト: ralescano/castle
		public ReturnStatement( Expression expression )
		{
			_expression = expression;
		}
コード例 #10
0
ファイル: ConvertExpression.cs プロジェクト: ralescano/castle
		public ConvertExpression( Type targetType, Type fromType, Expression right )
		{
			_target = targetType;
			_fromType = fromType;
			_right = right;
		}
コード例 #11
0
ファイル: ConvertExpression.cs プロジェクト: ralescano/castle
		public ConvertExpression( Type targetType, Expression right ) : this(targetType, typeof(object), right)
		{
		}
コード例 #12
0
ファイル: AssignStatement.cs プロジェクト: ralescano/castle
		public AssignStatement( Reference target, Expression expression )
		{
			_target = target;
			_expression = expression;
		}
コード例 #13
0
ファイル: ExpressionStatement.cs プロジェクト: atczyc/castle
		public ExpressionStatement( Expression expression )
		{
			_expression = expression;
		}