luau-obfuscator 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.js +1 -0
- package/generated/grammers.luau +3314 -3232
- package/generated/tests.luau +2729 -1944
- package/package.json +1 -1
- package/smoketest/tests.luau +16 -0
- package/src/passes/vmify/compiler.ts +6 -0
package/package.json
CHANGED
package/smoketest/tests.luau
CHANGED
|
@@ -106,6 +106,22 @@ check("string length ascii", #"Roblox", 6)
|
|
|
106
106
|
check("string.upper", string.upper("mixedCase"), "MIXEDCASE")
|
|
107
107
|
check("string.sub", string.sub("Hello, Roblox!", 1, 5), "Hello")
|
|
108
108
|
|
|
109
|
+
-- 11) 제네릭 for의 iterator가 `a.b` / `a:b()`일 때 루프 변수가 밀리지 않는지
|
|
110
|
+
-- (예전엔 `a`를 담은 임시 레지스터가 남아 첫 변수에 `a`가 들어가고 루프가 안 끝났음)
|
|
111
|
+
local holder = { items = { "x", "y" } }
|
|
112
|
+
function holder:GetItems() return self.items end
|
|
113
|
+
local memberParts, methodParts = {}, {}
|
|
114
|
+
for i, v in holder.items do
|
|
115
|
+
if #memberParts > 5 then break end
|
|
116
|
+
memberParts[#memberParts + 1] = tostring(i) .. "=" .. tostring(v)
|
|
117
|
+
end
|
|
118
|
+
for i, v in holder:GetItems() do
|
|
119
|
+
if #methodParts > 5 then break end
|
|
120
|
+
methodParts[#methodParts + 1] = tostring(i) .. "=" .. tostring(v)
|
|
121
|
+
end
|
|
122
|
+
check("generic for over a.b", table.concat(memberParts, ","), "1=x,2=y")
|
|
123
|
+
check("generic for over a:b()", table.concat(methodParts, ","), "1=x,2=y")
|
|
124
|
+
|
|
109
125
|
print("===== ObfuscationTest end =====")
|
|
110
126
|
|
|
111
127
|
if failCount == 0 then
|
|
@@ -642,6 +642,12 @@ export class VmCompiler {
|
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
+
// iterator 표현식이 남긴 임시 레지스터를 반납한다(`a.b` / `a:b()`는 `a`를 담은
|
|
646
|
+
// 레지스터를 잡아둔 채로 끝난다). 아래 CALL은 top()부터 결과를 쓰고 루프 변수는
|
|
647
|
+
// declareLocal()로 base+3부터 잡히므로, 여기서 top을 base+3으로 맞추지 않으면
|
|
648
|
+
// 루프 변수가 한 칸씩 밀려 첫 변수에 `a`가 들어가고 루프가 끝나지 않는다.
|
|
649
|
+
state.regs.freeTemp(base + 3)
|
|
650
|
+
|
|
645
651
|
// Luau 제네릭 반복은 iterator 표현식이 함수가 아니라 테이블일 수 있다
|
|
646
652
|
// (플레인 테이블 → array-then-hash 순회, __iter 메타메서드 → 그 결과). base가
|
|
647
653
|
// 함수가 아니면 루프 진입 전에 한 번 정규화한다 — 안 하면 아래 CALL이 테이블을
|