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

Function stringConcat

vm.go:2346–2381  ·  view source on GitHub ↗
(L *LState, total, last int)

Source from the content-addressed store, hash-verified

2344}
2345
2346func stringConcat(L *LState, total, last int) LValue {
2347 rhs := L.reg.Get(last)
2348 total--
2349 for i := last - 1; total > 0; {
2350 lhs := L.reg.Get(i)
2351 if !(LVCanConvToString(lhs) && LVCanConvToString(rhs)) {
2352 op := L.metaOp2(lhs, rhs, "__concat")
2353 if op.Type() == LTFunction {
2354 L.reg.Push(op)
2355 L.reg.Push(lhs)
2356 L.reg.Push(rhs)
2357 L.Call(2, 1)
2358 rhs = L.reg.Pop()
2359 total--
2360 i--
2361 } else {
2362 L.RaiseError("cannot perform concat operation between %v and %v", lhs.Type().String(), rhs.Type().String())
2363 return LNil
2364 }
2365 } else {
2366 buf := make([]string, total+1)
2367 buf[total] = LVAsString(rhs)
2368 for total > 0 {
2369 lhs = L.reg.Get(i)
2370 if !LVCanConvToString(lhs) {
2371 break
2372 }
2373 buf[total-1] = LVAsString(lhs)
2374 i--
2375 total--
2376 }
2377 rhs = LString(strings.Join(buf, ""))
2378 }
2379 }
2380 return rhs
2381}
2382
2383func lessThan(L *LState, lhs, rhs LValue) bool {
2384 // optimization for numbers

Callers 4

initFunction · 0.70
tableConcatFunction · 0.70
ConcatMethod · 0.70
ConcatMethod · 0.70

Calls 11

LVCanConvToStringFunction · 0.85
LVAsStringFunction · 0.85
LStringTypeAlias · 0.85
TypeMethod · 0.65
PushMethod · 0.65
PopMethod · 0.65
StringMethod · 0.65
GetMethod · 0.45
metaOp2Method · 0.45
CallMethod · 0.45
RaiseErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…