public interface TypeRewriter
Responsible for rewriting a given type in some way whilst maintaining
semantic equivalence. Often (though not exclusively) this is used for
simplifying types. For example, int|int could be simplfiied to
int. Type simplification is necessary, for example, to prevent
infinite loops in some operations (e.g. type extraction). Type simplification
is also useful in making generated types easier to read.
Type simplification can be performed over a range of constructs. The following highlights some examples:
!!int can be rewritten to
int. Likewise, !({int f}|int) can be rewritten to
(!{int f})|(!int).int|null|int can be rewritten to
int|null. Likewise, {int|null f} can be rewritten
to {int f}|{null f}.int&int can be rewritten
to int. Likewise, {int|null f}&{int f} can be
rewritten to {int f}.This interface does not specify what rewrites will be applied. It only provides a concept of type simplification in abstract sense. Specific implementations of this interface will choose what rules to apply based on their own use case (e.g. for internal algorithms, for human readability, etc).
| Modifier and Type | Method and Description |
|---|---|
WyalFile.Type |
rewrite(WyalFile.Type type)
Apply the rewrite rules to the given type producing a potentially updated
type.
|
WyalFile.Type rewrite(WyalFile.Type type)
Type
object should be returned intact.type - The type to be rewrittenCopyright © 2017. All rights reserved.