public CallFlowNode AddCallNode( IRoutineLocation location, IEnumerable <Expression> arguments = null, IEnumerable <FlowVariable> returnAssignments = null, CallKind kind = CallKind.Static, FlowNodeFlags flags = FlowNodeFlags.None) { Contract.Requires <InvalidOperationException>(this.Graph != null); Contract.Requires <ArgumentNullException>(location != null, nameof(location)); Contract.Requires <ArgumentException>(kind != CallKind.ObjectCreation || location.IsConstructor, nameof(kind)); var nodeId = this.nodeIdProvider.GenerateNewId(); var node = new CallFlowNode( this.Graph, nodeId, flags, location, arguments ?? Enumerable.Empty <Expression>(), returnAssignments ?? Enumerable.Empty <FlowVariable>(), kind); this.Graph.MutableNodes.Add(node); Contract.Assert(nodeId.Value == this.Graph.MutableNodes.IndexOf(node)); return(node); }
private MethodCallEffect BuildMethodCallEffect(Instruction instruction, CallKind callKind) { var methodOperand = (IMethod)instruction.Operand; var parameterCount = methodOperand.GetParameterCount(); var symbolicParameters = new SymbolicSlot[parameterCount]; for (int i = parameterCount - 1; i >= 0; i--) { symbolicParameters[i] = context.Frame.Pop(); } var signature = methodOperand.MethodSig; SymbolicSlot symbolicRetSlot = null; if (!IsSystemVoid(signature.RetType)) { symbolicRetSlot = new SymbolicSlot( new SymbolicReference( new MethodReturnSource(methodOperand))); context.Frame.Push(symbolicRetSlot); } return(new MethodCallEffect( methodOperand, symbolicParameters, symbolicRetSlot, callKind)); }
public MethodCall(MethodUniqueSignature signature, MethodDef methodDefinition, SymbolicSlot[] parameters, CallKind callKind) { Signature = signature; Definition = methodDefinition; Parameters = parameters; CallKind = callKind; }
public MethodCallEffect( IMethod method, SymbolicSlot[] symbolicParameters, SymbolicSlot symbolicRetSlot, CallKind callKind) : base(method.CreateMethodUniqueSignature(), method.ResolveMethodDef(), symbolicParameters, callKind) { OutputSlots = new List <SymbolicSlot>(method.MethodSig.Params.Count + 1); if (symbolicRetSlot != null) { OutputSlots.Add(symbolicRetSlot); } foreach (var index in method.EnumerateOutputParameterIndexes()) { OutputSlots.Add(symbolicParameters[index]); } }
public static CallOpcode GetCall(CallKind kind) { switch (kind) { case CallKind.EarlyBound: return(Call); case CallKind.Virtual: return(Callvirt); case CallKind.Indirect: return(Calli); case CallKind.Constructor: return(Newobj); case CallKind.Jump: return(Jmp); default: throw new ArgumentException("kind"); } }
internal CallFlowNode( FlowGraph graph, FlowNodeId id, FlowNodeFlags flags, IRoutineLocation location, IEnumerable <Expression> arguments, IEnumerable <FlowVariable> returnAssignments, CallKind kind) : base(graph, id, flags) { Contract.Requires(location != null); Contract.Requires(arguments != null); Contract.Requires(returnAssignments != null); Contract.Requires( kind != CallKind.ObjectCreation || VerifyConstructorUsage(location, returnAssignments), nameof(kind)); this.Location = location; this.Arguments = arguments.ToImmutableArray(); this.ReturnAssignments = returnAssignments.ToImmutableArray(); this.Kind = kind; }
protected abstract IEnumerable <SyntaxNode> GetCallArgumentExpressionNodes(SyntaxNode node, CallKind callKind);
protected override IEnumerable<SyntaxNode> GetCallArgumentExpressionNodes(SyntaxNode node, CallKind callKind) { if (node != null) { ArgumentListSyntax argList = null; SyntaxKind kind = node.Kind(); if ((kind == SyntaxKind.InvocationExpression) && ((callKind & CallKind.Invocation) != 0)) { var invocationNode = (InvocationExpressionSyntax)node; argList = invocationNode.ArgumentList; } else if ((kind == SyntaxKind.ObjectCreationExpression) && ((callKind & CallKind.ObjectCreation) != 0)) { var invocationNode = (ObjectCreationExpressionSyntax)node; argList = invocationNode.ArgumentList; } if (argList != null) { return argList.Arguments.Select(arg => arg.Expression); } } return Enumerable.Empty<SyntaxNode>(); }
protected override IEnumerable <SyntaxNode> GetCallArgumentExpressionNodes(SyntaxNode node, CallKind callKind) { if (node == null) { return(Enumerable.Empty <SyntaxNode>()); } ArgumentListSyntax argList = null; SyntaxKind kind = node.Kind(); switch (kind) { case SyntaxKind.InvocationExpression when(callKind& CallKind.Invocation) != 0: { var invocationNode = (InvocationExpressionSyntax)node; argList = invocationNode.ArgumentList; break; } case SyntaxKind.ObjectCreationExpression when(callKind& CallKind.ObjectCreation) != 0: { var invocationNode = (ObjectCreationExpressionSyntax)node; argList = invocationNode.ArgumentList; break; } } if (argList != null) { return(argList.Arguments.Select(arg => arg.Expression)); } return(Enumerable.Empty <SyntaxNode>()); }
protected override IEnumerable <SyntaxNode> GetCallArgumentExpressionNodes(SyntaxNode node, CallKind callKind) { if (node == null) { return(null); } ArgumentListSyntax argList = null; SyntaxKind kind = node.Kind(); switch (kind) { case SyntaxKind.InvocationExpression when(callKind& CallKind.Invocation) != 0: argList = ((InvocationExpressionSyntax)node).ArgumentList; break; case SyntaxKind.ObjectCreationExpression when(callKind& CallKind.ObjectCreation) != 0: argList = ((ObjectCreationExpressionSyntax)node).ArgumentList; break; } if (argList != null) { return(from arg in argList.Arguments select arg.GetExpression()); } return(Enumerable.Empty <SyntaxNode>()); }
protected override IEnumerable <SyntaxNode> GetCallArgumentExpressionNodes(SyntaxNode node, CallKind callKind) { if (node != null) { ArgumentListSyntax argList = null; SyntaxKind kind = node.Kind(); if ((kind == SyntaxKind.InvocationExpression) && ((callKind & CallKind.Invocation) != 0)) { var invocationNode = (InvocationExpressionSyntax)node; argList = invocationNode.ArgumentList; } else if ((kind == SyntaxKind.ObjectCreationExpression) && ((callKind & CallKind.ObjectCreation) != 0)) { var invocationNode = (ObjectCreationExpressionSyntax)node; argList = invocationNode.ArgumentList; } if (argList != null) { return(argList.Arguments.Select(arg => arg.Expression)); } } return(Enumerable.Empty <SyntaxNode>()); }
protected abstract IEnumerable<SyntaxNode> GetCallArgumentExpressionNodes(SyntaxNode node, CallKind callKind);
public void Call(CallKind kind, MethodBase method) { Contract.Requires(method != null); Call(Opcode.GetCall(kind), method); }