File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed
tests/capi/luaL_loadbuffer_proto Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -386,6 +386,13 @@ message BinaryOperator {
386
386
387
387
/* Arithmetic operators (5.3+). */
388
388
uint32 idiv = 16 ;
389
+
390
+ /* Bitwise operators (5.3+). */
391
+ uint32 band = 17 ;
392
+ uint32 bor = 18 ;
393
+ uint32 bxor = 19 ;
394
+ uint32 shl = 20 ;
395
+ uint32 shr = 21 ;
389
396
}
390
397
}
391
398
@@ -395,6 +402,9 @@ message UnaryOperator {
395
402
uint32 negate = 1 ;
396
403
uint32 not = 2 ;
397
404
uint32 length = 3 ;
405
+
406
+ /* Bitwise operators (5.3+). */
407
+ uint32 bnot = 4 ;
398
408
}
399
409
}
400
410
Original file line number Diff line number Diff line change @@ -76,6 +76,30 @@ local __idiv = load([[
76
76
local v1, v2 = ...
77
77
return always_number(v1) // always_number(v2)
78
78
]] )
79
+ local __band = load ([[
80
+ local v1, v2 = ...
81
+ return always_number(v1) & always_number(v2)
82
+ ]] )
83
+ local __bor = load ([[
84
+ local v1, v2 = ...
85
+ return always_number(v1) | always_number(v2)
86
+ ]] )
87
+ local __bxor = load ([[
88
+ local v1, v2 = ...
89
+ return always_number(v1) ~ always_number(v2)
90
+ ]] )
91
+ local __bnot = load ([[
92
+ local v = ...
93
+ return ~always_number(v)
94
+ ]] )
95
+ local __shl = load ([[
96
+ local v1, v2 = ...
97
+ return always_number(v1) << always_number(v2)
98
+ ]] )
99
+ local __shr = load ([[
100
+ local v1, v2 = ...
101
+ return always_number(v1) >> always_number(v2)
102
+ ]] )
79
103
80
104
debug.setmetatable (' string' , {
81
105
__add = __add ,
@@ -89,6 +113,12 @@ debug.setmetatable('string', {
89
113
__pow = __pow ,
90
114
__sub = __sub ,
91
115
__unm = __unm ,
116
+ __band = __band ,
117
+ __bor = __bor ,
118
+ __bxor = __bxor ,
119
+ __bnot = __bnot ,
120
+ __shl = __shl ,
121
+ __shr = __shr ,
92
122
})
93
123
debug.setmetatable (0 , {
94
124
__add = __add ,
Original file line number Diff line number Diff line change @@ -1185,6 +1185,19 @@ PROTO_TOSTRING(BinaryOperator, op)
1185
1185
return " and" ;
1186
1186
case BinopType::kOr :
1187
1187
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
1188
1201
default :
1189
1202
/* Works in most cases. */
1190
1203
return " ==" ;
@@ -1201,6 +1214,10 @@ PROTO_TOSTRING(UnaryOperator, op)
1201
1214
return " not " ;
1202
1215
case UnaryopType::kLength :
1203
1216
return " #" ;
1217
+ #if LUA_VERSION_NUM >= 503
1218
+ case UnaryopType::kBNot :
1219
+ return " ~" ;
1220
+ #endif
1204
1221
default :
1205
1222
/* Works in most cases. */
1206
1223
return " not " ;
You can’t perform that action at this time.
0 commit comments