Beispiel #1
0
		private bool IsResultExpression (Expression expression)
		{
			var methodCall = expression as MethodCall;
			if (methodCall == null)
				return false;

			var memberBinding = methodCall.Callee as MemberBinding;
			if (memberBinding == null)
				return false;

			var method = memberBinding.BoundMember as Method;
			if (method == null)
				return false;

			return method.HasGenericParameters && method.Name == "Result" && method.DeclaringType != null && method.DeclaringType.Name == "Contract";
		}
Beispiel #2
0
		private MethodCall ParseCall (Instruction instruction, NodeType typeOfCall, out bool isStatement)
		{
			Method method = GetMethodFromMethodCallInstruction (instruction);
			isStatement = TypeIsVoid (method.ReturnType);
			int parametersCount = method.Parameters == null ? 0 : method.Parameters.Count;
			int n = typeOfCall != NodeType.Jmp ? parametersCount : 0;
			List<Expression> arguments;
			{
				var expressions = new Expression[n];

				for (int index = n - 1; index >= 0; --index)
					expressions [index] = PopOperand ();
				arguments = new List<Expression> (expressions);
			}

			var methodCall = new MethodCall (new MemberBinding (method.IsStatic ? null : PopOperand (), method), arguments, typeOfCall) {Type = method.ReturnType};
			return methodCall;
		}
Beispiel #3
0
		private Expression ParseBinaryExpressionWithoutType (NodeType operatorType, out Expression op1, out Expression op2)
		{
			op2 = PopOperand ();
			op1 = PopOperand ();

			return new BinaryExpression (operatorType, op1, op2);
		}
Beispiel #4
0
		private Expression ParseNewObjectCreation (Instruction inst)
		{
			Method method = GetMethodFromMethodCallInstruction (inst);
			int count = method.Parameters.Count;
			List<Expression> arguments;
			{
				var expressions = new Expression[count];
				for (int index = count - 1; index >= 0; index--)
					expressions [index] = PopOperand ();

				arguments = new List<Expression> (expressions);
			}

			var construct = new Construct (new MemberBinding (null, method), arguments) {Type = method.DeclaringType};

			return construct;
		}
Beispiel #5
0
		public Construct (Expression constructor, List<Expression> arguments)
			: base (arguments, NodeType.Construct)
		{
			Constructor = constructor;
		}
Beispiel #6
0
		public MethodCall (Expression callee, List<Expression> arguments, NodeType typeOfCall)
			: base (arguments, typeOfCall)
		{
			Callee = callee;
		}