-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathlocal_function_declaration.lua
More file actions
27 lines (22 loc) · 1.27 KB
/
local_function_declaration.lua
File metadata and controls
27 lines (22 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- This Script is Part of the Prometheus Obfuscator by levno-710
--
-- local_function_declaration.lua
--
-- This Script contains the statement handler for the LocalFunctionDeclaration
local Ast = require("prometheus.ast");
return function(self, statement, funcDepth)
local scope = self.activeBlock.scope;
if(self:isUpvalue(statement.scope, statement.id)) then
local varReg = self:getVarRegister(statement.scope, statement.id, funcDepth, nil);
scope:addReferenceToHigherScope(self.scope, self.allocUpvalFunction);
self:addStatement(self:setRegister(scope, varReg, Ast.FunctionCallExpression(Ast.VariableExpression(self.scope, self.allocUpvalFunction), {})), {varReg}, {}, false);
local retReg = self:compileFunction(statement, funcDepth);
self:addStatement(self:setUpvalueMember(scope, self:register(scope, varReg), self:register(scope, retReg)), {}, {varReg, retReg}, true);
self:freeRegister(retReg, false);
else
local retReg = self:compileFunction(statement, funcDepth);
local varReg = self:getVarRegister(statement.scope, statement.id, funcDepth, retReg);
self:addStatement(self:copyRegisters(scope, {varReg}, {retReg}), {varReg}, {retReg}, false);
self:freeRegister(retReg, false);
end
end;