luau-obfuscator 1.0.6 → 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 CHANGED
@@ -1494,6 +1494,7 @@ var Opcode = /* @__PURE__ */ ((Opcode2) => {
1494
1494
  Opcode2[Opcode2["VARARG"] = 32] = "VARARG";
1495
1495
  Opcode2[Opcode2["SETLIST"] = 33] = "SETLIST";
1496
1496
  Opcode2[Opcode2["IDIV"] = 34] = "IDIV";
1497
+ Opcode2[Opcode2["NORMITER"] = 35] = "NORMITER";
1497
1498
  return Opcode2;
1498
1499
  })(Opcode || {});
1499
1500
  function RK(regOrConstIdx, isConst) {
@@ -2309,6 +2310,8 @@ var VmCompiler = class {
2309
2310
  }
2310
2311
  }
2311
2312
  }
2313
+ state.regs.freeTemp(base + 3);
2314
+ this.emit(state, 35 /* NORMITER */, base, 0, 0, "normalize-generic-iter");
2312
2315
  const loopStart = state.proto.code.length;
2313
2316
  const nVars = stmt.variables.length;
2314
2317
  const callBase = state.regs.top();
@@ -2841,6 +2844,34 @@ local function ${N.rk}(${N.frame}, x)
2841
2844
  end
2842
2845
  end
2843
2846
 
2847
+ -- \uD50C\uB808\uC778 \uD14C\uC774\uBE14\uC5D0 \uB300\uD55C Luau \uC81C\uB124\uB9AD \uBC18\uBCF5(for k, v in t) \uC774\uD130\uB808\uC774\uD130.
2848
+ -- \uBC30\uC5F4\uBD80(1..\uACBD\uACC4)\uB97C \uC21C\uC11C\uB300\uB85C \uBA3C\uC800, \uADF8\uB2E4\uC74C \uD574\uC2DC\uBD80(\uC774\uBBF8 \uB0B8 \uC815\uC218 \uD0A4\uB294 \uAC74\uB108\uB700)\uB97C \uB0B8\uB2E4.
2849
+ -- \uC0C1\uD0DC\uB97C \uD074\uB85C\uC800\uC5D0 \uB2F4\uC73C\uBBC0\uB85C (fn, state, ctrl) \uC911 state/ctrl\uC740 \uC548 \uC4F4\uB2E4.
2850
+ local function ${N.tableIter}(t)
2851
+ local i = 0
2852
+ local arrayDone = false
2853
+ local hk = nil
2854
+ return function()
2855
+ if not arrayDone then
2856
+ i = i + 1
2857
+ local v = t[i]
2858
+ if v ~= nil then
2859
+ return i, v
2860
+ end
2861
+ arrayDone = true
2862
+ end
2863
+ local k, v = next(t, hk)
2864
+ while k ~= nil do
2865
+ if type(k) ~= "number" or k ~= math.floor(k) or k < 1 or k >= i then
2866
+ hk = k
2867
+ return k, v
2868
+ end
2869
+ k, v = next(t, k)
2870
+ end
2871
+ return nil
2872
+ end
2873
+ end
2874
+
2844
2875
  -- MOVE
2845
2876
  ${N.handlers}[${op(0 /* MOVE */)}] = function(${N.frame}, pc, instr)
2846
2877
  ${N.frame}.${N.R}[instr[2]] = ${N.frame}.${N.R}[instr[3]]
@@ -3042,6 +3073,30 @@ ${N.handlers}[${op(28 /* RETURN */)}] = function(${N.frame}, pc, instr)
3042
3073
  return table.pack(table.unpack(${N.frame}.${N.R}, a, a + b - 2))
3043
3074
  end
3044
3075
 
