-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathwhile_statement.lua
More file actions
31 lines (25 loc) · 1.29 KB
/
while_statement.lua
File metadata and controls
31 lines (25 loc) · 1.29 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
28
29
30
31
-- This Script is Part of the Prometheus Obfuscator by levno-710
--
-- while_statement.lua
--
-- This Script contains the statement handler for the WhileStatement
local Ast = require("prometheus.ast");
return function(self, statement, funcDepth)
local scope = self.activeBlock.scope;
local innerBlock = self:createBlock();
local finalBlock = self:createBlock();
local checkBlock = self:createBlock();
statement.__start_block = checkBlock;
statement.__final_block = finalBlock;
self:addStatement(self:setPos(scope, checkBlock.id), {self.POS_REGISTER}, {}, false);
self:setActiveBlock(checkBlock);
scope = self.activeBlock.scope;
local conditionReg = self:compileExpression(statement.condition, funcDepth, 1)[1];
self:addStatement(self:setRegister(scope, self.POS_REGISTER, Ast.OrExpression(Ast.AndExpression(self:register(scope, conditionReg), Ast.NumberExpression(innerBlock.id)), Ast.NumberExpression(finalBlock.id))), {self.POS_REGISTER}, {conditionReg}, false);
self:freeRegister(conditionReg, false);
self:setActiveBlock(innerBlock);
local scope = self.activeBlock.scope;
self:compileBlock(statement.body, funcDepth);
self:addStatement(self:setPos(scope, checkBlock.id), {self.POS_REGISTER}, {}, false);
self:setActiveBlock(finalBlock);
end;