Skip to content

Commit

Permalink
fix: some dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
R-unic committed Jan 7, 2025
1 parent 4baff3e commit 155a587
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 28 deletions.
2 changes: 1 addition & 1 deletion RobloxCS.Luau/AST/Assignment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public sealed class Assignment : Expression
{
public AssignmentTarget Target { get; }
public Expression Value;
public Expression Value { get; private set; }

public Assignment(AssignmentTarget target, Expression value)
{
Expand Down
9 changes: 2 additions & 7 deletions RobloxCS.Luau/AST/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ public class Block : Statement
public Block(List<Statement> statements)
{
Statements = statements;
AddChildren(Statements);
}

public override void Render(LuauWriter luau)
{
foreach (var statement in Statements)
{
statement.Render(luau);
}
}
public override void Render(LuauWriter luau) => luau.WriteNodes(Statements);
}
}
8 changes: 2 additions & 6 deletions RobloxCS.Luau/AST/TypeCast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ public TypeCast(Expression expression, TypeRef type)
Type = type;
}

public override void Render(LuauWriter luau)
{
Expression.Render(luau);
luau.Write(" :: ");
Type.Render(luau);
}
public override void Render(LuauWriter luau) =>
luau.WriteTypeCast(Expression, Type);
}
}
8 changes: 1 addition & 7 deletions RobloxCS.Luau/AST/VariableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ public VariableList(List<Variable> variables)
AddChildren(Variables);
}

public override void Render(LuauWriter luau)
{
foreach (var variable in Variables)
{
variable.Render(luau);
}
}
public override void Render(LuauWriter luau) => luau.WriteNodes(Variables);
}
}
14 changes: 7 additions & 7 deletions RobloxCS.Luau/LuauWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@ public string Render(AST ast)

public void WriteNodesCommaSeparated<TNode>(List<TNode> nodes) where TNode : Node
{
var index = 0;
foreach (var node in nodes)
{
node.Render(this);
if (node != nodes.Last())
{
if (index++ != nodes.Count - 1)
Write(", ");
}
}
}

public void WriteNodes<TNode>(List<TNode> nodes) where TNode : Node
{
foreach (var node in nodes)
{
node.Render(this);
}
}


public void WriteRequire(string requirePath)
{
WriteLine($"require({requirePath})");
Expand Down Expand Up @@ -132,7 +129,10 @@ public void WriteTypeCast(Expression expression, TypeRef type)
type.Render(this);
}

// wtf is this for??? i literally forgot
/// <summary>
/// Writes statements are descendants of <see cref="node"/>.
/// This is used in cases like a[b++] where the indexer has code that needs to be rendered outside the brackets.
/// </summary>
public void WriteDescendantStatements(ref Node node)
{
if (node.Parent is not Variable && node is not Argument)
Expand Down

0 comments on commit 155a587

Please sign in to comment.