3076
+ -- NORMITER: \uC81C\uB124\uB9AD for \uC9C4\uC785 \uC2DC \uC774\uD130\uB808\uC774\uD130 3-\uD29C\uD50C(R[A..A+2])\uC744 \uC815\uADDC\uD654.
3077
+ -- R[A]\uAC00 \uD568\uC218\uBA74 \uADF8\uB300\uB85C \uB450\uACE0(pairs/ipairs/\uCEE4\uC2A4\uD140 \uC774\uD130\uB808\uC774\uD130), \uD14C\uC774\uBE14\uC774\uBA74 __iter
3078
+ -- \uBA54\uD0C0\uBA54\uC11C\uB4DC\uAC00 \uC788\uC73C\uBA74 \uADF8\uAC78 \uD638\uCD9C\uD574 (fn,state,ctrl)\uB85C, \uC5C6\uC73C\uBA74 array-then-hash
3079
+ -- \uD074\uB85C\uC800 \uC774\uD130\uB808\uC774\uD130\uB85C \uBC14\uAFBC\uB2E4. \uC774\uD6C4 CALL \uD578\uB4E4\uB7EC\uAC00 \uD568\uC218\uB97C \uC815\uC0C1 \uD638\uCD9C\uD558\uAC8C \uB41C\uB2E4.
3080
+ ${N.handlers}[${op(35 /* NORMITER */)}] = function(${N.frame}, pc, instr)
3081
+ local a = instr[2]
3082
+ local it = ${N.frame}.${N.R}[a]
3083
+ if type(it) ~= "function" then
3084
+ local mt = getmetatable(it)
3085
+ local customIter = mt and rawget(mt, "__iter")
3086
+ if customIter ~= nil then
3087
+ local f, s, c = customIter(it)
3088
+ ${N.frame}.${N.R}[a] = f
3089
+ ${N.frame}.${N.R}[a + 1] = s
3090
+ ${N.frame}.${N.R}[a + 2] = c
3091
+ elseif type(it) == "table" then
3092
+ ${N.frame}.${N.R}[a] = ${N.tableIter}(it)
3093
+ ${N.frame}.${N.R}[a + 1] = nil
3094
+ ${N.frame}.${N.R}[a + 2] = nil
3095
+ end
3096
+ end
3097
+ return pc + 1
3098
+ end
3099
+
3045
3100
  -- FORPREP
3046
3101
  ${N.handlers}[${op(29 /* FORPREP */)}] = function(${N.frame}, pc, instr)
3047
3102
  local a = instr[2]
@@ -3169,6 +3224,7 @@ function generateVmNames(random = Math.random) {
3169
3224
  handlers: id(),
3170
3225
  dispatch: id(),
3171
3226
  rk: id(),
3227
+ tableIter: id(),
3172
3228
  frame: id(),
3173
3229
  R: id(),
3174
3230
  K: id(),
package/dist/index.js CHANGED
@@ -1466,6 +1466,7 @@ var Opcode = /* @__PURE__ */ ((Opcode2) => {
1466
1466
  Opcode2[Opcode2["VARARG"] = 32] = "VARARG";
1467
1467
  Opcode2[Opcode2["SETLIST"] = 33] = "SETLIST";
1468
1468
  Opcode2[Opcode2["IDIV"] = 34] = "IDIV";
1469
+ Opcode2[Opcode2["NORMITER"] = 35] = "NORMITER";
1469
1470
  return Opcode2;
1470
1471
  })(Opcode || {});
1471
1472
  function RK(regOrConstIdx, isConst) {
@@ -2281,6 +2282,8 @@ var VmCompiler = class {
2281
2282
  }
2282
2283
  }
2283
2284
  }
2285
+ state.regs.freeTemp(base + 3);
2286
+ this.emit(state, 35 /* NORMITER */, base, 0, 0, "normalize-generic-iter");
2284
2287
  const loopStart = state.proto.code.length;
2285
2288
  const nVars = stmt.variables.length;
2286
2289
  const callBase = state.regs.top();
@@ -2813,6 +2816,34 @@ local function ${N.rk}(${N.frame}, x)
2813
2816
  end
2814
2817
  end
2815
2818
 
