The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
Constraint.cs
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
3 // Project rROTOR
4 // --------------------------------------------------------------------------
5 // File: ConstraintList.cs
6 // Author: Francisco Ortin - francisco.ortin@gmail.com
7 // Description:
8 // Abstract class that represents any constraint to be part of a Method WriteType.
9 // In our type system, methods could have constraints associated to be
10 // satisfied every time it is invoked. This class represent the
11 // homogeneous treatment of the Composite desing pattern.
12 // Implements Composite pattern [Component].
13 // Implements Command pattern [Command].
14 // --------------------------------------------------------------------------
15 // Create date: 05-04-2007
16 // Modification date: 25-04-2007
18 
19 using System;
20 using System.Collections.Generic;
21 using System.Text;
22 using ErrorManagement;
23 
24 namespace TypeSystem.Constraints {
25  abstract public class Constraint {
26 
27  #region Fields
28  private string typeExpression;
32 
36  private bool validTypeExpression = false;
37  #endregion
38 
39  #region Properties
40  public bool ValidTypeExpression {
44  set {
45  if (!value)
46  this.typeExpression = this.BuildTypeExpressionString();
47  }
48  }
49  #endregion
50 
51 
56  public virtual bool isEmpty() { return false; }
57 
58  public override string ToString() {
59  if (this.validTypeExpression)
60  return this.typeExpression;
61  return this.typeExpression = this.BuildTypeExpressionString();
62  }
63 
64  protected abstract string BuildTypeExpressionString();
65 
74  public abstract Constraint CloneTypeVariables(IDictionary<TypeVariable, TypeVariable> typeVariableMappings, IList<EquivalenceClass> equivalenceClasses);
75 
86  public abstract TypeExpression Check(MethodType methodAnalyzed, TypeExpression actualImplicitObject, bool showInvocationMessage,
87  SortOfUnification activeSortOfUnification, Location location);
88  }
89 }
This class encapsulates a location in a specific file. Implements an Inmutable pattern. So it can be used in any context, that is his internal fields never change.
Definition: Location.cs:24
Abstract class that represents all different types.
virtual bool isEmpty()
To know if any constraint has been set
Definition: Constraint.cs:56
Representa a method type.
Definition: MethodType.cs:37