File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
tests/capi/luaL_loadbuffer_proto Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -383,6 +383,9 @@ message BinaryOperator {
383383 uint32 notEqual = 13 ;
384384 uint32 and = 14 ;
385385 uint32 or = 15 ;
386+
387+ /* Arithmetic operators (5.3+). */
388+ uint32 idiv = 16 ;
386389 }
387390}
388391
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ local not_nan_and_nil = function(val)
88 return (val ~= val or val == nil ) and DEFAULT_NUMBER or val
99end
1010
11+ _G .always_number = always_number
12+
1113local __add = function (v1 , v2 )
1214 return always_number (v1 ) + always_number (v2 )
1315end
7072local __unm = function (v )
7173 return - always_number (v )
7274end
75+ local __idiv = load ([[
76+ local v1, v2 = ...
77+ return always_number(v1) // always_number(v2)
78+ ]] )
7379
7480debug.setmetatable (' string' , {
7581 __add = __add ,
7682 __call = __call ,
7783 __div = __div ,
84+ __idiv = __idiv ,
7885 __index = __index ,
7986 __mod = __mod ,
8087 __mul = __mul ,
@@ -88,6 +95,7 @@ debug.setmetatable(0, {
8895 __call = __call ,
8996 __concat = __concat ,
9097 __div = __div ,
98+ __idiv = __idiv ,
9199 __index = __index ,
92100 __len = __len ,
93101 __newindex = __newindex ,
@@ -97,6 +105,7 @@ debug.setmetatable(nil, {
97105 __call = __call ,
98106 __concat = __concat ,
99107 __div = __div ,
108+ __idiv = __idiv ,
100109 __index = __index ,
101110 __le = __le ,
102111 __len = __len ,
@@ -112,6 +121,7 @@ debug.setmetatable(function() end, {
112121 __add = __add ,
113122 __concat = __concat ,
114123 __div = __div ,
124+ __idiv = __idiv ,
115125 __index = __index ,
116126 __le = __le ,
117127 __len = __len ,
@@ -128,6 +138,7 @@ debug.setmetatable(true, {
128138 __call = __call ,
129139 __concat = __concat ,
130140 __div = __div ,
141+ __idiv = __idiv ,
131142 __index = __index ,
132143 __le = __le ,
133144 __len = __len ,
@@ -144,6 +155,7 @@ local table_mt = {
144155 __call = __call ,
145156 __concat = __concat ,
146157 __div = __div ,
158+ __idiv = __idiv ,
147159 __le = __le ,
148160 __len = __len ,
149161 __lt = __lt ,
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 :
You can’t perform that action at this time.
0 commit comments