The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
VoidType.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: VoidType.cs //
6 // Authors: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Francisco Ortin - francisco.ortin@gmail.com //
8 // Description: //
9 // Represents a void type. //
10 // Inheritance: TypeExpression. //
11 // Implements Composite pattern [Leaf]. //
12 // Implements Singleton pattern. //
13 // -------------------------------------------------------------------------- //
14 // Create date: 22-10-2006 //
15 // Modification date: 20-02-2007 //
17 //visto
18 using System;
19 using System.Collections.Generic;
20 using System.Text;
21 using Tools;
22 using TypeSystem.Operations;
23 
24 namespace TypeSystem
25 {
34  public class VoidType : TypeExpression
35  {
36  #region Fields
37 
41  private static readonly VoidType instance = new VoidType();
42 
43  #endregion
44 
45  #region Properties
46 
50  public static VoidType Instance
51  {
52  get { return instance; }
53  }
54 
55  #endregion
56 
57  #region Constructors
58 
62  private VoidType()
63  {
64  this.typeExpression = "void";
65  this.fullName = "void";
66  }
67 
71  static VoidType()
72  {
73  }
74 
75  #endregion
76 
77  // WriteType Promotion
78 
79  #region Dispatcher
80  public override object AcceptOperation(TypeSystemOperation op, object arg) { return op.Exec(this, arg); }
81  #endregion
82 
83  #region PromotionLevel() ANULADA
84 
90  //public override int PromotionLevel(TypeExpression type)
91  //{
92  // if (type is VoidType)
93  // return 0;
94  // return -1;
95  //}
96 
97  #endregion
98 
99  #region IsValueType()
100 
105  public override bool IsValueType()
106  {
107  return false;
108  }
109 
110  #endregion
111 
112  // WriteType Unification
113 
114  #region Unify
115  public override bool Unify(TypeExpression te, SortOfUnification unification, IList<Pair<TypeExpression, TypeExpression>> previouslyUnified) {
123  VoidType vt = te as VoidType;
124  if (vt != null)
125  return true;
126  if (te is TypeVariable && unification!=SortOfUnification.Incremental)
127  // * No incremental unification is commutative
128  return te.Unify(this, unification, previouslyUnified);
129  return false;
130  }
131  #endregion
132 
133 
134  }
135 }
This class represent the entry wnen sending a message to an operation object derived from TypeExpress...
override bool IsValueType()
True if type expression is a ValueType. Otherwise, false.
Definition: VoidType.cs:105
Represents a void type.
Definition: VoidType.cs:34
Abstract class that represents all different types.
Represents a generic type expression
Definition: TypeVariable.cs:36
override bool Unify(TypeExpression te, SortOfUnification unification, IList< Pair< TypeExpression, TypeExpression >> previouslyUnified)
This method unifies two type expressions (this and te)
Definition: VoidType.cs:122
static VoidType Instance
Gets the unique instance of VoidType
Definition: VoidType.cs:51
override object AcceptOperation(TypeSystemOperation op, object arg)
Definition: VoidType.cs:80