public virtual TypeNode VisitConstrainedType(ConstrainedType cType, ConstrainedType changes, ConstrainedType deletions, ConstrainedType insertions){ this.UpdateSourceContext(cType, changes); if (cType == null) return changes; if (changes != null){ if (deletions == null || insertions == null) Debug.Assert(false); else{ cType.Constraint = this.VisitExpression(cType.Constraint, changes.Constraint, deletions.Constraint, insertions.Constraint); cType.UnderlyingType = this.VisitTypeReference(cType.UnderlyingType, changes.UnderlyingType); } }else if (deletions != null) return null; return cType; }
public virtual TypeNode VisitConstrainedType(ConstrainedType cType){ if (cType == null) return null; cType.UnderlyingType = this.VisitTypeReference(cType.UnderlyingType); cType.Constraint = this.VisitExpression(cType.Constraint); return cType; }
public virtual Differences VisitConstrainedType(ConstrainedType cType1, ConstrainedType cType2){ Differences differences = new Differences(cType1, cType2); if (cType1 == null || cType2 == null){ if (cType1 != cType2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++; return differences; } ConstrainedType changes = (ConstrainedType)cType2.Clone(); ConstrainedType deletions = (ConstrainedType)cType2.Clone(); ConstrainedType insertions = (ConstrainedType)cType2.Clone(); Differences diff = this.VisitExpression(cType1.Constraint, cType2.Constraint); if (diff == null){Debug.Assert(false); return differences;} changes.Constraint = diff.Changes as Expression; deletions.Constraint = diff.Deletions as Expression; insertions.Constraint = diff.Insertions as Expression; Debug.Assert(diff.Changes == changes.Constraint && diff.Deletions == deletions.Constraint && diff.Insertions == insertions.Constraint); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; diff = this.VisitTypeNode(cType1.UnderlyingType, cType2.UnderlyingType); if (diff == null){Debug.Assert(false); return differences;} changes.UnderlyingType = diff.Changes as TypeNode; deletions.UnderlyingType = diff.Deletions as TypeNode; insertions.UnderlyingType = diff.Insertions as TypeNode; //Debug.Assert(diff.Changes == changes.UnderlyingType && diff.Deletions == deletions.UnderlyingType && diff.Insertions == insertions.UnderlyingType); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; if (differences.NumberOfDifferences == 0){ differences.Changes = null; differences.Deletions = null; differences.Insertions = null; }else{ differences.Changes = changes; differences.Deletions = deletions; differences.Insertions = insertions; } return differences; }
public override TypeNode VisitConstrainedType(ConstrainedType cType){ if (cType == null) return null; this.VisitResolvedTypeReference(cType.UnderlyingType, cType.UnderlyingTypeExpression); return base.VisitConstrainedType(cType); }
public override TypeNode VisitTypeReference(TypeNode type) { if (type == null) { return(null); } Class cl = type as Class; if (cl != null) { this.VisitTypeReference(cl.BaseClass); } if (this.MembersToFind[type.UniqueKey] != null) { this.FoundMembers[type.UniqueKey] = type; if (!this.insideMethodBody) { this.AllReferencesAreConfinedToMethodBodies = false; } return(type); } switch (type.NodeType) { case NodeType.ArrayType: ArrayType arrType = (ArrayType)type; this.VisitTypeReference(arrType.ElementType); return(type); case NodeType.DelegateNode: { FunctionType ftype = type as FunctionType; if (ftype == null) { goto default; } this.VisitTypeReference(ftype.ReturnType); this.VisitParameterList(ftype.Parameters); return(type); } case NodeType.Pointer: Pointer pType = (Pointer)type; this.VisitTypeReference(pType.ElementType); return(type); case NodeType.Reference: Reference rType = (Reference)type; this.VisitTypeReference(rType.ElementType); return(type); case NodeType.TupleType: { TupleType tType = (TupleType)type; MemberList members = tType.Members; int n = members == null ? 0 : members.Count; for (int i = 0; i < n; i++) { Field f = members[i] as Field; if (f == null) { continue; } this.VisitTypeReference(f.Type); } return(type); } case NodeType.TypeIntersection: TypeIntersection tIntersect = (TypeIntersection)type; this.VisitTypeReferenceList(tIntersect.Types); return(type); case NodeType.TypeUnion: TypeUnion tUnion = (TypeUnion)type; this.VisitTypeReferenceList(tUnion.Types); return(type); case NodeType.ArrayTypeExpression: ArrayTypeExpression aExpr = (ArrayTypeExpression)type; this.VisitTypeReference(aExpr.ElementType); return(type); case NodeType.BoxedTypeExpression: BoxedTypeExpression bExpr = (BoxedTypeExpression)type; this.VisitTypeReference(bExpr.ElementType); return(type); case NodeType.ClassExpression: ClassExpression cExpr = (ClassExpression)type; this.VisitExpression(cExpr.Expression); this.VisitTypeReferenceList(cExpr.TemplateArguments); return(type); case NodeType.ClassParameter: case NodeType.TypeParameter: return(type); case NodeType.ConstrainedType: ConstrainedType conType = (ConstrainedType)type; this.VisitTypeReference(conType.UnderlyingType); this.VisitExpression(conType.Constraint); return(type); case NodeType.FlexArrayTypeExpression: FlexArrayTypeExpression flExpr = (FlexArrayTypeExpression)type; this.VisitTypeReference(flExpr.ElementType); return(type); case NodeType.FunctionTypeExpression: FunctionTypeExpression ftExpr = (FunctionTypeExpression)type; this.VisitParameterList(ftExpr.Parameters); this.VisitTypeReference(ftExpr.ReturnType); return(type); case NodeType.InvariantTypeExpression: InvariantTypeExpression invExpr = (InvariantTypeExpression)type; this.VisitTypeReference(invExpr.ElementType); return(type); case NodeType.InterfaceExpression: InterfaceExpression iExpr = (InterfaceExpression)type; this.VisitExpression(iExpr.Expression); this.VisitTypeReferenceList(iExpr.TemplateArguments); return(type); case NodeType.NonEmptyStreamTypeExpression: NonEmptyStreamTypeExpression neExpr = (NonEmptyStreamTypeExpression)type; this.VisitTypeReference(neExpr.ElementType); return(type); case NodeType.NonNullTypeExpression: NonNullTypeExpression nnExpr = (NonNullTypeExpression)type; this.VisitTypeReference(nnExpr.ElementType); return(type); case NodeType.NonNullableTypeExpression: NonNullableTypeExpression nbExpr = (NonNullableTypeExpression)type; this.VisitTypeReference(nbExpr.ElementType); return(type); case NodeType.NullableTypeExpression: NullableTypeExpression nuExpr = (NullableTypeExpression)type; this.VisitTypeReference(nuExpr.ElementType); return(type); case NodeType.OptionalModifier: case NodeType.RequiredModifier: TypeModifier modType = (TypeModifier)type; this.VisitTypeReference(modType.ModifiedType); this.VisitTypeReference(modType.Modifier); return(type); case NodeType.PointerTypeExpression: PointerTypeExpression pExpr = (PointerTypeExpression)type; this.VisitTypeReference(pExpr.ElementType); return(type); case NodeType.ReferenceTypeExpression: ReferenceTypeExpression rExpr = (ReferenceTypeExpression)type; this.VisitTypeReference(rExpr.ElementType); return(type); case NodeType.StreamTypeExpression: StreamTypeExpression sExpr = (StreamTypeExpression)type; this.VisitTypeReference(sExpr.ElementType); return(type); case NodeType.TupleTypeExpression: TupleTypeExpression tuExpr = (TupleTypeExpression)type; this.VisitFieldList(tuExpr.Domains); return(type); case NodeType.TypeExpression: TypeExpression tExpr = (TypeExpression)type; this.VisitExpression(tExpr.Expression); this.VisitTypeReferenceList(tExpr.TemplateArguments); return(type); case NodeType.TypeIntersectionExpression: TypeIntersectionExpression tiExpr = (TypeIntersectionExpression)type; this.VisitTypeReferenceList(tiExpr.Types); return(type); case NodeType.TypeUnionExpression: TypeUnionExpression tyuExpr = (TypeUnionExpression)type; this.VisitTypeReferenceList(tyuExpr.Types); return(type); default: if (type.Template != null && type.TemplateArguments != null) { this.VisitTypeReference(type.Template); this.VisitTypeReferenceList(type.TemplateArguments); } return(type); } }
public virtual TypeNode VisitConstrainedType(ConstrainedType cType1, ConstrainedType cType2){ if (cType1 == null) return null; if (cType2 == null){ cType1.UnderlyingType = this.VisitTypeReference(cType1.UnderlyingType, null); cType1.Constraint = this.VisitExpression(cType1.Constraint, null); }else{ cType1.UnderlyingType = this.VisitTypeReference(cType1.UnderlyingType, cType2.UnderlyingType); cType1.Constraint = this.VisitExpression(cType1.Constraint, cType2.Constraint); } return cType1; }
public override TypeNode VisitConstrainedType(ConstrainedType cType){ if (cType == null) return null; return base.VisitConstrainedType((ConstrainedType)cType.Clone()); }
public override string ToString() { string name = (Name != null) ? string.Format("{0} ({1})", Name, ConstrainedType.GetLiteral()) : ConstrainedType.GetLiteral(); return(string.Format("{0} ({1} elements)", name, Elements.Count)); }
public override TypeNode VisitConstrainedType(ConstrainedType cType){ cType = (ConstrainedType)base.VisitConstrainedType(cType); if (cType == null) return null; cType.ProvideBodiesForMethods(); cType.NodeType = NodeType.Struct; return cType; }
public override TypeNode VisitConstrainedType(ConstrainedType cType){ if (cType == null) return null; TypeNode uType = cType.UnderlyingType = this.VisitTypeReference(cType.UnderlyingType); if (uType == null) return null; cType.ProvideMembers(); Method toConstrained = this.GetTypeView(cType).GetMethod(StandardIds.opImplicit, cType.UnderlyingType); Parameter param = toConstrained.Parameters[0]; this.scope = new MethodScope(this.scope, null); this.AddToAllScopes(this.scope); ParameterField pField = new ParameterField(this.scope, null, FieldFlags.CompilerControlled, StandardIds.Value, cType.UnderlyingType, null); pField.Parameter = param; this.scope.Members.Add(pField); cType.Constraint = this.VisitExpression(cType.Constraint); this.scope = this.scope.OuterScope; this.AddToAllScopes(this.scope); return cType; }
public override TypeNode VisitConstrainedType(ConstrainedType cType) { throw new NotImplementedException("Node type not yet supported"); }
public EventingVisitor(Action<ConstrainedType> visitConstrainedType) { VisitedConstrainedType += visitConstrainedType; } public event Action<ConstrainedType> VisitedConstrainedType; public override TypeNode VisitConstrainedType(ConstrainedType cType) { if (VisitedConstrainedType != null) VisitedConstrainedType(cType); return base.VisitConstrainedType(cType); }