/// <summary> /// Adds a new argument to this object /// </summary> public void AddArgument(ILiteral argument) { // Get the assignments for this argument var assignments = argument.Flatten().ToArray(); // The first assignment defines the argument value, and the rest are just other variables var rootAssignment = assignments[0]; var variableAssignments = assignments.Skip(1); // If the root assignment is a variable, use a variable argument assignment instead if (rootAssignment.Value.UnificationKey == null) { var variableRoot = rootAssignment; variableAssignments = variableAssignments.Concat(new[] { variableRoot }); rootAssignment = new ArgumentAssignment(new Variable(), variableRoot.Variable); } // Store the list of other assignments _arguments.Add(rootAssignment); _otherAssignments.AddRange(variableAssignments); }