| | | 1 | | using System.Collections.Generic; |
| | | 2 | | |
| | | 3 | | namespace NanoCLang.Entities { |
| | | 4 | | /// <summary> |
| | | 5 | | /// Provides an interface that allows for variable expressions to be aliased. |
| | | 6 | | /// </summary> |
| | | 7 | | /// <typeparam name="T">Type of object to substitute in.</typeparam> |
| | | 8 | | public interface ISubstitutable<T> { |
| | | 9 | | /// <summary> |
| | | 10 | | /// Substitutes all entities in the object with the substitutor rules from <paramref name="sub"/> and returns a |
| | | 11 | | /// </summary> |
| | | 12 | | /// <param name="sub">Replacement partial function.</param> |
| | | 13 | | /// <returns>New object with replaced entities.</returns> |
| | | 14 | | T Replace(Substitutor sub); |
| | | 15 | | } |
| | | 16 | | /// <summary> |
| | | 17 | | /// Provides a class for substituting entities in abstract syntax trees. |
| | | 18 | | /// </summary> |
| | | 19 | | public class Substitutor { |
| | | 20 | | /// <summary> |
| | | 21 | | /// The location replacement dictionary. Replaces all location names, does not change abstract/concrete! |
| | | 22 | | /// </summary> |
| | 755 | 23 | | public IDictionary<string, string> Locations { get; set; } = new Dictionary<string, string>(); |
| | | 24 | | /// <summary> |
| | | 25 | | /// The variable replacement dictionary. Replaces all variables that are keys with the expression in the corresp |
| | | 26 | | /// </summary> |
| | 2063 | 27 | | public IDictionary<string, PureExpression> Variables { get; set; } = new Dictionary<string, PureExpression>(); |
| | | 28 | | /// <summary> |
| | | 29 | | /// The block offset replacement dictionary. Replaces all block offsets with expressions. |
| | | 30 | | /// </summary> |
| | 511 | 31 | | public IDictionary<int, PureExpression> BlockOffsets { get; set; } = new Dictionary<int, PureExpression>(); |
| | | 32 | | } |
| | | 33 | | } |