[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bytecode hacks
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 22 May 2014 00:27:16 -0300
> I think there are patchs around for the t:[var]() syntax.
Actually, this one seems simple. A quick hack is to just change
suffixedexp in lparser.c (from Lua 5.2.3):
case ':': { /* `:' NAME funcargs */
expdesc key;
luaX_next(ls);
- checkname(ls, &key);
+ if (ls->t.token=='[') {
+ luaK_exp2anyregup(fs, v);
+ yindex(ls, &key);
+ }
+ else
+ checkname(ls, &key);
luaK_self(fs, v, &key);
funcargs(ls, v, line);
break;
I tested it only on this program. It works in some cases but not in others :-(
local t={}
t.f=print
t.ff=print
local v="f"
t:f(1)
t:[v](2)
t:[string.char(string.byte("f"))](3,32,33)
t:["f".."f"](4)
t:["f"..string.sub("afun",2,2)](5,52,53)
t:[(string.sub("afun",2,2))](6,62,63)
table: 0x107e04e40 1
table: 0x107e04e40 2
3 32 33
table: 0x107e04e40 4
table: 0x107e04e40 5 52 53
6 62 63
It's been some time since I last hacked the parser and I must have
overlooked something. Happy hacking.