File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed
tests/capi/luaL_loadbuffer_proto Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -383,6 +383,17 @@ message BinaryOperator {
383383 uint32 notEqual = 13 ;
384384 uint32 and = 14 ;
385385 uint32 or = 15 ;
386+
387+ /* Arithmetic operators (5.3+). */
388+ uint32 idiv = 16 ;
389+
390+ /* Bitwise operators (5.3+). */
391+ uint32 bor = 17 ;
392+ uint32 band = 18 ;
393+ uint32 bxor = 19 ;
394+ uint32 bnot = 20 ;
395+ uint32 shl = 21 ;
396+ uint32 shr = 22 ;
386397 }
387398}
388399
@@ -392,6 +403,9 @@ message UnaryOperator {
392403 uint32 negate = 1 ;
393404 uint32 not = 2 ;
394405 uint32 length = 3 ;
406+
407+ /* Bitwise operators (5.3+). */
408+ uint32 bnot = 4 ;
395409 }
396410}
397411
Original file line number Diff line number Diff line change 7070local __unm = function (v )
7171 return - always_number (v )
7272end
73+ local __idiv = function (v1 , v2 )
74+ return always_number (v1 ) // always_number (v2 )
75+ end
76+ local __band = function (v1 , v2 )
77+ return always_number (v1 ) & always_number (v2 )
78+ end
79+ local __bor = function (v1 , v2 )
80+ return always_number (v1 ) | always_number (v2 )
81+ end
82+ local __bxor = function (v1 , v2 )
83+ return always_number (v1 ) ~ always_number (v2 )
84+ end
85+ local __bnot = function (v )
86+ return ~always_number (v )
87+ end
88+ local __shl = function (v1 , v2 )
89+ return always_number (v1 ) << always_number (v2 )
90+ end
91+ local __shr = function (v1 , v2 )
92+ return always_number (v1 ) >> always_number (v2 )
93+ end
7394
7495debug.setmetatable (' string' , {
7596 __add = __add ,
@@ -82,6 +103,13 @@ debug.setmetatable('string', {
82103 __pow = __pow ,
83104 __sub = __sub ,
84105 __unm = __unm ,
106+ __idiv = __idiv ,
107+ __band = __band ,
108+ __bor = __bor ,
109+ __bxor = __bxor ,
110+ __bnot = __bnot ,
111+ __shl = __shl ,
112+ __shr = __shr ,
85113})
86114debug.setmetatable (0 , {
87115 __add = __add ,
Original file line number Diff line number Diff line change @@ -1157,6 +1157,10 @@ PROTO_TOSTRING(BinaryOperator, op)
11571157 return " *" ;
11581158 case BinopType::kDiv :
11591159 return " /" ;
1160+ #if LUA_VERSION_NUM >= 503
1161+ case BinopType::kIDiv :
1162+ return " //" ;
1163+ #endif
11601164 case BinopType::kExp :
11611165 return " ^" ;
11621166 case BinopType::kMod :
@@ -1181,6 +1185,19 @@ PROTO_TOSTRING(BinaryOperator, op)
11811185 return " and" ;
11821186 case BinopType::kOr :
11831187 return " or" ;
1188+
1189+ #if LUA_VERSION_NUM >= 503
1190+ case BinopType::kBAnd :
1191+ return " &" ;
1192+ case BinopType::kBOr :
1193+ return " |" ;
1194+ case BinopType::kBXor :
1195+ return " ~" ;
1196+ case BinopType::kBShl :
1197+ return " <<" ;
1198+ case BinopType::kBShr :
1199+ return " >>" ;
1200+ #endif
11841201 default :
11851202 /* Works in most cases. */
11861203 return " ==" ;
@@ -1197,6 +1214,10 @@ PROTO_TOSTRING(UnaryOperator, op)
11971214 return " not " ;
11981215 case UnaryopType::kLength :
11991216 return " #" ;
1217+ #if LUA_VERSION_NUM >= 503
1218+ case UnaryopType::kBNot :
1219+ return " ~" ;
1220+ #endif
12001221 default :
12011222 /* Works in most cases. */
12021223 return " not " ;
You can’t perform that action at this time.
0 commit comments