MCPcopy Index your code
hub / github.com/yuin/gopher-lua / opToString

Function opToString

opcode.go:261–371  ·  view source on GitHub ↗
(inst uint32)

Source from the content-addressed store, hash-verified

259}
260
261func opToString(inst uint32) string {
262 op := opGetOpCode(inst)
263 if op > opCodeMax {
264 return ""
265 }
266 prop := &(opProps[op])
267
268 arga := opGetArgA(inst)
269 argb := opGetArgB(inst)
270 argc := opGetArgC(inst)
271 argbx := opGetArgBx(inst)
272 argsbx := opGetArgSbx(inst)
273
274 buf := ""
275 switch prop.Type {
276 case opTypeABC:
277 buf = fmt.Sprintf("%s | %d, %d, %d", prop.Name, arga, argb, argc)
278 case opTypeABx:
279 buf = fmt.Sprintf("%s | %d, %d", prop.Name, arga, argbx)
280 case opTypeASbx:
281 buf = fmt.Sprintf("%s | %d, %d", prop.Name, arga, argsbx)
282 }
283
284 switch op {
285 case OP_MOVE:
286 buf += fmt.Sprintf("; R(%v) := R(%v)", arga, argb)
287 case OP_MOVEN:
288 buf += fmt.Sprintf("; R(%v) := R(%v); followed by %v MOVE ops", arga, argb, argc)
289 case OP_LOADK:
290 buf += fmt.Sprintf("; R(%v) := Kst(%v)", arga, argbx)
291 case OP_LOADBOOL:
292 buf += fmt.Sprintf("; R(%v) := (Bool)%v; if (%v) pc++", arga, argb, argc)
293 case OP_LOADNIL:
294 buf += fmt.Sprintf("; R(%v) := ... := R(%v) := nil", arga, argb)
295 case OP_GETUPVAL:
296 buf += fmt.Sprintf("; R(%v) := UpValue[%v]", arga, argb)
297 case OP_GETGLOBAL:
298 buf += fmt.Sprintf("; R(%v) := Gbl[Kst(%v)]", arga, argbx)
299 case OP_GETTABLE:
300 buf += fmt.Sprintf("; R(%v) := R(%v)[RK(%v)]", arga, argb, argc)
301 case OP_GETTABLEKS:
302 buf += fmt.Sprintf("; R(%v) := R(%v)[RK(%v)] ; RK(%v) is constant string", arga, argb, argc, argc)
303 case OP_SETGLOBAL:
304 buf += fmt.Sprintf("; Gbl[Kst(%v)] := R(%v)", argbx, arga)
305 case OP_SETUPVAL:
306 buf += fmt.Sprintf("; UpValue[%v] := R(%v)", argb, arga)
307 case OP_SETTABLE:
308 buf += fmt.Sprintf("; R(%v)[RK(%v)] := RK(%v)", arga, argb, argc)
309 case OP_SETTABLEKS:
310 buf += fmt.Sprintf("; R(%v)[RK(%v)] := RK(%v) ; RK(%v) is constant string", arga, argb, argc, argb)
311 case OP_NEWTABLE:
312 buf += fmt.Sprintf("; R(%v) := {} (size = BC)", arga)
313 case OP_SELF:
314 buf += fmt.Sprintf("; R(%v+1) := R(%v); R(%v) := R(%v)[RK(%v)]", arga, argb, arga, argb, argc)
315 case OP_ADD:
316 buf += fmt.Sprintf("; R(%v) := RK(%v) + RK(%v)", arga, argb, argc)
317 case OP_SUB:
318 buf += fmt.Sprintf("; R(%v) := RK(%v) - RK(%v)", arga, argb, argc)

Callers 1

strMethod · 0.85

Calls 6

opGetOpCodeFunction · 0.85
opGetArgAFunction · 0.85
opGetArgBFunction · 0.85
opGetArgCFunction · 0.85
opGetArgBxFunction · 0.85
opGetArgSbxFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…