2819
+ -- \uD50C\uB808\uC778 \uD14C\uC774\uBE14\uC5D0 \uB300\uD55C Luau \uC81C\uB124\uB9AD \uBC18\uBCF5(for k, v in t) \uC774\uD130\uB808\uC774\uD130.
2820
+ -- \uBC30\uC5F4\uBD80(1..\uACBD\uACC4)\uB97C \uC21C\uC11C\uB300\uB85C \uBA3C\uC800, \uADF8\uB2E4\uC74C \uD574\uC2DC\uBD80(\uC774\uBBF8 \uB0B8 \uC815\uC218 \uD0A4\uB294 \uAC74\uB108\uB700)\uB97C \uB0B8\uB2E4.
2821
+ -- \uC0C1\uD0DC\uB97C \uD074\uB85C\uC800\uC5D0 \uB2F4\uC73C\uBBC0\uB85C (fn, state, ctrl) \uC911 state/ctrl\uC740 \uC548 \uC4F4\uB2E4.
2822
+ local function ${N.tableIter}(t)
2823
+ local i = 0
2824
+ local arrayDone = false
2825
+ local hk = nil
2826
+ return function()
2827
+ if not arrayDone then
2828
+ i = i + 1
2829
+ local v = t[i]
2830
+ if v ~= nil then
2831
+ return i, v
2832
+ end
2833
+ arrayDone = true
2834
+ end
2835
+ local k, v = next(t, hk)
2836
+ while k ~= nil do
2837
+ if type(k) ~= "number" or k ~= math.floor(k) or k < 1 or k >= i then
2838
+ hk = k
2839
+ return k, v
2840
+ end
2841
+ k, v = next(t, k)
2842
+ end
2843
+ return nil
2844
+ end
2845
+ end
2846
+
2816
2847
  -- MOVE
2817
2848
  ${N.handlers}[${op(0 /* MOVE */)}] = function(${N.frame}, pc, instr)
2818
2849
  ${N.frame}.${N.R}[instr[2]] = ${N.frame}.${N.R}[instr[3]]
@@ -3014,6 +3045,30 @@ ${N.handlers}[${op(28 /* RETURN */)}] = function(${N.frame}, pc, instr)
3014
3045
  return table.pack(table.unpack(${N.frame}.${N.R}, a, a + b - 2))
3015
3046
  end
3016
3047
 
3048
+ -- NORMITER: \uC81C\uB124\uB9AD for \uC9C4\uC785 \uC2DC \uC774\uD130\uB808\uC774\uD130 3-\uD29C\uD50C(R[A..A+2])\uC744 \uC815\uADDC\uD654.
3049
+ -- R[A]\uAC00 \uD568\uC218\uBA74 \uADF8\uB300\uB85C \uB450\uACE0(pairs/ipairs/\uCEE4\uC2A4\uD140 \uC774\uD130\uB808\uC774\uD130), \uD14C\uC774\uBE14\uC774\uBA74 __iter
3050
+ -- \uBA54\uD0C0\uBA54\uC11C\uB4DC\uAC00 \uC788\uC73C\uBA74 \uADF8\uAC78 \uD638\uCD9C\uD574 (fn,state,ctrl)\uB85C, \uC5C6\uC73C\uBA74 array-then-hash
3051
+ -- \uD074\uB85C\uC800 \uC774\uD130\uB808\uC774\uD130\uB85C \uBC14\uAFBC\uB2E4. \uC774\uD6C4 CALL \uD578\uB4E4\uB7EC\uAC00 \uD568\uC218\uB97C \uC815\uC0C1 \uD638\uCD9C\uD558\uAC8C \uB41C\uB2E4.
3052
+ ${N.handlers}[${op(35 /* NORMITER */)}] = function(${N.frame}, pc, instr)
3053
+ local a = instr[2]
3054
+ local it = ${N.frame}.${N.R}[a]
3055
+ if type(it) ~= "function" then
3056
+ local mt = getmetatable(it)
3057
+ local customIter = mt and rawget(mt, "__iter")
3058
+ if customIter ~= nil then
3059
+ local f, s, c = customIter(it)
3060
+ ${N.frame}.${N.R}[a] = f
3061
+ ${N.frame}.${N.R}[a + 1] = s
3062
+ ${N.frame}.${N.R}[a + 2] = c
3063
+ elseif type(it) == "table" then
3064
+ ${N.frame}.${N.R}[a] = ${N.tableIter}(it)
3065
+ ${N.frame}.${N.R}[a + 1] = nil
3066
+ ${N.frame}.${N.R}[a + 2] = nil
3067
+ end
3068
+ end
3069
+ return pc + 1
3070
+ end
3071
+
3017
3072
  -- FORPREP
3018
3073
  ${N.handlers}[${op(29 /* FORPREP */)}] = function(${N.frame}, pc, instr)
3019
3074
  local a = instr[2]
@@ -3141,6 +3196,7 @@ function generateVmNames(random = Math.random) {
3141
3196
  handlers: id(),
3142
3197
  dispatch: id(),
3143
3198
  rk: id(),
3199
+ tableIter: id(),
3144
3200
  frame: id(),
3145
3201
  R: id(),
3146
3202
  K: id(),