1 using Mercury.Exceptions;
3 using System.Collections.Generic;
7 namespace Mercury.Interpreting
23 private int? memHash = null;
36 if (action == null)
throw new ArgumentNullException(
"action");
37 if (formalparams == null)
throw new ArgumentNullException(
"formalparams");
40 FormalParameters = formalparams.ToArray();
41 Type = ParameterType.ActionCall;
43 if ((Action.Arity.Item2 < FormalParameters.Count) || (FormalParameters.Count < Action.Arity.Item1))
51 public IReadOnlyList<IFormalParameter> FormalParameters {
get;
private set; }
61 public override bool Equals(
object obj)
64 return obj == null ?
false : Equals(other);
69 if (!memHash.HasValue)
71 memHash = 19 * Action.Name.GetHashCode();
73 for (
int ix = 0; ix < FormalParameters.Count; ++ix)
74 memHash = 17 * memHash + FormalParameters[ix].GetHashCode();
82 StringBuilder sb =
new StringBuilder(
"(").Append(Action.Name);
84 if (FormalParameters.Count != 0)
86 sb.Append(
' ').Append(FormalParameters[0]);
88 for (
int ix = 1; ix < FormalParameters.Count; ++ix)
89 sb.Append(
' ').Append(FormalParameters[ix]);
92 return sb.Append(
")").ToString();
99 #region [ IFormalParameter ]
105 #region [ IEquatable ]
109 return (other != null)
110 && (Action.Name == other.Action.Name)
112 && (FormalParameters.Zip(other.FormalParameters, (x, y) => x.Equals(y)).All(x => x));
override int GetHashCode()
bool Equals(ActionCall< T > other)
An exception representing a problem with Mercury.Interpreting.ActionCall{T}
Function that wraps constant values in the RHS
ParameterType
Formal Parameter Type
override string ToString()
This class represents the application of Mercury.Interpreting.InterpreterAction{T} on the Mercury...
ActionCall(InterpreterAction< T > action, IEnumerable< IFormalParameter > formalparams)
Initializes a new instance of the ActionCall{T} class.
IReadOnlyList< IFormalParameter > FormalParameters
The list of formal parameters.
override bool Equals(object obj)