-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathbinary.lua
More file actions
27 lines (24 loc) · 1.06 KB
/
binary.lua
File metadata and controls
27 lines (24 loc) · 1.06 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
27
-- This Script is Part of the Prometheus Obfuscator by levno-710
--
-- binary.lua
--
-- This Script contains the expression handler for the Binary operations (Add, Sub, Mul, Div, etc.).
local Ast = require("prometheus.ast");
return function(self, expression, funcDepth, numReturns)
local scope = self.activeBlock.scope;
local regs = {};
for i = 1, numReturns do
regs[i] = self:allocRegister();
if i == 1 then
local lhsReg = self:compileExpression(expression.lhs, funcDepth, 1)[1];
local rhsReg = self:compileExpression(expression.rhs, funcDepth, 1)[1];
local binaryExpr = Ast[expression.kind](self:register(scope, lhsReg), self:register(scope, rhsReg));
self:addStatement(self:setRegister(scope, regs[i], binaryExpr), {regs[i]}, {lhsReg, rhsReg}, true);
self:freeRegister(rhsReg, false);
self:freeRegister(lhsReg, false);
else
self:addStatement(self:setRegister(scope, regs[i], Ast.NilExpression()), {regs[i]}, {}, false);
end
end
return regs;
end;