Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

v0.0.3 alpha#4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
atrexus merged 17 commits intomainfromv0.0.3-alpha
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
17 commits
Select commitHold shift + click to select a range
090a7c5
Fix some bugs with the decompiler.
atrexusJun 11, 2023
84f603d
Add logger and add basic unit tests.
atrexusJun 12, 2023
aa5d60c
Add a few more unit tests
atrexusJun 13, 2023
f3cf2ef
Update README.md
atrexusJun 13, 2023
3a619ed
Update README.md
atrexusJun 14, 2023
dd770b8
Update README.md
atrexusJun 14, 2023
d0e649d
Update README.md
atrexusJun 14, 2023
1b2c965
Fix console writer, and a few annoying bugs.
atrexusJun 14, 2023
b3f5c21
Merge branch 'v0.0.3-alpha' of https://github.com/societall/UnluauNET…
atrexusJun 14, 2023
709bfb7
Update README.md
atrexusJun 14, 2023
55a8e6b
Various bug fixes to assignments and upvalues.
atrexusJun 15, 2023
0bbd24f
Merge branch 'v0.0.3-alpha' of https://github.com/societall/UnluauNET…
atrexusJun 15, 2023
1546392
Update README.md
atrexusJun 15, 2023
48b2589
Fix bug in settable constant and change version.
atrexusJun 15, 2023
47f3d11
Merge branch 'v0.0.3-alpha' of https://github.com/societall/UnluauNET…
atrexusJun 15, 2023
dc171c3
Add a few more tests.
atrexusJun 23, 2023
0d37bc6
Add additional tests for expressions. Still working and Vararg.
atrexusJun 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Add a few more unit tests
  • Loading branch information
@atrexus
atrexus committedJun 13, 2023
commitaa5d60c55c1e26b1a27ac9a1bbf2b2c330eb4faa
Binary file addedUnluau.Test/Binary/Tables01.luau
View file
Open in desktop
Binary file not shown.
Binary file addedUnluau.Test/Binary/WhileLoops.luau
View file
Open in desktop
Binary file not shown.
2 changes: 2 additions & 0 deletionsUnluau.Test/Expect/Namecall.lua
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
local PlayersService = game:GetService("Players")
local MiscService = game:GetService("Misc")
5 changes: 5 additions & 0 deletionsUnluau.Test/Expect/Tables01.lua
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
local var1 = {}
var1.first = 1
var1.second = 2
var1.third = 3
y = { first = 1, second = 2, third = 3 }
20 changes: 20 additions & 0 deletionsUnluau.Test/Expect/WhileLoops.lua
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
while a do
f()
end
while a do
if b then
f()
end
end
while a do
while b do
f()
end
g()
end
while a do
f()
while b do
g()
end
end
37 changes: 32 additions & 5 deletionsUnluau.Test/UnluauTests.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,14 @@

namespace Unluau.Test
{
/// <summary>
/// Specifically created for the test decompilation stage
/// </summary>
public class UnluauOptions
{

}

[TestClass]
public class UnluauTests
{
Expand All@@ -24,7 +32,9 @@ private string GetCode(string FileName)
Decompiler decompiler = new Decompiler(stream, new DecompilerOptions()
{
Output = new Output(new StreamWriter(memoryStream)),
HeaderEnabled = false
HeaderEnabled = false,
VariableNameGuessing = true,
InlineTableDefintions = true
});

decompiler.Decompile();
Expand All@@ -33,14 +43,31 @@ private string GetCode(string FileName)
}
}

private void GetAndAssert(string binary, string expect)
{
string actual = GetCode(binary);
string expected = new StreamReader(OpenRead(expect)).ReadToEnd();

Assert.AreEqual(expected, actual);
}

[TestMethod]
public voidMultiple_Namecall()
public voidTest_Namecall()
{
string actual = GetCode("Binary/MultipleNamecallStatements.luau");
GetAndAssert("Binary/Namecall.luau", "Expect/Namecall.lua");
}

[TestMethod]
public void Test_WhileLoops()
{
GetAndAssert("Binary/WhileLoops.luau", "Expect/WhileLoops.lua");
}

string expected = "local var4 = game:GetService(\"Players\")\nlocal var8 = game:GetService(\"Misc\")";

Assert.AreEqual(expected, actual);
[TestMethod]
public void Test_DictionaryTable()
{
GetAndAssert("Binary/Tables01.luau", "Expect/Tables01.lua");
}
}
}
12 changes: 11 additions & 1 deletionUnluau/Lifter/Expressions/TableLiteral.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,6 +45,12 @@ public void AddEntry(Entry entry)

public override void Write(Output output)
{
if (Entries.Count == 0)
{
output.Write("{}");
return;
}

output.Write("{ ");

bool itemsOnNewline = (IsList && Entries.Count > 10) || (IsDictionary && Entries.Count > 5);
Expand All@@ -65,12 +71,16 @@ public override void Write(Output output)

if (entry.Key != null)
{
if (entry.Key is NumberLiteral || entry.Key is StringLiteral)
if (entry.Key is NumberLiteral)
{
output.Write("[");
entry.Key.Write(output);
output.Write("]");
}
else if (entry.Key is StringLiteral)
{
output.Write((entry.Key as StringLiteral).Value);
}
else
entry.Key.Write(output);

Expand Down
16 changes: 11 additions & 5 deletionsUnluau/Lifter/Lifter.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,8 +200,8 @@ private Block LiftBlock(Function function, Registers registers, int pcStart = 0,
}
case OpCode.SETTABLEKS:
{
StringConstant target = (StringConstant)function.Constants[(int)function.Instructions[++pc].Value];
Expression table = registers.GetExpression(instruction.B), value = ((LocalExpression)table).Expression;
StringConstant target = (StringConstant)function.Constants[function.Instructions[++pc].Value];
Expression table = registers.GetExpression(instruction.B, false), value = ((LocalExpression)table).Expression;

if (options.InlineTableDefintions && value is TableLiteral)
{
Expand All@@ -222,7 +222,7 @@ private Block LiftBlock(Function function, Registers registers, int pcStart = 0,
case OpCode.SETTABLE:
{
Expression expression = registers.GetRefExpressionValue(instruction.C), value = registers.GetExpression(instruction.A);
Expression table = registers.GetExpression(instruction.B), tableValue = ((LocalExpression)table).Expression;
Expression table = registers.GetExpression(instruction.B, false), tableValue = ((LocalExpression)table).Expression;

if (options.InlineTableDefintions && tableValue is TableLiteral)
{
Expand DownExpand Up@@ -392,8 +392,14 @@ private Block LiftBlock(Function function, Registers registers, int pcStart = 0,

private int IsSelf(Expression expression)
{
NameIndex nameIndex = (NameIndex)((LocalExpression)expression).Expression;
return nameIndex.IsSelf ? 1 : 0;
Expression value = ((LocalExpression)expression).Expression;

if (value is NameIndex)
{
NameIndex nameIndex = (NameIndex)value;
return nameIndex.IsSelf ? 1 : 0;
}
return 0;
}

private Expression BuildConcat(Registers registers, int from, int to)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp