warcraft-vscode 0.3.4 → 0.3.5

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.3.5](https://github.com/warcraft-iii/warcraft-vscode/compare/v0.3.4...v0.3.5) (2026-01-19)
2
+
3
+
4
+
1
5
  ## [0.3.4](https://github.com/warcraft-iii/warcraft-vscode/compare/v0.3.3...v0.3.4) (2025-12-30)
2
6
 
3
7
 
@@ -37,7 +37,7 @@ return {
37
37
  {
38
38
  Name = "Vmify";
39
39
  Settings = {
40
-
40
+
41
41
  };
42
42
  },
43
43
  {
@@ -55,6 +55,27 @@ return {
55
55
  },
56
56
  }
57
57
  };
58
+ ["Vmify"] = {
59
+ -- The default LuaVersion is Lua51
60
+ LuaVersion = "Lua51";
61
+ -- For minifying no VarNamePrefix is applied
62
+ VarNamePrefix = "";
63
+ -- Name Generator for Variables that look like this: IlI1lI1l
64
+ NameGenerator = "MangledShuffled";
65
+ -- No pretty printing
66
+ PrettyPrint = false;
67
+ -- Seed is generated based on current time
68
+ Seed = 0;
69
+ -- Obfuscation steps
70
+ Steps = {
71
+ {
72
+ Name = "Vmify";
73
+ Settings = {
74
+
75
+ };
76
+ },
77
+ }
78
+ };
58
79
  ["Medium"] = {
59
80
  -- The default LuaVersion is Lua51
60
81
  LuaVersion = "Lua51";
@@ -83,7 +104,7 @@ return {
83
104
  {
84
105
  Name = "Vmify";
85
106
  Settings = {
86
-
107
+
87
108
  };
88
109
  },
89
110
  {
@@ -126,7 +147,7 @@ return {
126
147
  {
127
148
  Name = "Vmify";
128
149
  Settings = {
129
-
150
+
130
151
  };
131
152
  },
132
153
  {
@@ -144,7 +165,7 @@ return {
144
165
  {
145
166
  Name = "Vmify";
146
167
  Settings = {
147
-
168
+
148
169
  };
149
170
  },
150
171
  {
@@ -33,7 +33,7 @@ function Compiler:new()
33
33
  registerVars = {};
34
34
 
35
35
  VAR_REGISTER = newproxy(false);
36
- RETURN_ALL = newproxy(false);
36
+ RETURN_ALL = newproxy(false);
37
37
  POS_REGISTER = newproxy(false);
38
38
  RETURN_REGISTER = newproxy(false);
39
39
  UPVALUE = newproxy(false);
@@ -86,7 +86,7 @@ function Compiler:setActiveBlock(block)
86
86
  end
87
87
 
88
88
  function Compiler:addStatement(statement, writes, reads, usesUpvals)
89
- if(self.activeBlock.advanceToNextBlock) then
89
+ if(self.activeBlock.advanceToNextBlock) then
90
90
  table.insert(self.activeBlock.statements, {
91
91
  statement = statement,
92
92
  writes = lookupify(writes),
@@ -123,7 +123,7 @@ function Compiler:compile(ast)
123
123
  local _, setmetatableVar = newGlobalScope:resolve("setmetatable");
124
124
  local _, getmetatableVar = newGlobalScope:resolve("getmetatable");
125
125
  local _, selectVar = newGlobalScope:resolve("select");
126
-
126
+
127
127
  psc:addReferenceToHigherScope(newGlobalScope, getfenvVar, 2);
128
128
  psc:addReferenceToHigherScope(newGlobalScope, tableVar);
129
129
  psc:addReferenceToHigherScope(newGlobalScope, unpackVar);
@@ -331,7 +331,7 @@ function Compiler:getCreateClosureVar(argCount)
331
331
  local var = Ast.AssignmentVariable(self.scope, self.scope:addVariable());
332
332
  local createClosureScope = Scope:new(self.scope);
333
333
  local createClosureSubScope = Scope:new(createClosureScope);
334
-
334
+
335
335
  local createClosurePosArg = createClosureScope:addVariable();
336
336
  local createClosureUpvalsArg = createClosureScope:addVariable();
337
337
  local createClosureProxyObject = createClosureScope:addVariable();
@@ -384,7 +384,7 @@ function Compiler:getCreateClosureVar(argCount)
384
384
  }
385
385
  end
386
386
 
387
-
387
+
388
388
  local var = self.createClosureVars[argCount].var;
389
389
  return var.scope, var.id;
390
390
  end
@@ -419,7 +419,7 @@ function Compiler:createUpvaluesGcFunc()
419
419
  local ifScope = Scope:new(whileScope);
420
420
  ifScope:addReferenceToHigherScope(self.scope, self.upvaluesReferenceCountsTable, 1);
421
421
  ifScope:addReferenceToHigherScope(self.scope, self.upvaluesTable, 1);
422
-
422
+
423
423
 
424
424
  return Ast.FunctionLiteralExpression({Ast.VariableExpression(scope, selfVar)}, Ast.Block({
425
425
  Ast.LocalVariableDeclaration(scope, {iteratorVar, valueVar}, {Ast.NumberExpression(1), Ast.IndexExpression(Ast.VariableExpression(scope, selfVar), Ast.NumberExpression(1))}),
@@ -674,7 +674,7 @@ function Compiler:emitContainerFuncBody()
674
674
 
675
675
  self.whileScope:addReferenceToHigherScope(self.containerFuncScope, self.returnVar, 1);
676
676
  self.whileScope:addReferenceToHigherScope(self.containerFuncScope, self.posVar);
677
-
677
+
678
678
  self.containerFuncScope:addReferenceToHigherScope(self.scope, self.unpackVar);
679
679
 
680
680
  local declarations = {
@@ -736,7 +736,7 @@ function Compiler:allocRegister(isVar)
736
736
  return self.RETURN_REGISTER;
737
737
  end
738
738
  end
739
-
739
+
740
740
 
741
741
  local id = 0;
742
742
  if self.usedRegisters < MAX_REGS * MAX_REGS_MUL then
@@ -921,7 +921,7 @@ end
921
921
 
922
922
  function Compiler:setPos(scope, val)
923
923
  if not val then
924
-
924
+
925
925
  local v = Ast.IndexExpression(self:env(scope), randomStrings.randomStringNode(math.random(12, 14))); --Ast.NilExpression();
926
926
  scope:addReferenceToHigherScope(self.containerFuncScope, self.posVar);
927
927
  return Ast.AssignmentStatement({Ast.AssignmentVariable(self.containerFuncScope, self.posVar)}, {v});
@@ -979,7 +979,7 @@ function Compiler:compileTopNode(node)
979
979
  AstKind.TopNode,
980
980
  }
981
981
  -- Collect Upvalues
982
- visitast(node, function(node, data)
982
+ visitast(node, function(node, data)
983
983
  if node.kind == AstKind.Block then
984
984
  node.scope.__depth = data.functionData.depth;
985
985
  end
@@ -1100,7 +1100,7 @@ function Compiler:compileFunction(node, funcDepth)
1100
1100
  self:setActiveBlock(oldActiveBlock);
1101
1101
 
1102
1102
  local scope = self.activeBlock.scope;
1103
-
1103
+
1104
1104
  local retReg = self:allocRegister(false);
1105
1105
 
1106
1106
  local isVarargFunction = #node.args > 0 and node.args[#node.args].kind == AstKind.VarargExpression;
@@ -1250,7 +1250,7 @@ function Compiler:compileStatement(statement, funcDepth)
1250
1250
  for i, reg in ipairs(regs) do
1251
1251
  self:freeRegister(reg, false);
1252
1252
  end
1253
-
1253
+
1254
1254
  return;
1255
1255
  end
1256
1256
 
@@ -1283,13 +1283,13 @@ function Compiler:compileStatement(statement, funcDepth)
1283
1283
  for i, reg in ipairs(regs) do
1284
1284
  self:freeRegister(reg, false);
1285
1285
  end
1286
-
1286
+
1287
1287
  return;
1288
1288
  end
1289
1289
 
1290
1290
  -- Local Function Declaration
1291
1291
  if(statement.kind == AstKind.LocalFunctionDeclaration) then
1292
-
1292
+
1293
1293
  if(self:isUpvalue(statement.scope, statement.id)) then
1294
1294
  local varReg = self:getVarRegister(statement.scope, statement.id, funcDepth, nil);
1295
1295
  scope:addReferenceToHigherScope(self.scope, self.allocUpvalFunction);
@@ -1478,7 +1478,7 @@ function Compiler:compileStatement(statement, funcDepth)
1478
1478
  local innerBlock = self:createBlock();
1479
1479
 
1480
1480
  self:addStatement(self:setRegister(scope, self.POS_REGISTER, Ast.OrExpression(Ast.AndExpression(self:register(scope, conditionReg), Ast.NumberExpression(innerBlock.id)), Ast.NumberExpression(nextBlock.id))), {self.POS_REGISTER}, {conditionReg}, false);
1481
-
1481
+
1482
1482
  self:freeRegister(conditionReg, false);
1483
1483
 
1484
1484
  self:setActiveBlock(innerBlock);
@@ -1497,7 +1497,7 @@ function Compiler:compileStatement(statement, funcDepth)
1497
1497
  end
1498
1498
  local scope = self.activeBlock.scope;
1499
1499
  self:addStatement(self:setRegister(scope, self.POS_REGISTER, Ast.OrExpression(Ast.AndExpression(self:register(scope, conditionReg), Ast.NumberExpression(innerBlock.id)), Ast.NumberExpression(nextBlock.id))), {self.POS_REGISTER}, {conditionReg}, false);
1500
-
1500
+
1501
1501
  self:freeRegister(conditionReg, false);
1502
1502
 
1503
1503
  self:setActiveBlock(innerBlock);
@@ -1552,28 +1552,39 @@ function Compiler:compileStatement(statement, funcDepth)
1552
1552
  if(statement.kind == AstKind.RepeatStatement) then
1553
1553
  local innerBlock = self:createBlock();
1554
1554
  local finalBlock = self:createBlock();
1555
- local checkBlock = self:createBlock();
1556
- statement.__start_block = checkBlock;
1555
+ statement.__start_block = innerBlock;
1557
1556
  statement.__final_block = finalBlock;
1558
1557
 
1559
- local conditionReg = self:compileExpression(statement.condition, funcDepth, 1)[1];
1560
1558
  self:addStatement(self:setRegister(scope, self.POS_REGISTER, Ast.NumberExpression(innerBlock.id)), {self.POS_REGISTER}, {}, false);
1561
- self:freeRegister(conditionReg, false);
1562
-
1563
1559
  self:setActiveBlock(innerBlock);
1564
- self:compileBlock(statement.body, funcDepth);
1565
- local scope = self.activeBlock.scope
1566
- self:addStatement(self:setPos(scope, checkBlock.id), {self.POS_REGISTER}, {}, false);
1567
- self:setActiveBlock(checkBlock);
1560
+
1561
+ -- Compile body statements without automatic variable cleanup
1562
+ -- self:compileBlock(statement.body, funcDepth);
1563
+ for i, stat in ipairs(statement.body.statements) do
1564
+ self:compileStatement(stat, funcDepth);
1565
+ end;
1566
+
1568
1567
  local scope = self.activeBlock.scope;
1569
- local conditionReg = self:compileExpression(statement.condition, funcDepth, 1)[1];
1570
- self:addStatement(self:setRegister(scope, self.POS_REGISTER, Ast.OrExpression(Ast.AndExpression(self:register(scope, conditionReg), Ast.NumberExpression(finalBlock.id)), Ast.NumberExpression(innerBlock.id))), {self.POS_REGISTER}, {conditionReg}, false);
1568
+ -- Evaluate condition (can access body's local variables)
1569
+ local conditionReg = (self:compileExpression(statement.condition, funcDepth, 1))[1];
1570
+ self:addStatement(self:setRegister(scope, self.POS_REGISTER, Ast.OrExpression(Ast.AndExpression(self:register(scope, conditionReg), Ast.NumberExpression(finalBlock.id)), Ast.NumberExpression(innerBlock.id))), { self.POS_REGISTER }, { conditionReg }, false);
1571
1571
  self:freeRegister(conditionReg, false);
1572
1572
 
1573
- self:setActiveBlock(finalBlock);
1573
+ -- Clean up body's local variables
1574
+ for id, name in ipairs(statement.body.scope.variables) do
1575
+ local varReg = self:getVarRegister(statement.body.scope, id, funcDepth, nil);
1576
+ if self:isUpvalue(statement.body.scope, id) then
1577
+ scope:addReferenceToHigherScope(self.scope, self.freeUpvalueFunc);
1578
+ self:addStatement(self:setRegister(scope, varReg, Ast.FunctionCallExpression(Ast.VariableExpression(self.scope, self.freeUpvalueFunc), { self:register(scope, varReg) })), { varReg }, { varReg }, false);
1579
+ else
1580
+ self:addStatement(self:setRegister(scope, varReg, Ast.NilExpression()), { varReg }, {}, false);
1581
+ end;
1582
+ self:freeRegister(varReg, true);
1583
+ end;
1574
1584
 
1585
+ self:setActiveBlock(finalBlock);
1575
1586
  return;
1576
- end
1587
+ end;
1577
1588
 
1578
1589
  -- For Statement
1579
1590
  if(statement.kind == AstKind.ForStatement) then
@@ -1602,7 +1613,7 @@ function Compiler:compileStatement(statement, funcDepth)
1602
1613
  local tmpReg = self:allocRegister(false);
1603
1614
  self:addStatement(self:setRegister(scope, tmpReg, Ast.NumberExpression(0)), {tmpReg}, {}, false);
1604
1615
  local incrementIsNegReg = self:allocRegister(false);
1605
- self:addStatement(self:setRegister(scope, incrementIsNegReg, Ast.LessThanExpression(self:register(scope, incrementReg), self:register(scope, tmpReg))), {incrementIsNegReg}, {incrementReg, tmpReg}, false);
1616
+ self:addStatement(self:setRegister(scope, incrementIsNegReg, Ast.LessThanExpression(self:register(scope, incrementReg), self:register(scope, tmpReg))), {incrementIsNegReg}, {incrementReg, tmpReg}, false);
1606
1617
  self:freeRegister(tmpReg);
1607
1618
 
1608
1619
  local currentReg = self:allocRegister(true);
@@ -1646,10 +1657,10 @@ function Compiler:compileStatement(statement, funcDepth)
1646
1657
  self:addStatement(self:setRegister(scope, varReg, self:register(scope, currentReg)), {varReg}, {currentReg}, false);
1647
1658
  end
1648
1659
 
1649
-
1660
+
1650
1661
  self:compileBlock(statement.body, funcDepth);
1651
1662
  self:addStatement(self:setRegister(scope, self.POS_REGISTER, Ast.NumberExpression(checkBlock.id)), {self.POS_REGISTER}, {}, false);
1652
-
1663
+
1653
1664
  self.registers[self.POS_REGISTER] = self.VAR_REGISTER;
1654
1665
  self:freeRegister(finalReg);
1655
1666
  self:freeRegister(incrementIsNegReg);
@@ -1983,7 +1994,7 @@ function Compiler:compileExpression(expression, funcDepth, numReturns)
1983
1994
  retRegs[i] = self:allocRegister(false);
1984
1995
  end
1985
1996
  end
1986
-
1997
+
1987
1998
  local regs = {};
1988
1999
  local args = {};
1989
2000
  for i, expr in ipairs(expression.args) do
@@ -2005,13 +2016,13 @@ function Compiler:compileExpression(expression, funcDepth, numReturns)
2005
2016
  else
2006
2017
  if(numReturns > 1) then
2007
2018
  local tmpReg = self:allocRegister(false);
2008
-
2019
+
2009
2020
  self:addStatement(self:setRegister(scope, tmpReg, Ast.TableConstructorExpression{Ast.TableEntry(Ast.FunctionCallExpression(self:register(scope, baseReg), args))}), {tmpReg}, {baseReg, unpack(regs)}, true);
2010
-
2021
+
2011
2022
  for i, reg in ipairs(retRegs) do
2012
2023
  self:addStatement(self:setRegister(scope, reg, Ast.IndexExpression(self:register(scope, tmpReg), Ast.NumberExpression(i))), {reg}, {tmpReg}, false);
2013
2024
  end
2014
-
2025
+
2015
2026
  self:freeRegister(tmpReg, false);
2016
2027
  else
2017
2028
  self:addStatement(self:setRegister(scope, retRegs[1], Ast.FunctionCallExpression(self:register(scope, baseReg), args)), {retRegs[1]}, {baseReg, unpack(regs)}, true);
@@ -2022,7 +2033,7 @@ function Compiler:compileExpression(expression, funcDepth, numReturns)
2022
2033
  for i, reg in ipairs(regs) do
2023
2034
  self:freeRegister(reg, false);
2024
2035
  end
2025
-
2036
+
2026
2037
  return retRegs;
2027
2038
  end
2028
2039
 
@@ -2085,7 +2096,7 @@ function Compiler:compileExpression(expression, funcDepth, numReturns)
2085
2096
  for i, reg in ipairs(regs) do
2086
2097
  self:freeRegister(reg, false);
2087
2098
  end
2088
-
2099
+
2089
2100
  return retRegs;
2090
2101
  end
2091
2102
 
@@ -2175,7 +2186,7 @@ function Compiler:compileExpression(expression, funcDepth, numReturns)
2175
2186
  return regs;
2176
2187
  end
2177
2188
 
2178
- if(expression.kind == AstKind.OrExpression) then
2189
+ if(expression.kind == AstKind.OrExpression) then
2179
2190
  local posState = self.registers[self.POS_REGISTER];
2180
2191
  self.registers[self.POS_REGISTER] = self.VAR_REGISTER;
2181
2192
 
@@ -2234,7 +2245,7 @@ function Compiler:compileExpression(expression, funcDepth, numReturns)
2234
2245
  return regs;
2235
2246
  end
2236
2247
 
2237
- if(expression.kind == AstKind.AndExpression) then
2248
+ if(expression.kind == AstKind.AndExpression) then
2238
2249
  local posState = self.registers[self.POS_REGISTER];
2239
2250
  self.registers[self.POS_REGISTER] = self.VAR_REGISTER;
2240
2251
 
@@ -2254,7 +2265,7 @@ function Compiler:compileExpression(expression, funcDepth, numReturns)
2254
2265
  self:addStatement(self:copyRegisters(scope, {tmpReg}, {self.POS_REGISTER}), {tmpReg}, {self.POS_REGISTER}, false);
2255
2266
  end
2256
2267
 
2257
-
2268
+
2258
2269
  local lhsReg = self:compileExpression(expression.lhs, funcDepth, 1)[1];
2259
2270
  if(expression.rhs.isConstant) then
2260
2271
  local rhsReg = self:compileExpression(expression.rhs, funcDepth, 1)[1];
@@ -38,6 +38,13 @@ local ASSIGNMENT_NO_WARN_LOOKUP = lookupify{
38
38
  AstKind.VarargExpression
39
39
  };
40
40
 
41
+ local CALLABLE_PREFIX_EXPRESSION_LOOKUP = lookupify{
42
+ AstKind.VariableExpression,
43
+ AstKind.IndexExpression,
44
+ AstKind.FunctionCallExpression,
45
+ AstKind.PassSelfFunctionCallExpression
46
+ };
47
+
41
48
  local function generateError(self, message)
42
49
  local token;
43
50
  if(self.index > self.length) then
@@ -782,6 +789,10 @@ end
782
789
 
783
790
  function Parser:expressionFunctionCall(scope, base)
784
791
  base = base or self:expressionIndex(scope);
792
+
793
+ if(not (base and (CALLABLE_PREFIX_EXPRESSION_LOOKUP[base.kind] or base.isParenthesizedExpression))) then
794
+ return base;
795
+ end
785
796
 
786
797
  -- Normal Function Call
787
798
  local args = {};
@@ -887,6 +898,9 @@ function Parser:expressionLiteral(scope)
887
898
  if(consume(self, TokenKind.Symbol, "(")) then
888
899
  local expr = self:expression(scope);
889
900
  expect(self, TokenKind.Symbol, ")");
901
+ if expr then
902
+ expr.isParenthesizedExpression = true;
903
+ end
890
904
  return expr;
891
905
  end
892
906
 
@@ -71,10 +71,6 @@ function AntiTamper:apply(ast, pipeline)
71
71
  valid = false;
72
72
  end
73
73
 
74
- if debug.getlocal(funcs[i], 1) then
75
- valid = false;
76
- end
77
-
78
74
  if debug.getupvalue(funcs[i], 1) then
79
75
  valid = false;
80
76
  end