| | | 1 | | using NanoCLang.Environemnts; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | |
| | | 4 | | namespace NanoCLang.Entities { |
| | | 5 | | /// <summary> |
| | | 6 | | /// Provides a superclass for all NanoC types. |
| | | 7 | | /// May also include basic types that are used as refined types with trivial refinement. |
| | | 8 | | /// </summary> |
| | | 9 | | public abstract class Type : Base, ISubstitutable<Type> { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Gets the size of the type in bytes. |
| | | 12 | | /// </summary> |
| | | 13 | | public abstract int Size { get; } |
| | | 14 | | /// <summary> |
| | | 15 | | /// Gets the underlying type of the current type. |
| | | 16 | | /// </summary> |
| | | 17 | | public abstract BasicType BaseType { get; } |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets a refinement that is valid for the type. |
| | | 20 | | /// </summary> |
| | | 21 | | public abstract PureExpression Refinement { get; } |
| | | 22 | | /// <summary> |
| | | 23 | | /// Checks if the type is well-formed and raises an exception if it is ill-formed. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <exception cref="IllFormedException">Type is ill-formed.</exception> |
| | | 26 | | public abstract void WellFormed(LocalEnvironment gamma, Heap heap); |
| | | 27 | | /// <summary> |
| | | 28 | | /// Checks if the current type is a subtype of the <paramref name="other"/> type in the given environment. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <param name="gamma">Environment to check the subtype in.</param> |
| | | 31 | | /// <param name="other">Other type to check against.</param> |
| | | 32 | | /// <returns><see langword="true"/> iff the current type is a subtype of the <paramref name="other"/> type.</ret |
| | 375 | 33 | | public virtual bool SubType(LocalEnvironment gamma, Type other) => this == other || ProperSubType(gamma, other); |
| | | 34 | | /// <summary> |
| | | 35 | | /// Checks if the current type is a proper subtype of the <paramref name="other"/> type in the given environment |
| | | 36 | | /// </summary> |
| | | 37 | | /// <param name="gamma">Environment to check the subtype in.</param> |
| | | 38 | | /// <param name="other">Other type to check against.</param> |
| | | 39 | | /// <returns><see langword="true"/> iff the current type is a proper subtype of the <paramref name="other"/> typ |
| | | 40 | | public abstract bool ProperSubType(LocalEnvironment gamma, Type other); |
| | | 41 | | /// <inheritdoc/> |
| | | 42 | | public abstract Type Replace(Substitutor sub); |
| | | 43 | | /// <inheritdoc/> |
| | | 44 | | public abstract override IEnumerable<StringFormatterToken> Tokens(CSourceFormat args); |
| | | 45 | | } |
| | | 46 | | } |