2 using System.Collections.Generic;
8 using TypeSystem.Operations;
9 using DynVarManagement;
10 using TypeSystem.Constraints;
11 namespace TypeSystem.Operations {
14 protected TypeExpression to;
15 protected MethodType methodAnalyzed;
20 internal SimplePromotionOperation(TypeExpression to, MethodType methodAnalyzed,
Location location) {
22 this.methodAnalyzed = methodAnalyzed;
23 this.location = location;
28 get {
return KindOfPromotion.Simple; }
31 #region ClassTypeProxy -->...
32 public override object Exec(FieldType from,
object arg) {
33 if (from.FieldTypeExpression != null)
34 return from.FieldTypeExpression.AcceptOperation(
this, arg);
39 #region TypeExpression-->...
40 public override object Exec(TypeExpression from,
object arg) {
42 return ReportError(from);
49 public override object Exec(UnionType from,
object arg) {
50 return from.AcceptOperation(PromotionOperation.Create(this.to, AssignmentOperator.Assign, this.methodAnalyzed, this.location), arg);
55 public override object Exec(TypeVariable from,
object arg) {
56 if (from.Substitution != null) {
57 DynVarOptions.Instance.AssignDynamism(from.Substitution, from.IsDynamic);
58 return from.Substitution.AcceptOperation(
this, arg);
60 if (methodAnalyzed != null) {
63 this.methodAnalyzed.AddConstraint(constraint);
64 return constraint.ReturnType;
66 return ReportError(from);
72 public override object ReportError(TypeExpression from) {
73 ErrorManager.Instance.NotifyError(
new TypePromotionError(from.FullName,
this.to.FullName,
this.location));
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.
KindOfPromotion
This class implements factory method pattern ( virtual constructor). Role: Factory ...