1 using System.Collections.Generic;
2 using DynVarManagement;
4 namespace TypeSystem.Operations {
24 this.secondOperand = secondOperand;
29 public override object Exec(
ArrayType firstOperand,
object arg) {
38 return firstOperand.ArrayTypeExpression.Equals(array.ArrayTypeExpression) ? 0 : -1;
41 if (typeVariable != null && typeVariable.Substitution == null)
45 if (unionType != null)
46 return unionType.SuperType(firstOperand);
49 if (fieldType != null)
52 return firstOperand.AsClassType().AcceptOperation(
this, arg);
57 public override object Exec(
BoolType firstOperand,
object arg) {
68 TypeVariable typeVariable = this.secondOperand as TypeVariable;
70 if (typeVariable != null && typeVariable.
Substitution == null)
76 if (unionType != null)
77 return unionType.SuperType(firstOperand);
81 if (fieldType != null)
82 return firstOperand.AcceptOperation(
new PromotionLevelOperation(fieldType.FieldTypeExpression), arg);
85 return firstOperand.AsClassType().AcceptOperation(
this, arg);
95 if (firstOperand == this.secondOperand)
103 if (fieldType != null)
107 TypeVariable typeVariable = this.secondOperand as TypeVariable;
108 if (typeVariable != null) {
109 if (typeVariable.Substitution != null)
111 return firstOperand.AcceptOperation(
new PromotionLevelOperation(typeVariable.EquivalenceClass.Substitution), arg);
120 if ((
bool)firstOperand.BaseClass.AcceptOperation(equivalentType, arg))
131 for (
int i = 0; i < firstOperand.InterfaceList.Count; i++) {
132 if ((
bool)firstOperand.
InterfaceList[i].AcceptOperation(equivalentType, arg)) {
133 if (less > 1 || less == -1)
136 aux = (int)firstOperand.
InterfaceList[i].AcceptOperation(
this, arg);
138 if (less > aux + 1 || less == -1)
149 if (unionType != null)
150 return unionType.SuperType(firstOperand);
157 #region ClassTypeProxy-->#
159 return firstOperand.RealType.AcceptOperation(
this, arg);
175 TypeVariable typeVariable = this.secondOperand as TypeVariable;
176 if (typeVariable != null && typeVariable.
Substitution == null)
181 if (unionType != null)
182 return unionType.SuperType(firstOperand);
185 if (fieldType != null)
189 return firstOperand.AsClassType().AcceptOperation(
this, arg);
201 TypeVariable typeVariable = this.secondOperand as TypeVariable;
202 if (typeVariable != null && typeVariable.
Substitution == null)
207 if (unionType != null)
208 return unionType.SuperType(firstOperand);
211 if (fieldType != null)
214 return firstOperand.AsClassType().AcceptOperation(
this, arg);
219 #region FieldType-->#
222 return firstOperand.FieldTypeExpression.AcceptOperation(
this, arg);
227 #region InterfaceType-->#
235 TypeVariable typeVariable = this.secondOperand as TypeVariable;
236 if (typeVariable != null) {
246 if (fieldType != null)
251 for (
int i = 0; i < firstOperand.InterfaceList.Count; i++) {
252 if ( (
bool)firstOperand.InterfaceList[i].AcceptOperation(
new EquivalentOperation(this.secondOperand), arg) ) {
253 if ((less > 1) || (less == -1))
256 aux = (int)firstOperand.
InterfaceList[i].AcceptOperation(
this, arg);
258 if (less > aux + 1 || less == -1)
269 if (unionType != null)
270 return unionType.SuperType(firstOperand);
286 TypeVariable typeVariable = this.secondOperand as TypeVariable;
287 if (typeVariable != null && typeVariable.
Substitution == null)
291 if (unionType != null)
292 return unionType.SuperType(firstOperand);
295 if (fieldType != null)
298 return firstOperand.AsClassType().AcceptOperation(
this, arg);
309 if (bclClass != null) {
316 TypeVariable typeVariable = this.secondOperand as TypeVariable;
317 if (typeVariable != null) {
326 if (unionType != null)
327 return unionType.SuperType(firstOperand);
330 if (fieldType != null)
337 #region PropertyType-->#
340 return firstOperand.PropertyTypeExpression.AcceptOperation(
this, arg);
346 #region StringType-->#
353 TypeVariable typeVariable = this.secondOperand as TypeVariable;
354 if (typeVariable != null && typeVariable.
Substitution == null)
359 if (unionType != null)
360 return unionType.SuperType(firstOperand);
363 if (fieldType != null)
366 return firstOperand.AsClassType().AcceptOperation(
this, arg);
372 #region TypeExpression-->#
379 #region TypeVariable-->#
380 public override object Exec(TypeVariable firstOperand,
object arg) {
382 DynVarOptions.Instance.AssignDynamism(firstOperand.Substitution, firstOperand.IsDynamic);
384 return firstOperand.EquivalenceClass.Substitution.AcceptOperation(
this, arg);
391 #region UnionType-->#
394 private static IList<UnionType> recursivePromotionLevelDetection =
new List<UnionType>();
398 if (recursivePromotionLevelDetection.Contains(firstOperand))
400 recursivePromotionLevelDetection.Add(firstOperand);
403 int promotionLevel = firstOperand.IsDynamic ? Int32.MaxValue : 0;
406 if (firstOperand.
IsDynamic && aux != -1) {
408 promotionLevel = Math.Min(promotionLevel, aux);
409 if (promotionLevel == 0)
418 promotionLevel += aux;
421 if (firstOperand.
IsDynamic && promotionLevel == Int32.MaxValue)
425 recursivePromotionLevelDetection.Clear();
426 return promotionLevel;
432 return this.secondOperand is
VoidType ? 0 : -1;
436 #region ReportError()
438 System.Diagnostics.Debug.Assert(
false,
"Error en código op1 = " + firstOperand +
"OP2=" + this.secondOperand);
TypeExpression Substitution
A equivalence class could be bounded to a unique no variable type
Representa an array type.
This class represent the entry wnen sending a message to an operation object derived from TypeExpress...
Represents a interface type.
Represent a character type.
Abstract class that represents all different types.
Represents a generic type expression
Represents a proxy of a class type. It implements the unfold operatations of theoretical type systes...
No location information is provided within this class, because the exec methods invoked by the proper...
Represent a integer type.
Type TypeInfo
Returns the real introspective type
Represents a double type.
TypeExpression FieldTypeExpression
Gets the field type.
List< InterfaceType > InterfaceList
Gets the list of interfaces
virtual bool IsDynamic
Indicates if the type has been set as dynamic
Representa a property type.
override object AcceptOperation(TypeSystemOperation op, object arg)
ClassType BaseClass
Gets the base type (null if not exists).
TypeExpression Substitution
Gets the substitution; null if it does not exist
TypeExpression PropertyTypeExpression
Gets the property type.
override object AcceptOperation(TypeSystemOperation op, object arg)
EquivalenceClass EquivalenceClass
The equivalence class of the type variable (see the dragon book)
virtual object AcceptOperation(TypeSystemOperation op, object arg)