Skip to content

Commit 0069571

Browse files
committed
#61 - новая иерархия ключей символов
1 parent d93b2ca commit 0069571

File tree

6 files changed

+39
-14
lines changed

6 files changed

+39
-14
lines changed

src/Domain/HydraScript.Domain.IR/ISymbolId.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Domain/HydraScript.Domain.IR/Impl/SymbolIds/FunctionSymbolId.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ namespace HydraScript.Domain.IR.Impl.SymbolIds;
22

33
public class FunctionSymbolId(
44
string id,
5-
IEnumerable<Type> parameters) : ISymbolId
5+
IEnumerable<Type> parameters) : SymbolId
66
{
7-
public string Value { get; } =
7+
protected override string Value { get; } =
88
$"function {id}({string.Join(", ", parameters)})";
99
}

src/Domain/HydraScript.Domain.IR/Impl/SymbolIds/NamedSymbolId.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace HydraScript.Domain.IR.Impl.SymbolIds;
2+
3+
public class TypeSymbolId(string name) : SymbolId
4+
{
5+
protected override string Value { get; } = "type " + name;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace HydraScript.Domain.IR.Impl.SymbolIds;
2+
3+
public class VariableSymbolId(string name) : SymbolId
4+
{
5+
protected override string Value { get; } = "var " + name;
6+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace HydraScript.Domain.IR;
2+
3+
public abstract class SymbolId : IEquatable<SymbolId>
4+
{
5+
protected abstract string Value { get; }
6+
7+
public bool Equals(SymbolId? other)
8+
{
9+
if (other is null) return false;
10+
if (ReferenceEquals(this, other)) return true;
11+
return Value == other.Value;
12+
}
13+
14+
public override bool Equals(object? obj)
15+
{
16+
if (obj is null) return false;
17+
if (ReferenceEquals(this, obj)) return true;
18+
if (obj.GetType() != GetType()) return false;
19+
return Equals((SymbolId)obj);
20+
}
21+
22+
public override int GetHashCode() => Value.GetHashCode();
23+
24+
public override string ToString() => Value;
25+
}

0 commit comments

Comments
 (0)