diff --git a/src/Application/HydraScript.Application.StaticAnalysis/Visitors/SemanticChecker.cs b/src/Application/HydraScript.Application.StaticAnalysis/Visitors/SemanticChecker.cs index c58143d..dca6c85 100644 --- a/src/Application/HydraScript.Application.StaticAnalysis/Visitors/SemanticChecker.cs +++ b/src/Application/HydraScript.Application.StaticAnalysis/Visitors/SemanticChecker.cs @@ -268,11 +268,11 @@ public Type Visit(LexicalDeclaration visitable) { var assignment = visitable.Assignments[i]; var registeredSymbol = _symbolTables[visitable.Scope].FindSymbol( - assignment.Destination.Id); + assignment.Destination.Id)!; var sourceType = assignment.Source.Accept(This); if (sourceType.Equals(undefined)) throw new CannotDefineType(assignment.Source.Segment); - if (!registeredSymbol!.Type.Equals(undefined) && !registeredSymbol.Type.Equals(sourceType)) + if (!registeredSymbol.Type.Equals(undefined) && !registeredSymbol.Type.Equals(sourceType)) throw new IncompatibleTypesOfOperands( assignment.Segment, left: registeredSymbol.Type, diff --git a/src/Domain/HydraScript.Domain.BackEnd/IAddress.cs b/src/Domain/HydraScript.Domain.BackEnd/IAddress.cs index 2701598..93900f4 100644 --- a/src/Domain/HydraScript.Domain.BackEnd/IAddress.cs +++ b/src/Domain/HydraScript.Domain.BackEnd/IAddress.cs @@ -2,5 +2,7 @@ namespace HydraScript.Domain.BackEnd; public interface IAddress : IEquatable { - IAddress Next { get; set; } + public IAddress Next { get; set; } + + public string Name { get; } } \ No newline at end of file diff --git a/src/Domain/HydraScript.Domain.BackEnd/Impl/Addresses/HashAddress.cs b/src/Domain/HydraScript.Domain.BackEnd/Impl/Addresses/HashAddress.cs index 6b93034..8165396 100644 --- a/src/Domain/HydraScript.Domain.BackEnd/Impl/Addresses/HashAddress.cs +++ b/src/Domain/HydraScript.Domain.BackEnd/Impl/Addresses/HashAddress.cs @@ -3,11 +3,27 @@ namespace HydraScript.Domain.BackEnd.Impl.Addresses; public class HashAddress(int seed) : IAddress { private readonly int _seed = seed; + private string? _name; private readonly Guid _id = Guid.NewGuid(); public IAddress Next { get; set; } = default!; + public string Name + { + get + { + if (_name is null) + { + var baseName = $"{unchecked((uint)GetHashCode())}{_id:N}"; + var nameArray = Random.Shared.GetItems(baseName.AsSpan(), 10); + _name = new string(nameArray); + } + + return _name; + } + } + public bool Equals(IAddress? other) { if (other is HashAddress hashed) diff --git a/src/Domain/HydraScript.Domain.BackEnd/Impl/Instructions/WithAssignment/Simple.cs b/src/Domain/HydraScript.Domain.BackEnd/Impl/Instructions/WithAssignment/Simple.cs index 0af2110..719f546 100644 --- a/src/Domain/HydraScript.Domain.BackEnd/Impl/Instructions/WithAssignment/Simple.cs +++ b/src/Domain/HydraScript.Domain.BackEnd/Impl/Instructions/WithAssignment/Simple.cs @@ -45,7 +45,7 @@ public Simple( } protected override void OnSetOfAddress(IAddress address) => - Left ??= $"_t{unchecked((uint)address.GetHashCode())}"; + Left ??= address.Name; public override IAddress Execute(IExecuteParams executeParams) {