@ -515,8 +515,11 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
}
}
if ( tm = = NULL ) /* no TM? */
if ( tm = = NULL ) /* no TM? */
return 0 ; /* objects are different */
return 0 ; /* objects are different */
luaT_callTMres ( L , tm , t1 , t2 , L - > top ) ; /* call TM */
else {
return ! l_isfalse ( s2v ( L - > top ) ) ;
L - > top = L - > ci - > top ;
luaT_callTMres ( L , tm , t1 , t2 , L - > top ) ; /* call TM */
return ! l_isfalse ( s2v ( L - > top ) ) ;
}
}
}
@ -548,7 +551,7 @@ void luaV_concat (lua_State *L, int total) {
int n = 2 ; /* number of elements handled in this pass (at least 2) */
int n = 2 ; /* number of elements handled in this pass (at least 2) */
if ( ! ( ttisstring ( s2v ( top - 2 ) ) | | cvt2str ( s2v ( top - 2 ) ) ) | |
if ( ! ( ttisstring ( s2v ( top - 2 ) ) | | cvt2str ( s2v ( top - 2 ) ) ) | |
! tostring ( L , s2v ( top - 1 ) ) )
! tostring ( L , s2v ( top - 1 ) ) )
luaT_trybinTM ( L , s2v ( top - 2 ) , s2v ( top - 1 ) , top - 2 , TM_CONCAT ) ;
luaT_tryconcatTM ( L ) ;
else if ( isemptystr ( s2v ( top - 1 ) ) ) /* second operand is empty? */
else if ( isemptystr ( s2v ( top - 1 ) ) ) /* second operand is empty? */
cast_void ( tostring ( L , s2v ( top - 2 ) ) ) ; /* result is first operand */
cast_void ( tostring ( L , s2v ( top - 2 ) ) ) ; /* result is first operand */
else if ( isemptystr ( s2v ( top - 2 ) ) ) { /* first operand is empty string? */
else if ( isemptystr ( s2v ( top - 2 ) ) ) { /* first operand is empty string? */
@ -747,7 +750,7 @@ void luaV_finishOp (lua_State *L) {
break ;
break ;
}
}
case OP_CONCAT : {
case OP_CONCAT : {
StkId top = L - > top - 1 ; /* top when 'luaT_trybin TM' was called */
StkId top = L - > top - 1 ; /* top when 'luaT_tryconcat TM' was called */
int a = GETARG_A ( inst ) ; /* first element to concatenate */
int a = GETARG_A ( inst ) ; /* first element to concatenate */
int total = cast_int ( top - 1 - ( base + a ) ) ; /* yet to concatenate */
int total = cast_int ( top - 1 - ( base + a ) ) ; /* yet to concatenate */
setobjs2s ( L , top - 2 , top ) ; /* put TM result in proper position */
setobjs2s ( L , top - 2 , top ) ; /* put TM result in proper position */
@ -801,7 +804,7 @@ void luaV_finishOp (lua_State *L) {
setfltvalue ( s2v ( ra ) , fop ( L , nb , fimm ) ) ; \
setfltvalue ( s2v ( ra ) , fop ( L , nb , fimm ) ) ; \
} \
} \
else \
else \
Protect ( luaT_trybiniTM ( L , v1 , imm , flip , ra , tm ) ) ; }
ProtectNT ( luaT_trybiniTM ( L , v1 , imm , flip , ra , tm ) ) ; }
/*
/*
@ -836,7 +839,7 @@ void luaV_finishOp (lua_State *L) {
setfltvalue ( s2v ( ra ) , fop ( L , n1 , n2 ) ) ; \
setfltvalue ( s2v ( ra ) , fop ( L , n1 , n2 ) ) ; \
} \
} \
else \
else \
Protect ( luaT_trybinTM ( L , v1 , v2 , ra , tm ) ) ; }
ProtectNT ( luaT_trybinTM ( L , v1 , v2 , ra , tm ) ) ; }
/*
/*
@ -877,7 +880,7 @@ void luaV_finishOp (lua_State *L) {
setfltvalue ( s2v ( ra ) , fop ( L , n1 , n2 ) ) ; \
setfltvalue ( s2v ( ra ) , fop ( L , n1 , n2 ) ) ; \
} \
} \
else \
else \
Protect ( luaT_trybinassocTM ( L , v1 , v2 , ra , flip , tm ) ) ; } }
ProtectNT ( luaT_trybinassocTM ( L , v1 , v2 , ra , flip , tm ) ) ; } }
/*
/*
@ -891,7 +894,7 @@ void luaV_finishOp (lua_State *L) {
setfltvalue ( s2v ( ra ) , fop ( L , n1 , n2 ) ) ; \
setfltvalue ( s2v ( ra ) , fop ( L , n1 , n2 ) ) ; \
} \
} \
else \
else \
Protect ( luaT_trybinTM ( L , v1 , v2 , ra , tm ) ) ; }
ProtectNT ( luaT_trybinTM ( L , v1 , v2 , ra , tm ) ) ; }
/*
/*
@ -906,7 +909,7 @@ void luaV_finishOp (lua_State *L) {
setivalue ( s2v ( ra ) , op ( L , i1 , i2 ) ) ; \
setivalue ( s2v ( ra ) , op ( L , i1 , i2 ) ) ; \
} \
} \
else \
else \
Protect ( luaT_trybiniTM ( L , v1 , i2 , TESTARG_k ( i ) , ra , tm ) ) ; }
ProtectNT ( luaT_trybiniTM ( L , v1 , i2 , TESTARG_k ( i ) , ra , tm ) ) ; }
/*
/*
@ -920,7 +923,7 @@ void luaV_finishOp (lua_State *L) {
setivalue ( s2v ( ra ) , op ( L , i1 , i2 ) ) ; \
setivalue ( s2v ( ra ) , op ( L , i1 , i2 ) ) ; \
} \
} \
else \
else \
Protect ( luaT_trybinTM ( L , v1 , v2 , ra , tm ) ) ; }
ProtectNT ( luaT_trybinTM ( L , v1 , v2 , ra , tm ) ) ; }
/*
/*
@ -937,7 +940,7 @@ void luaV_finishOp (lua_State *L) {
else if ( ttisnumber ( s2v ( ra ) ) & & ttisnumber ( rb ) ) \
else if ( ttisnumber ( s2v ( ra ) ) & & ttisnumber ( rb ) ) \
cond = opf ( s2v ( ra ) , rb ) ; \
cond = opf ( s2v ( ra ) , rb ) ; \
else \
else \
Protect ( cond = other ( L , s2v ( ra ) , rb ) ) ; \
ProtectNT ( cond = other ( L , s2v ( ra ) , rb ) ) ; \
docondjump ( ) ; }
docondjump ( ) ; }
@ -956,7 +959,7 @@ void luaV_finishOp (lua_State *L) {
} \
} \
else { \
else { \
int isf = GETARG_C ( i ) ; \
int isf = GETARG_C ( i ) ; \
Protect ( cond = luaT_callorderiTM ( L , s2v ( ra ) , im , inv , isf , tm ) ) ; \
ProtectNT ( cond = luaT_callorderiTM ( L , s2v ( ra ) , im , inv , isf , tm ) ) ; \
} \
} \
docondjump ( ) ; }
docondjump ( ) ; }
@ -1094,7 +1097,8 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
vmfetch ( ) ;
vmfetch ( ) ;
lua_assert ( base = = ci - > func + 1 ) ;
lua_assert ( base = = ci - > func + 1 ) ;
lua_assert ( base < = L - > top & & L - > top < L - > stack + L - > stacksize ) ;
lua_assert ( base < = L - > top & & L - > top < L - > stack + L - > stacksize ) ;
lua_assert ( ci - > top < L - > stack + L - > stacksize ) ;
/* invalidate top for instructions not expecting it */
lua_assert ( isIT ( i ) | | ( L - > top = base ) ) ;
vmdispatch ( GET_OPCODE ( i ) ) {
vmdispatch ( GET_OPCODE ( i ) ) {
vmcase ( OP_MOVE ) {
vmcase ( OP_MOVE ) {
setobjs2s ( L , ra , RB ( i ) ) ;
setobjs2s ( L , ra , RB ( i ) ) ;
@ -1359,7 +1363,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
if ( TESTARG_k ( i ) ) {
if ( TESTARG_k ( i ) ) {
ic = - ic ; ev = TM_SHL ;
ic = - ic ; ev = TM_SHL ;
}
}
Protect ( luaT_trybiniTM ( L , rb , ic , 0 , ra , ev ) ) ;
ProtectNT ( luaT_trybiniTM ( L , rb , ic , 0 , ra , ev ) ) ;
}
}
vmbreak ;
vmbreak ;
}
}
@ -1371,7 +1375,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
setivalue ( s2v ( ra ) , luaV_shiftl ( ic , ib ) ) ;
setivalue ( s2v ( ra ) , luaV_shiftl ( ic , ib ) ) ;
}
}
else
else
Protect ( luaT_trybiniTM ( L , rb , ic , 1 , ra , TM_SHL ) ) ;
ProtectNT ( luaT_trybiniTM ( L , rb , ic , 1 , ra , TM_SHL ) ) ;
vmbreak ;
vmbreak ;
}
}
vmcase ( OP_ADD ) {
vmcase ( OP_ADD ) {
@ -1422,7 +1426,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
setivalue ( s2v ( ra ) , luaV_shiftl ( ib , - ic ) ) ;
setivalue ( s2v ( ra ) , luaV_shiftl ( ib , - ic ) ) ;
}
}
else
else
Protect ( luaT_trybinTM ( L , rb , rc , ra , TM_SHR ) ) ;
ProtectNT ( luaT_trybinTM ( L , rb , rc , ra , TM_SHR ) ) ;
vmbreak ;
vmbreak ;
}
}
vmcase ( OP_SHL ) {
vmcase ( OP_SHL ) {
@ -1433,7 +1437,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
setivalue ( s2v ( ra ) , luaV_shiftl ( ib , ic ) ) ;
setivalue ( s2v ( ra ) , luaV_shiftl ( ib , ic ) ) ;
}
}
else
else
Protect ( luaT_trybinTM ( L , rb , rc , ra , TM_SHL ) ) ;
ProtectNT ( luaT_trybinTM ( L , rb , rc , ra , TM_SHL ) ) ;
vmbreak ;
vmbreak ;
}
}
vmcase ( OP_UNM ) {
vmcase ( OP_UNM ) {
@ -1447,7 +1451,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
setfltvalue ( s2v ( ra ) , luai_numunm ( L , nb ) ) ;
setfltvalue ( s2v ( ra ) , luai_numunm ( L , nb ) ) ;
}
}
else
else
Protect ( luaT_trybinTM ( L , rb , rb , ra , TM_UNM ) ) ;
ProtectNT ( luaT_trybinTM ( L , rb , rb , ra , TM_UNM ) ) ;
vmbreak ;
vmbreak ;
}
}
vmcase ( OP_BNOT ) {
vmcase ( OP_BNOT ) {
@ -1457,7 +1461,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
setivalue ( s2v ( ra ) , intop ( ^ , ~ l_castS2U ( 0 ) , ib ) ) ;
setivalue ( s2v ( ra ) , intop ( ^ , ~ l_castS2U ( 0 ) , ib ) ) ;
}
}
else
else
Protect ( luaT_trybinTM ( L , rb , rb , ra , TM_BNOT ) ) ;
ProtectNT ( luaT_trybinTM ( L , rb , rb , ra , TM_BNOT ) ) ;
vmbreak ;
vmbreak ;
}
}
vmcase ( OP_NOT ) {
vmcase ( OP_NOT ) {
@ -1493,7 +1497,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
vmcase ( OP_EQ ) {
vmcase ( OP_EQ ) {
int cond ;
int cond ;
TValue * rb = vRB ( i ) ;
TValue * rb = vRB ( i ) ;
Protect ( cond = luaV_equalobj ( L , s2v ( ra ) , rb ) ) ;
ProtectNT ( cond = luaV_equalobj ( L , s2v ( ra ) , rb ) ) ;
docondjump ( ) ;
docondjump ( ) ;
vmbreak ;
vmbreak ;
}
}