aboutsummaryrefslogtreecommitdiff
path: root/src/LuaMinify.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/LuaMinify.h')
-rw-r--r--src/LuaMinify.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/LuaMinify.h b/src/LuaMinify.h
index 4990646..76d7759 100644
--- a/src/LuaMinify.h
+++ b/src/LuaMinify.h
@@ -298,8 +298,12 @@ local Scope = {
298 298
299 ObfuscateLocals = function(self, recommendedMaxLength, validNameChars) 299 ObfuscateLocals = function(self, recommendedMaxLength, validNameChars)
300 for i, var in pairs(self.Locals) do 300 for i, var in pairs(self.Locals) do
301 local id = GetUnique(self) 301 if var.Name == "_ENV" then
302 self:RenameLocal(var.Name, id) 302 self:RenameLocal(var.Name, "_ENV")
303 else
304 local id = GetUnique(self)
305 self:RenameLocal(var.Name, id)
306 end
303 end 307 end
304 end 308 end
305} 309}
@@ -1502,13 +1506,24 @@ R"lua_codes(
1502 1506
1503 elseif tok:ConsumeKeyword('local', tokenList) then 1507 elseif tok:ConsumeKeyword('local', tokenList) then
1504 if tok:Is('Ident') then 1508 if tok:Is('Ident') then
1505 local varList = { tok:Get(tokenList).Data } 1509 local varList, attrList = {}, {}
1506 while tok:ConsumeSymbol(',', tokenList) do 1510 repeat
1507 if not tok:Is('Ident') then 1511 if not tok:Is('Ident') then
1508 return false, GenerateError("local var name expected") 1512 return false, GenerateError("local var name expected")
1509 end 1513 end
1510 varList[#varList+1] = tok:Get(tokenList).Data 1514 varList[#varList+1] = tok:Get(tokenList).Data
1511 end 1515 if tok:ConsumeSymbol('<', tokenList) then
1516 if not tok:Is('Ident') then
1517 return false, GenerateError("attrib name expected")
1518 end
1519 attrList[#attrList+1] = tok:Get(tokenList).Data
1520 if not tok:ConsumeSymbol('>', tokenList) then
1521 return false, GenerateError("missing '>' to close attrib name")
1522 end
1523 else
1524 attrList[#attrList+1] = false
1525 end
1526 until not tok:ConsumeSymbol(',', tokenList)
1512 1527
1513 local initList = {} 1528 local initList = {}
1514 if tok:ConsumeSymbol('=', tokenList) then 1529 if tok:ConsumeSymbol('=', tokenList) then
@@ -1529,6 +1544,7 @@ R"lua_codes(
1529 local nodeLocal = {} 1544 local nodeLocal = {}
1530 nodeLocal.AstType = 'LocalStatement' 1545 nodeLocal.AstType = 'LocalStatement'
1531 nodeLocal.LocalList = varList 1546 nodeLocal.LocalList = varList
1547 nodeLocal.AttrList = attrList
1532 nodeLocal.InitList = initList 1548 nodeLocal.InitList = initList
1533 nodeLocal.Tokens = tokenList 1549 nodeLocal.Tokens = tokenList
1534 -- 1550 --
@@ -1923,8 +1939,11 @@ local function Format_Mini(ast)
1923 out = out.."local " 1939 out = out.."local "
1924 for i = 1, #statement.LocalList do 1940 for i = 1, #statement.LocalList do
1925 out = out..statement.LocalList[i].Name 1941 out = out..statement.LocalList[i].Name
1926 if i ~= #statement.LocalList then 1942 if statement.AttrList[i] then
1927 out = out.."," 1943 out = out.."<"..statement.AttrList[i]..">"
1944 if i == #statement.LocalList then
1945 out = out.." "
1946 end
1928 end 1947 end
1929 end 1948 end
1930 if #statement.InitList > 0 then 1949 if #statement.InitList > 0 then