-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
80 changed files
with
2,373 additions
and
1,708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
namespace RobloxCS.Luau | ||
namespace RobloxCS.Luau; | ||
|
||
public class AST : Node | ||
{ | ||
public class AST : Node | ||
{ | ||
public List<Statement> Statements { get; } | ||
public List<Statement> Statements { get; } | ||
|
||
public AST(List<Statement> statements) | ||
{ | ||
Statements = statements; | ||
AddChildren(Statements); | ||
} | ||
public AST(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) | ||
{ | ||
foreach (var statement in Statements) | ||
statement.Render(luau); | ||
|
||
luau.WriteReturn(); | ||
} | ||
luau.WriteReturn(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
namespace RobloxCS.Luau | ||
namespace RobloxCS.Luau; | ||
|
||
public class AnonymousFunction : Expression | ||
{ | ||
public class AnonymousFunction : Expression | ||
{ | ||
public ParameterList ParameterList { get; } | ||
public Block? Body { get; } | ||
public TypeRef? ReturnType { get; } | ||
public List<AttributeList> AttributeLists { get; } | ||
public ParameterList ParameterList { get; } | ||
public Block? Body { get; } | ||
public TypeRef? ReturnType { get; } | ||
public List<AttributeList> AttributeLists { get; } | ||
|
||
public AnonymousFunction(ParameterList parameterList, TypeRef? returnType = null, | ||
Block? body = null, | ||
List<AttributeList>? attributeLists = null) | ||
public AnonymousFunction(ParameterList parameterList, TypeRef? returnType = null, | ||
Block? body = null, | ||
List<AttributeList>? attributeLists = null) | ||
{ | ||
ParameterList = parameterList; | ||
Body = body; | ||
Body = body; | ||
ReturnType = returnType; | ||
AttributeLists = attributeLists ?? []; AddChild(ParameterList); | ||
AddChild(ParameterList); | ||
if (ReturnType != null) | ||
{ | ||
AddChild(ReturnType); | ||
} | ||
if (Body != null) | ||
{ | ||
ParameterList = parameterList; | ||
Body = body; | ||
Body = body; | ||
ReturnType = returnType; | ||
AttributeLists = attributeLists ?? []; AddChild(ParameterList); | ||
AddChild(ParameterList); | ||
if (ReturnType != null) | ||
{ | ||
AddChild(ReturnType); | ||
} | ||
if (Body != null) | ||
{ | ||
AddChild(Body); | ||
} | ||
AddChildren(AttributeLists); | ||
AddChild(Body); | ||
} | ||
|
||
public override void Render(LuauWriter luau) => | ||
luau.WriteFunction(null, false, ParameterList, ReturnType, Body, AttributeLists, | ||
inlineAttributes: true, createNewline: false); | ||
AddChildren(AttributeLists); | ||
} | ||
|
||
public override void Render(LuauWriter luau) => | ||
luau.WriteFunction(null, false, ParameterList, ReturnType, Body, AttributeLists, | ||
inlineAttributes: true, createNewline: false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
namespace RobloxCS.Luau | ||
{ | ||
public class Argument : Expression | ||
{ | ||
public Expression Expression { get; set; } | ||
namespace RobloxCS.Luau; | ||
|
||
public Argument(Expression expression) | ||
{ | ||
Expression = expression; | ||
AddChild(Expression); | ||
} | ||
public class Argument : Expression | ||
{ | ||
public Expression Expression { get; set; } | ||
|
||
public override void Render(LuauWriter luau) | ||
{ | ||
Expression.Render(luau); | ||
} | ||
public Argument(Expression expression) | ||
{ | ||
Expression = expression; | ||
AddChild(Expression); | ||
} | ||
} | ||
|
||
public override void Render(LuauWriter luau) => Expression.Render(luau); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
namespace RobloxCS.Luau | ||
namespace RobloxCS.Luau; | ||
|
||
public class ArgumentList : Expression | ||
{ | ||
public class ArgumentList : Expression | ||
{ | ||
public List<Argument> Arguments { get; set; } | ||
public List<Argument> Arguments { get; set; } | ||
|
||
public ArgumentList(List<Argument> arguments) | ||
{ | ||
Arguments = arguments; | ||
AddChildren(Arguments.OfType<Node>().ToList()); | ||
} | ||
public ArgumentList(List<Argument> arguments) | ||
{ | ||
Arguments = arguments; | ||
AddChildren(Arguments); | ||
} | ||
|
||
public override void Render(LuauWriter luau) | ||
{ | ||
luau.Write('('); | ||
luau.WriteNodesCommaSeparated(Arguments); | ||
luau.Write(')'); | ||
} | ||
public override void Render(LuauWriter luau) | ||
{ | ||
luau.Write('('); | ||
luau.WriteNodesCommaSeparated(Arguments); | ||
luau.Write(')'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
namespace RobloxCS.Luau | ||
namespace RobloxCS.Luau; | ||
|
||
public class ArrayType : TypeRef | ||
{ | ||
public class ArrayType : TypeRef | ||
{ | ||
public TypeRef ElementType { get; } | ||
public TypeRef ElementType { get; } | ||
|
||
public ArrayType(TypeRef elementType) | ||
: base("{ " + elementType.Path + " }", true) | ||
{ | ||
ElementType = elementType; | ||
} | ||
public ArrayType(TypeRef elementType) | ||
: base("{ " + elementType.Path + " }", true) | ||
{ | ||
ElementType = elementType; | ||
AddChild(ElementType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
namespace RobloxCS.Luau | ||
namespace RobloxCS.Luau; | ||
|
||
public sealed class Assignment : Expression | ||
{ | ||
public sealed class Assignment : Expression | ||
{ | ||
public AssignmentTarget Target { get; } | ||
public Expression Value { get; private set; } | ||
public AssignmentTarget Target { get; } | ||
public Expression Value { get; private set; } | ||
|
||
public Assignment(AssignmentTarget target, Expression value) | ||
{ | ||
Target = target; | ||
Value = value; | ||
AddChildren([Target, Value]); | ||
} | ||
public Assignment(AssignmentTarget target, Expression value) | ||
{ | ||
Target = target; | ||
Value = value; | ||
AddChildren([Target, Value]); | ||
} | ||
|
||
public override void Render(LuauWriter luau) | ||
{ | ||
Node value = Value; | ||
luau.WriteDescendantStatements(ref value); | ||
Value = (Expression)value; | ||
luau.WriteAssignment(Target, Value); | ||
} | ||
public override void Render(LuauWriter luau) | ||
{ | ||
Node value = Value; | ||
luau.WriteDescendantStatements(ref value); | ||
Value = (Expression)value; | ||
luau.WriteAssignment(Target, Value); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
namespace RobloxCS.Luau | ||
{ | ||
public abstract class AssignmentTarget : Expression | ||
{ | ||
} | ||
} | ||
namespace RobloxCS.Luau; | ||
|
||
public abstract class AssignmentTarget : Expression; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,23 @@ | ||
namespace RobloxCS.Luau | ||
{ | ||
public class BinaryOperator : Expression | ||
{ | ||
public Expression Left { get; } | ||
public string Operator { get; } | ||
public Expression Right { get; } | ||
namespace RobloxCS.Luau; | ||
|
||
public BinaryOperator(Expression left, string @operator, Expression right) | ||
{ | ||
Left = left; | ||
Operator = @operator; | ||
Right = right; | ||
AddChildren([Left, Right]); | ||
} | ||
public class BinaryOperator : Expression | ||
{ | ||
public Expression Left { get; } | ||
public string Operator { get; } | ||
public Expression Right { get; } | ||
|
||
public override void Render(LuauWriter luau) | ||
{ | ||
Left.Render(luau); | ||
luau.Write($" {Operator} "); | ||
Right.Render(luau); | ||
} | ||
public BinaryOperator(Expression left, string @operator, Expression right) | ||
{ | ||
Left = left; | ||
Operator = @operator; | ||
Right = right; | ||
AddChildren([Left, Right]); | ||
} | ||
|
||
public BinaryOperator WithLeft(Expression left) => new BinaryOperator(left, Operator, Right); | ||
public BinaryOperator WithRight(Expression right) => new BinaryOperator(Left, Operator, right); | ||
public override void Render(LuauWriter luau) | ||
{ | ||
Left.Render(luau); | ||
luau.Write($" {Operator} "); | ||
Right.Render(luau); | ||
} | ||
} |
Oops, something went wrong.