diff options
Diffstat (limited to 'ltm.c')
-rw-r--r-- | ltm.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 2.47 2017/11/07 13:25:26 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 2.48 2017/11/08 14:50:23 roberto Exp $ |
3 | ** Tag methods | 3 | ** Tag methods |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -180,10 +180,19 @@ void luaT_trybiniTM (lua_State *L, const TValue *p1, int i2, | |||
180 | 180 | ||
181 | int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, | 181 | int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, |
182 | TMS event) { | 182 | TMS event) { |
183 | if (!callbinTM(L, p1, p2, L->top, event)) | 183 | if (callbinTM(L, p1, p2, L->top, event)) /* try original event */ |
184 | return -1; /* no metamethod */ | ||
185 | else | ||
186 | return !l_isfalse(s2v(L->top)); | 184 | return !l_isfalse(s2v(L->top)); |
185 | else if (event == TM_LE) { | ||
186 | /* try '!(p2 < p1)' for '(p1 <= p2)' */ | ||
187 | L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ | ||
188 | if (callbinTM(L, p2, p1, L->top, TM_LT)) { | ||
189 | L->ci->callstatus ^= CIST_LEQ; /* clear mark */ | ||
190 | return l_isfalse(s2v(L->top)); | ||
191 | } | ||
192 | /* else error will remove this 'ci'; no need to clear mark */ | ||
193 | } | ||
194 | luaG_ordererror(L, p1, p2); /* no metamethod found */ | ||
195 | return 0; /* to avoid warnings */ | ||
187 | } | 196 | } |
188 | 197 | ||
189 | 198 | ||