@@ -593,10 +593,10 @@ end
593593
594594function Tokenizer :consumeLongComment ()
595595 self :consumeCharacter (" [" )
596- if self .curChar ~= " [" then
596+ if self .curChar ~= " [" then
597597 return self :consumeShortComment ()
598598 end
599- local depth = self :calculateDelimiterDepth ()
599+ local depth = self :calculateDelimiterDepth ()
600600 self :consumeCharacter (" [" )
601601 self :consumeUntilEndingDelimiter (depth )
602602
@@ -1559,7 +1559,7 @@ function Parser:parseLocalStatement()
15591559 }
15601560 }
15611561 else
1562- -- It's a regular local variable declaration.
1562+ -- It's a regular local variable declaration.
15631563 -- <ident_list> [= <expr_list>]
15641564 local variables = self :consumeIdentifierList ()
15651565 local initializers = {}
@@ -1993,7 +1993,7 @@ CodeGenerator.CONFIG = {
19931993 MAX_REGISTERS = 250 ,
19941994
19951995 -- Maximum amount of elements for a single SETLIST instruction.
1996- -- If more elements are needed, multiple SETLIST instructions are emitted.
1996+ -- If more elements are needed, multiple SETLIST instructions are emitted.
19971997 SETLIST_MAX = 50 ,
19981998
19991999 -- Node kinds that can return multiple values (multiret).
@@ -2113,7 +2113,7 @@ function CodeGenerator:leaveScope()
21132113 -- count how many local variables are declared in this scope to determine
21142114 -- how many registers should be in use at most.
21152115
2116- -- Arguments are treated as local variables.
2116+ -- Arguments are treated as local variables.
21172117 local variableCount = 0
21182118 for _ in pairs (currentScope .locals ) do
21192119 variableCount = variableCount + 1
@@ -2131,7 +2131,7 @@ function CodeGenerator:leaveScope()
21312131 end
21322132 end
21332133
2134- -- Remove the current scope from the stack.
2134+ -- Remove the current scope from the stack.
21352135 table.remove (scopes )
21362136
21372137 local needClose = currentScope .needClose and not currentScope .isFunction
@@ -2141,8 +2141,8 @@ function CodeGenerator:leaveScope()
21412141
21422142 if needClose then
21432143 if self .breakJumpPCs then
2144- self .breakJumpPCs .needClose = true
2145- end
2144+ self .breakJumpPCs .needClose = true
2145+ end
21462146
21472147 -- OP_CLOSE [A] close all variables in the stack up to (>=) R(A)
21482148 self :emitInstruction (" CLOSE" , self .stackSize , 0 , 0 )
@@ -2328,7 +2328,7 @@ function CodeGenerator:processConstantOrExpression(node, register)
23282328 end
23292329 end
23302330
2331- -- Otherwise, process it as an expression
2331+ -- Otherwise, process it as an expression
23322332 return self :processExpressionNode (node , register )
23332333end
23342334
@@ -2363,9 +2363,9 @@ function CodeGenerator:patchJump(fromPC, toPC)
23632363 local instruction = self .proto .code [fromPC ]
23642364 if not instruction then
23652365 error (
2366- " CodeGenerator: Invalid 'fromPC' for jump patching: "
2367- .. tostring (fromPC )
2368- )
2366+ " CodeGenerator: Invalid 'fromPC' for jump patching: "
2367+ .. tostring (fromPC )
2368+ )
23692369 end
23702370
23712371 local offset = toPC - (fromPC + 1 )
@@ -2387,7 +2387,7 @@ function CodeGenerator:patchBreakJumpsToHere()
23872387 if not self .breakJumpPCs then return end
23882388 self :patchJumpsToHere (self .breakJumpPCs )
23892389 if # self .breakJumpPCs > 0 and self .breakJumpPCs .needClose then
2390- -- OP_CLOSE [A] close all variables in the stack up to (>=) R(A)
2390+ -- OP_CLOSE [A] close all variables in the stack up to (>=) R(A)
23912391 self :emitInstruction (" CLOSE" , self .stackSize , 0 , 0 )
23922392 end
23932393 self .breakJumpPCs = nil
@@ -2618,7 +2618,7 @@ function CodeGenerator:processBinaryOperator(node, register)
26182618 -- String concatenation (..)
26192619 elseif operator == " .." then
26202620 local bottomRegister = self :processExpressionNode (left )
2621-
2621+
26222622 -- Optimization: Flatten consecutive concatenations.
26232623 -- That will help us reduce the number of CONCAT instructions.
26242624 -- For example, the expression:
@@ -3011,7 +3011,7 @@ function CodeGenerator:processRepeatStatement(node)
30113011 local conditionRegister = self :processExpressionNode (condition )
30123012
30133013 if self .currentScope .needClose then
3014- -- OP_CLOSE [A] close all variables in the stack up to (>=) R(A)
3014+ -- OP_CLOSE [A] close all variables in the stack up to (>=) R(A)
30153015 self :emitInstruction (" CLOSE" , self .currentScope .parentScope .stackSize , 0 , 0 )
30163016 self .currentScope .needClose = false
30173017 end
@@ -3199,9 +3199,9 @@ function CodeGenerator:generateClosure(proto, closureRegister)
31993199 self :emitInstruction (" GETUPVAL" , 0 , self :findOrCreateUpvalue (upvalueName ))
32003200 else -- Assume it's a global.
32013201 error (
3202- " CodeGenerator: The upvalue cannot be a global: "
3203- .. upvalueName
3204- )
3202+ " CodeGenerator: The upvalue cannot be a global: "
3203+ .. upvalueName
3204+ )
32053205 end
32063206 end
32073207end
@@ -3427,9 +3427,9 @@ end
34273427function BytecodeEmitter :encodeUint8 (value )
34283428 if value < 0 or value > 2 ^ 8 - 1 then
34293429 error (
3430- " BytecodeEmitter: encodeUint8 value out of range of u8: "
3431- .. tostring (value )
3432- )
3430+ " BytecodeEmitter: encodeUint8 value out of range of u8: "
3431+ .. tostring (value )
3432+ )
34333433 end
34343434
34353435 return string.char (value % 256 )
@@ -3439,9 +3439,9 @@ end
34393439function BytecodeEmitter :encodeUint32 (value )
34403440 if value < 0 or value > 2 ^ 32 - 1 then
34413441 error (
3442- " BytecodeEmitter: encodeUint32 value out of range of u32: "
3443- .. tostring (value )
3444- )
3442+ " BytecodeEmitter: encodeUint32 value out of range of u32: "
3443+ .. tostring (value )
3444+ )
34453445 end
34463446
34473447 local b1 = value % 256 value = math.floor (value / 256 )
@@ -3456,9 +3456,9 @@ end
34563456function BytecodeEmitter :encodeUint64 (value )
34573457 if value < 0 or value > 2 ^ 64 - 1 then
34583458 error (
3459- " BytecodeEmitter: encodeUint64 value out of range of u64: "
3460- .. tostring (value )
3461- )
3459+ " BytecodeEmitter: encodeUint64 value out of range of u64: "
3460+ .. tostring (value )
3461+ )
34623462 end
34633463
34643464 local lowWord = value % 2 ^ 32
@@ -3485,7 +3485,7 @@ function BytecodeEmitter:encodeFloat64(value)
34853485 -- The special representation for NaN is:
34863486 -- exponent = all bits set to 1 (2047)
34873487 -- faction = non-zero value for quiet NaN (we'll use 1)
3488- --
3488+ --
34893489 -- Fun fact: IEEE 754 defines two types of NaN:
34903490 -- - Quiet NaN (qNaN): The most significant bit of the fraction is set to 1.
34913491 -- - Signaling NaN (sNaN): The most significant bit of the fraction is set to 0.
@@ -3681,10 +3681,10 @@ function BytecodeEmitter:encodeInstruction(instruction)
36813681 end
36823682
36833683 error (
3684- " BytecodeEmitter: Unsupported instruction format for '"
3685- .. instructionName
3686- .. " '"
3687- )
3684+ " BytecodeEmitter: Unsupported instruction format for '"
3685+ .. instructionName
3686+ .. " '"
3687+ )
36883688end
36893689
36903690-- Serializes the code section of a function prototype.
@@ -3718,8 +3718,8 @@ end
37183718function BytecodeEmitter :encodePrototype (proto )
37193719 -- Basic validation of the function prototype.
37203720 if not proto .code or not proto .constants then
3721- error (" BytecodeEmitter: Invalid function prototype" )
3722- end
3721+ error (" BytecodeEmitter: Invalid function prototype" )
3722+ end
37233723
37243724 return table.concat ({
37253725 -- Header --
@@ -3814,7 +3814,7 @@ end
38143814
38153815function VirtualMachine :pushClosure (closure )
38163816 closure = {
3817- env = closure .env or _G ,
3817+ env = closure .env or _G ,
38183818 proto = closure .proto ,
38193819 upvalues = closure .upvalues or {},
38203820 }
@@ -4133,7 +4133,7 @@ function VirtualMachine:executeClosure(...)
41334133 top = a + b
41344134 end
41354135
4136- -- Optimization:
4136+ -- Optimization:
41374137 -- Since TAILCALL always comes before RETURN,
41384138 -- we can just return the function call results directly.
41394139
@@ -4285,27 +4285,27 @@ function VirtualMachine:executeClosure(...)
42854285 }
42864286 upvalueStack [index ] = upvalue
42874287 if index > maxUpvalue then
4288- maxUpvalue = index
4289- end
4288+ maxUpvalue = index
4289+ end
42904290 table.insert (tProtoUpvalues , upvalue )
42914291 elseif nextOpname == " GETUPVAL" then
42924292 local upvalue = upvalues [index + 1 ]
42934293 table.insert (tProtoUpvalues , upvalue )
42944294 else
42954295 error (
4296- " Unexpected instruction while capturing upvalues: "
4297- .. tostring (nextOpname )
4298- )
4296+ " Unexpected instruction while capturing upvalues: "
4297+ .. tostring (nextOpname )
4298+ )
42994299 end
43004300 end
43014301
43024302 local tClosure = {
4303- env = nil ,
4303+ env = nil ,
43044304 proto = tProto ,
43054305 upvalues = tProtoUpvalues ,
43064306 }
43074307
4308- stack [a ] = function (...)
4308+ stack [a ] = function (...)
43094309 self :pushClosure (tClosure )
43104310 local nReturns , returns = pack (self :executeClosure (... ))
43114311 self :pushClosure (closure )
@@ -4316,15 +4316,15 @@ end
43164316 -- OP_VARARG [A, B] R(A), R(A+1), ..., R(A+B-1) = vararg
43174317 -- Load vararg function arguments into registers.
43184318 elseif opname == " VARARG" then
4319- local upperBound = b - 1
4319+ local upperBound = b - 1
43204320 if b == USE_CURRENT_TOP then
43214321 top = a + varargLen
43224322 upperBound = top
4323- end
4324-
4325- for i = 1 , upperBound do
4326- stack [a + i - 1 ] = vararg [i ]
4327- end
4323+ end
4324+
4325+ for i = 1 , upperBound do
4326+ stack [a + i - 1 ] = vararg [i ]
4327+ end
43284328 else
43294329 error (" Unimplemented instruction: " .. tostring (opname ))
43304330 end
@@ -4337,7 +4337,7 @@ end
43374337function VirtualMachine :execute ()
43384338 -- Push main closure.
43394339 self :pushClosure ({
4340- env = _G ,
4340+ env = _G ,
43414341 proto = self .mainProto ,
43424342 upvalues = {},
43434343 })
0 commit comments