lualua-5.1

Why ChunkSpy .function part has four parameters?


When using ChunkSpy, I find one thing makes me coufused. Let's see the following example

>a = 1
; source chunk: (interactive mode)
; x86 standard (32-bit, little endian, doubles)

; function [0] definition (level 1)
; 0 upvalues, 0 params, 2 stacks
.function  0 0 2 2
.const  "a"  ; 0
.const  1  ; 1
[1] loadk      0   1        ; 1
[2] setglobal  0   0        ; a
[3] return     0   1
; end of function

Since here is 0 upvalues, 0 params, 2 stacks, why there are four parameters in .function 0 0 2 2

In another example, we can see that

>local a; function b() a = 1 return a end
; source chunk: (interactive mode)
; x86 standard (32-bit, little endian, doubles)

; function [0] definition (level 1)
; 0 upvalues, 0 params, 2 stacks
.function  0 0 2 2
.local  "a"  ; 0
.const  "b"  ; 0

; function [0] definition (level 2)
; 1 upvalues, 0 params, 2 stacks
.function  1 0 0 2
.upvalue  "a"  ; 0
.const  1  ; 0
[1] loadk      0   0        ; 1
[2] setupval   0   0        ; a
[3] getupval   0   0        ; a
[4] return     0   2
[5] return     0   1
; end of function

[1] closure    1   0        ; 1 upvalues
[2] move       0   0
[3] setglobal  1   0        ; b
[4] return     0   1
; end of function

So I guess the first parameter is upvalues, but what is the use of the second?


Solution

  • I get the answer by the help of Egor Skriptunoff from comments.

    The .fucntion part with four parameters are meaning like below: