Class SymTypeNormalizeVisitor
- All Implemented Interfaces:
ISymTypeVisitor
(A|A|B) -> A, if A extends B
Usage:
calculate(symType)
normalization of regular expressions are not supported
note, this visitor does not box/unbox, boxing/unboxing should be done before this visitor if required
-
Field Summary
Fields inherited from class de.monticore.types3.util.SymTypeDeepCloneVisitor
transformedSymTypes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiderrorIfEmpty(Collection<? extends SymTypeExpression> types) protected SymTypeExpressionintersect(Collection<SymTypeExpression> uniqueTypes) Intersects types and removes any redundant information (for normalized types without unions or intersections)protected SymTypeExpressionintersectArrayTypes(Collection<SymTypeArray> arrays) protected SymTypeExpressionintersectFunctionTypes(Collection<SymTypeOfFunction> functions) calculates the intersection of function types.protected Set<SymTypeOfIntersection> intersectionOfUnions2UnionOfIntersections(Set<SymTypeExpression> intersectedTypes) takes an intersection, which may contain unions and creates a union which contains intersectionsA&B&(C|D) -> (A&B&C)|(A&B&D)Note that this only calculates the given intersection, not the intersection contained within the given intersection.protected SymTypeExpressionintersectObjectTypes(Collection<? extends SymTypeExpression> objects) Objects, Genericsprotected SymTypeExpressionintersectRegExTypes(Collection<SymTypeOfRegEx> regExs) protected SymTypeExpressionintersectSimpleTypes(Collection<SymTypeExpression> simpleTypes) primitives, SIUnitsprotected SymTypeExpressionintersectTupleTypes(Collection<SymTypeOfTuple> tuples) protected SymTypeExpressionnormalizeIntersectionWithoutUnions(SymTypeOfIntersection intersection) normalizes an intersection the contained expressions are expected to be normalized and not unions s.protected SymTypeExpressionprotected Set<SymTypeExpression> splitIntersections(Set<SymTypeExpression> types) splits up intersections e.g.,{(A&(B&C)),D} -> {A,B,C,D}used for normalizationprotected List<SymTypeOfTuple> Split tuples by intersections.protected List<SymTypeOfTuple> splitTupleByIntersection(SymTypeOfTuple tuple, int idx) protected List<SymTypeOfTuple> splitTupleByUnion(SymTypeOfTuple tuple) Split tuples by unions.protected List<SymTypeOfTuple> splitTupleByUnion(SymTypeOfTuple tuple, int idx) protected Set<SymTypeExpression> splitUnions(Set<SymTypeExpression> types) splits up unions e.g.,{(A|(B|C)),D} -> {A,B,C,D}used for normalizationvoidvisit(SymTypeArray array) voidvisit(SymTypeOfFunction function) voidvisit(SymTypeOfIntersection intersection) voidvisit(SymTypeOfNumericWithSIUnit numericWithSIUnit) voidvisit(SymTypeOfSIUnit siUnit) voidvisit(SymTypeOfTuple tuple) voidvisit(SymTypeOfUnion union) Methods inherited from class de.monticore.types3.util.SymTypeDeepCloneVisitor
applyToCollection, applyToCollection, calculate, getTransformedSymType, getTransformedSymTypes, popTransformedSubSymType, pushTransformedSymType, reset, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
-
Constructor Details
-
SymTypeNormalizeVisitor
public SymTypeNormalizeVisitor()
-
-
Method Details
-
visit
- Specified by:
visitin interfaceISymTypeVisitor- Overrides:
visitin classSymTypeDeepCloneVisitor
-
normalizeUnionWithNormalizedTypes
-
visit
- Specified by:
visitin interfaceISymTypeVisitor- Overrides:
visitin classSymTypeDeepCloneVisitor
-
normalizeIntersectionWithoutUnions
normalizes an intersection the contained expressions are expected to be normalized and not unions s. visit(SymTypeOfIntersection) -
intersect
Intersects types and removes any redundant information (for normalized types without unions or intersections) -
intersectSimpleTypes
primitives, SIUnits -
intersectTupleTypes
-
intersectFunctionTypes
calculates the intersection of function types.IMPORTANT: This does filter out cases that can occur for overloaded functions, e.g.,
intersect(A -> B, (A, A) -> B) = bottomThis is relevant if no type inference is used, and within type inference itself; With this version, resolved intersections MUST be split before normalization. An alternativ would be to allow the aforementioned kind of intersection, But that would lead to allowing values that are multiple function references at once. This is highly unintuitive and not supported by (most?) major languages.TODO FDr: Figure out if for the non-type-inference version the intersection has to be calculated differently (to allow for overloads), or if another representation for overloads would be better suited (which in turn would probably be turned into an intersection for the non-inference version anyway).
-
intersectRegExTypes
-
intersectArrayTypes
-
intersectObjectTypes
Objects, Generics -
visit
- Specified by:
visitin interfaceISymTypeVisitor- Overrides:
visitin classSymTypeDeepCloneVisitor
-
visit
- Specified by:
visitin interfaceISymTypeVisitor- Overrides:
visitin classSymTypeDeepCloneVisitor
-
visit
- Specified by:
visitin interfaceISymTypeVisitor- Overrides:
visitin classSymTypeDeepCloneVisitor
-
visit
- Specified by:
visitin interfaceISymTypeVisitor- Overrides:
visitin classSymTypeDeepCloneVisitor
-
visit
- Specified by:
visitin interfaceISymTypeVisitor- Overrides:
visitin classSymTypeDeepCloneVisitor
-
splitUnions
splits up unions e.g.,{(A|(B|C)),D} -> {A,B,C,D}used for normalization -
splitIntersections
splits up intersections e.g.,{(A&(B&C)),D} -> {A,B,C,D}used for normalization -
intersectionOfUnions2UnionOfIntersections
protected Set<SymTypeOfIntersection> intersectionOfUnions2UnionOfIntersections(Set<SymTypeExpression> intersectedTypes) takes an intersection, which may contain unions and creates a union which contains intersectionsA&B&(C|D) -> (A&B&C)|(A&B&D)Note that this only calculates the given intersection, not the intersection contained within the given intersection. An additional characteristic to mention is that NO empty intersections / unions are created if there have been none to begin with -
splitTupleByUnion
Split tuples by unions.(A|B,C&D) -> (A,C&D), (B, C&D)does not create deep copies. -
splitTupleByUnion
-
splitTupleByIntersection
Split tuples by intersections.(A|B,C&D) -> (A|B,C), (A|B, D)does not create deep copies. -
splitTupleByIntersection
-
errorIfEmpty
-