public override Evaluation VisitObjectCreationExpression(ObjectCreationExpressionSyntax node) { //node.ArgumentList?.Accept(this); Evaluation evaluation = node.Initializer?.Accept <Evaluation>(this); //TODO - choose ret EvaluationList accept = node.ArgumentList.Accept <Evaluation>(this) as EvaluationList; node.Type?.Accept <Evaluation>(this); ITypeSymbol type = node.Type.GetSymbol(_comp) as ITypeSymbol; Instance instance = _callStack.Peek().CreateInstance(type, type.ToNodeKind()); GraphBuilder <Evaluation> .From(_callStack.Peek().Node).Kind(EdgeKind.CreatesObject).To(instance.Node); InitializeInstance(instance); FunctionalFrame constructor = instance.InstanceHeap.CreateFrame(node.GetReference(), _comp, type.ToNodeKind()); GraphBuilder <Evaluation> .From(instance.Node).Kind(EdgeKind.InvokesMember).To(constructor.Node); SimulateFrame(constructor, EvaluationUtil.From <Instance>(accept).ToArray()); return(instance); }
public override Evaluation VisitInvocationExpression(InvocationExpressionSyntax node) { EvaluationList args = node.ArgumentList?.Accept <Evaluation>(this) as EvaluationList; Evaluation methodExpression = node.Expression?.Accept <Evaluation>(this); IMethodSymbol declaringSymbol = node.GetSymbol(_comp) as IMethodSymbol; if (declaringSymbol == null) { throw new Exception("Unhandled symbol type"); } if (declaringSymbol.DeclaringSyntaxReferences.Length != 1) { throw new Exception("Unhandled declaring references length"); } SyntaxReference methReference = declaringSymbol.DeclaringSyntaxReferences.FirstOrDefault(); Frame newFrame = null; if (declaringSymbol.IsStatic) { //static method calls have no "instance" newFrame = StaticInstance.InstanceHeap.CreateFrame(methReference, _comp, declaringSymbol.ToNodeKind()); } else { //method call on an instance IEnumerable <Instance> findInstance = FindInstance(node.GetReference()); if (findInstance.Count() != 1) { throw new Exception("Unhandled instance length"); } Instance instance = findInstance.FirstOrDefault(); newFrame = instance.InstanceHeap.CreateFrame(methReference, _comp, declaringSymbol.ToNodeKind()); } //TODO link expression target to invocation SimulateFrame(newFrame, EvaluationUtil.From <Instance>(args).ToArray()); return(base.VisitInvocationExpression(node)); }