[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (rc4) now available
- From: Tim Hill <drtimhill@...>
- Date: Tue, 13 Jan 2015 11:03:27 -0800
> On Jan 13, 2015, at 12:15 AM, Paige DePol <lual@serfnet.org> wrote:
>
> Tim Hill <drtimhill@gmail.com> wrote:
>> However, as Lua does little (if any) constant folding at compile time, this will be more expensive than the equivalent hex/decimal literal.
>>
>> —Tim
>
> Lua does constant folding... grep the codebase for 'folding'!
>
> "a = 1 << 5"
>
> Compiles to:
>
> main <ackoop:0,0> (2 instructions at 0x7f8db8405270)
> 0+ params, 2 slots, 1 upvalue, 0 locals, 2 constants, 0 functions
> 1 [2] SETTABUP 0 -1 -2 ; _ENV "a" 32
> 2 [2] RETURN 0 1
> constants (2) for 0x7f8db8405270:
> 1 "a"
> 2 32
> locals (0) for 0x7f8db8405270:
> upvalues (1) for 0x7f8db8405270:
> 0 _ENV 1 0
>
> Looks like it folded "1 << 5" to "32" correctly! :)
>
> ~pmd
>
>
I stand corrected, thank you.
—Tim