The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
EqualsForOverloadOperation.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2 using Tools;
3 namespace TypeSystem.Operations {
9  #region Fields
10  private TypeExpression typeExpression;
11  #endregion
12  #region Constructor
13  public EqualsForOverloadOperation(TypeExpression typeExpression) {
14  this.typeExpression = typeExpression;
15  }
16  #endregion
17 
18  #region Methods
19  #region Equals.TypeExpresion
20  public override object Exec(TypeExpression te, object arg) {
21  return te.Equals(this.typeExpression);
22  }
23  #endregion
24  #region Equals.MethodType
25  public override object Exec(MethodType m, object arg) {
26  MethodType method = this.typeExpression as MethodType;
27  if (method == null)
28  return false;
29  if (m.ParameterListCount != method.ParameterListCount)
30  return false;
31  for (int i = 0; i < method.ParameterListCount; i++)
32  if (!(bool)m.GetParameter(i).AcceptOperation(new EqualsForOverloadOperation(method.GetParameter(i)), arg))
33  return false;
34  return true;
35  }
36  #endregion
37  #region Equals.ClassTypeProxy
38  public override object Exec(ClassTypeProxy ct, object arg) {
39  return ct.RealType.AcceptOperation(new EqualsForOverloadOperation(this.typeExpression), arg);
40  }
41  #endregion
42  #region Equals.TypeVariable
43  public override object Exec(TypeVariable t, object arg) {
44  return this.typeExpression is TypeVariable;
45  }
46  #endregion
47  #region Errors
48  public override object ReportError(TypeExpression firstOperand) {
49  throw new System.NotImplementedException();
50  }
51  #endregion
52  #endregion
53  }
54 }
override object Exec(MethodType m, object arg)
This class represent the entry wnen sending a message to an operation object derived from TypeExpress...
Implemeents a double dispatcher pattern Role:
Abstract class that represents all different types.
Represents a generic type expression
Definition: TypeVariable.cs:36
Represents a proxy of a class type. It implements the unfold operatations of theoretical type systes...
int ParameterListCount
Gets the number of parameters
Definition: MethodType.cs:111
override object Exec(TypeExpression te, object arg)
override object Exec(TypeVariable t, object arg)
override object Exec(ClassTypeProxy ct, object arg)
Representa a method type.
Definition: MethodType.cs:37
TypeExpression GetParameter(int index)
Gets the type expression of the specific parameter
Definition: MethodType.cs:202
override object ReportError(TypeExpression firstOperand)