Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.

Commit cc3edfb

Browse files
improve/fix graph display
1 parent 8bf1835 commit cc3edfb

17 files changed

+105
-19
lines changed

Parsing/Tree/ClassDeclarationSyntax.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void CreateDefaultConstructor(SymbolTreeBuilder symbolTree)
6767

6868
var constructedType = Symbol.Result.DeclaresDataType;
6969
var constructorSymbol = new ConstructorSymbol(Symbol.Result, null, FixedList<DataType>.Empty);
70-
var selfParameterSymbol = new SelfParameterSymbol(constructorSymbol, false, constructedType);
70+
var selfParameterSymbol = new SelfParameterSymbol(constructorSymbol, constructedType);
7171

7272
symbolTree.Add(constructorSymbol);
7373
symbolTree.Add(selfParameterSymbol);

Parsing/Tree/SelfParameterSyntax.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Adamant.Tools.Compiler.Bootstrap.Parsing.Tree
88
{
99
internal class SelfParameterSyntax : ParameterSyntax, ISelfParameterSyntax
1010
{
11-
public bool IsMutableBinding => MutableSelf;
11+
public bool IsMutableBinding => false;
1212
public bool MutableSelf { get; }
1313
public Promise<SelfParameterSymbol> Symbol { get; } = new Promise<SelfParameterSymbol>();
1414
IPromise<BindingSymbol> IBindingSyntax.Symbol => Symbol;

Semantics.Reachability.Graph/CallerVariable.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class CallerVariable : StackPlace
1414
{
1515
public BindingSymbol Symbol { get; }
1616

17-
private CallerVariable(ReachabilityGraph graph, BindingSymbol symbol)
17+
internal CallerVariable(ReachabilityGraph graph, BindingSymbol symbol)
1818
: base(graph)
1919
{
2020
_ = symbol.DataType.UnderlyingReferenceType()
@@ -32,7 +32,8 @@ internal static CallerVariable CreateForParameterWithObject(ReachabilityGraph gr
3232

3333
public override string ToString()
3434
{
35-
return $"⟦{Symbol.Name}⟧: {Symbol.DataType}";
35+
var name = Symbol is SelfParameterSymbol ? "self" : Symbol.Name?.ToString();
36+
return $"⟦{name}⟧: {Symbol.DataType}";
3637
}
3738
}
3839
}

Semantics.Reachability.Graph/ReachabilityGraphGraphvizExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Adamant.Tools.Compiler.Bootstrap.Semantics.Reachability.Graph
88
{
99
public static class ReachabilityGraphGraphvizExtensions
1010
{
11-
private const string Grey = "grey45";
11+
private const string Grey = "grey55";
1212
private const string Black = "black";
1313

1414
/// <summary>

Semantics.Reachability.Graph/Variable.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ public void Dead()
5858

5959
public override string ToString()
6060
{
61-
return $"{Symbol.Name}: {Symbol.DataType}";
61+
var mut = Symbol.IsMutableBinding ? "var " : "";
62+
var name = Symbol is SelfParameterSymbol ? "self" : Symbol.Name?.ToString();
63+
return $"{mut}{name}: {Symbol.DataType}";
6264
}
6365
}
6466
}

Semantics/AST/Tree/NamedParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public NamedParameter(
2424

2525
public override string ToString()
2626
{
27-
var mutable = Symbol.IsMutableBinding ? "mut " : "";
27+
var mutable = Symbol.IsMutableBinding ? "var " : "";
2828
var defaultValue = DefaultValue != null ? " = " + DefaultValue : "";
2929
var declarationNumber = Symbol.DeclarationNumber is null ? "" : "#" + Symbol.DeclarationNumber;
3030
return $"{mutable}{Symbol.Name}{declarationNumber}: {Symbol.DataType}{defaultValue}";

Semantics/Symbols/Entities/EntitySymbolBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private void BuildSelParameterSymbol(
243243
ISelfParameterSyntax param,
244244
DataType type)
245245
{
246-
var symbol = new SelfParameterSymbol(containingSymbol, param.IsMutableBinding, type);
246+
var symbol = new SelfParameterSymbol(containingSymbol, type);
247247
param.Symbol.Fulfill(symbol);
248248
symbolTree.Add(symbol);
249249
}

Symbols/FieldSymbol.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public override int GetHashCode()
3636

3737
public override string ToILString()
3838
{
39-
var mutable = IsMutableBinding ? "mut " : "";
40-
return $"{ContainingSymbol}::{mutable}{Name}: {DataType}";
39+
var mutable = IsMutableBinding ? "var" : "let";
40+
return $"{ContainingSymbol}::{mutable} {Name}: {DataType}";
4141
}
4242
}
4343
}

Symbols/SelfParameterSymbol.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ public class SelfParameterSymbol : BindingSymbol
77
{
88
public new InvocableSymbol ContainingSymbol { get; }
99

10-
public SelfParameterSymbol(InvocableSymbol containingSymbol, bool isMutableBinding, DataType dataType)
11-
: base(containingSymbol, null, isMutableBinding, dataType)
10+
public SelfParameterSymbol(InvocableSymbol containingSymbol, DataType dataType)
11+
: base(containingSymbol, null, false, dataType)
1212
{
13+
if (containingSymbol is FunctionSymbol)
14+
throw new ArgumentException("Function can't have self parameter", nameof(containingSymbol));
15+
1316
ContainingSymbol = containingSymbol;
1417
}
1518

@@ -31,8 +34,7 @@ public override int GetHashCode()
3134

3235
public override string ToILString()
3336
{
34-
var mutable = IsMutableBinding ? "mut " : "";
35-
return $"{ContainingSymbol} {{{mutable}{Name}: {DataType}}}";
37+
return $"{ContainingSymbol} {{self: {DataType}}}";
3638
}
3739
}
3840
}

Symbols/VariableSymbol.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public override int GetHashCode()
4343

4444
public override string ToILString()
4545
{
46-
var mutable = IsMutableBinding ? "mut " : "";
46+
var mutable = IsMutableBinding ? "var" : "let";
4747
var declarationNumber = DeclarationNumber is null ? "" : "#" + DeclarationNumber;
48-
return $"{ContainingSymbol} {{{mutable}{Name}{declarationNumber}: {DataType}}}";
48+
return $"{ContainingSymbol} {{{mutable} {Name}{declarationNumber}: {DataType}}}";
4949
}
5050
}
5151
}

0 commit comments

Comments
 (0)