diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-04-25 13:07:52 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-04-25 13:07:52 -0300 |
| commit | 9600c60df3e5a971ca642734470901775ef67ff9 (patch) | |
| tree | e53e526676be089fde966143599f22c4a5e862fb /ltm.c | |
| parent | 32bf6c9b277d04a35591ca6420cf1518ebc1a7f3 (diff) | |
| download | lua-9600c60df3e5a971ca642734470901775ef67ff9.tar.gz lua-9600c60df3e5a971ca642734470901775ef67ff9.tar.bz2 lua-9600c60df3e5a971ca642734470901775ef67ff9.zip | |
functions 'get_equalTM' and 'call_orderTM' moved to other files
to make 'lvm.c' smaller
Diffstat (limited to 'ltm.c')
| -rw-r--r-- | ltm.c | 25 |
1 files changed, 24 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.c,v 2.15 2013/04/12 19:07:09 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 2.16 2013/04/25 15:59:42 roberto Exp roberto $ |
| 3 | ** Tag methods | 3 | ** Tag methods |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -18,6 +18,7 @@ | |||
| 18 | #include "lstring.h" | 18 | #include "lstring.h" |
| 19 | #include "ltable.h" | 19 | #include "ltable.h" |
| 20 | #include "ltm.h" | 20 | #include "ltm.h" |
| 21 | #include "lvm.h" | ||
| 21 | 22 | ||
| 22 | 23 | ||
| 23 | static const char udatatypename[] = "userdata"; | 24 | static const char udatatypename[] = "userdata"; |
| @@ -104,3 +105,25 @@ int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, | |||
| 104 | return 1; | 105 | return 1; |
| 105 | } | 106 | } |
| 106 | 107 | ||
| 108 | |||
| 109 | const TValue *luaT_getequalTM (lua_State *L, Table *mt1, Table *mt2) { | ||
| 110 | const TValue *tm1 = fasttm(L, mt1, TM_EQ); | ||
| 111 | const TValue *tm2; | ||
| 112 | if (tm1 == NULL) return NULL; /* no metamethod */ | ||
| 113 | if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ | ||
| 114 | tm2 = fasttm(L, mt2, TM_EQ); | ||
| 115 | if (tm2 == NULL) return NULL; /* no metamethod */ | ||
| 116 | if (luaV_rawequalobj(tm1, tm2)) /* same metamethods? */ | ||
| 117 | return tm1; | ||
| 118 | return NULL; | ||
| 119 | } | ||
| 120 | |||
| 121 | |||
| 122 | int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, | ||
| 123 | TMS event) { | ||
| 124 | if (!luaT_callbinTM(L, p1, p2, L->top, event)) | ||
| 125 | return -1; /* no metamethod */ | ||
| 126 | else | ||
| 127 | return !l_isfalse(L->top); | ||
| 128 | } | ||
| 129 | |||
