Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

error case #12

Open
Nymphium opened this issue Mar 14, 2017 · 0 comments
Open

error case #12

Nymphium opened this issue Mar 14, 2017 · 0 comments

Comments

@Nymphium
Copy link
Owner

local f = function(a)
    return a + a
end

local g = function(b)
    return (f(b)) * (f(b))
end

local h = function(c)
    return g(c)
end

print(h(3))

Opeth returns the bytecode like :

main <?:0,0> (8 instructions at 0x1da19e0)
0+ params, 6 slots, 1 upvalue, 0 locals, 2 constants, 2 functions
        1       [-]     CLOSURE         0 0     ; 0x1da1b00
        2       [-]     CLOSURE         2 1     ; 0x1da1ba0
        3       [-]     GETTABUP        3 0 -1  ; - "print"
        4       [-]     MOVE            4 2
        5       [-]     LOADK           5 -2    ; 3
        6       [-]     CALL            4 2 0
        7       [-]     CALL            3 0 1
        8       [-]     RETURN          0 1
constants (2) for 0x1da19e0:
        1       "print"
        2       3
locals (0) for 0x1da19e0:
upvalues (1) for 0x1da19e0:
        0       -       1       0

function <?:1,3> (3 instructions at 0x1da1b00)
1 param, 2 slots, 0 upvalues, 0 locals, 0 constants, 0 functions
        1       [-]     ADD             1 0 0
        2       [-]     RETURN          1 2
        3       [-]     RETURN          0 1
constants (0) for 0x1da1b00:
locals (0) for 0x1da1b00:
upvalues (0) for 0x1da1b00:

function <?:9,11> (5 instructions at 0x1da1ba0)
1 param, 3 slots, 1 upvalue, 0 locals, 0 constants, 0 functions
        1       [-]     GETUPVAL        1 0     ; -
        2       [-]     MOVE            2 0
        3       [-]     TAILCALL        1 2 0
        4       [-]     RETURN          1 0
        5       [-]     RETURN          0 1
constants (0) for 0x1da1ba0:
locals (0) for 0x1da1ba0:
upvalues (1) for 0x1da1ba0:
        0       -       1       0

And get a result 6

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant