| 175 | |
| 176 | |
| 177 | static int b_replace (lua_State *L) { |
| 178 | int w; |
| 179 | b_uint r = luaL_checkunsigned(L, 1); |
| 180 | b_uint v = luaL_checkunsigned(L, 2); |
| 181 | int f = fieldargs(L, 3, &w); |
| 182 | int m = mask(w); |
| 183 | v &= m; /* erase bits outside given width */ |
| 184 | r = (r & ~(m << f)) | (v << f); |
| 185 | lua_pushunsigned(L, r); |
| 186 | return 1; |
| 187 | } |
| 188 | |
| 189 | |
| 190 | static const luaL_Reg bitlib[] = { |
nothing calls this directly
no test coverage detected