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

Function stringConcat

_vm.go:930–965  ·  view source on GitHub ↗
(L *LState, total, last int)

Source from the content-addressed store, hash-verified

928}
929
930func stringConcat(L *LState, total, last int) LValue {
931 rhs := L.reg.Get(last)
932 total--
933 for i := last - 1; total > 0; {
934 lhs := L.reg.Get(i)
935 if !(LVCanConvToString(lhs) && LVCanConvToString(rhs)) {
936 op := L.metaOp2(lhs, rhs, "__concat")
937 if op.Type() == LTFunction {
938 L.reg.Push(op)
939 L.reg.Push(lhs)
940 L.reg.Push(rhs)
941 L.Call(2, 1)
942 rhs = L.reg.Pop()
943 total--
944 i--
945 } else {
946 L.RaiseError("cannot perform concat operation between %v and %v", lhs.Type().String(), rhs.Type().String())
947 return LNil
948 }
949 } else {
950 buf := make([]string, total+1)
951 buf[total] = LVAsString(rhs)
952 for total > 0 {
953 lhs = L.reg.Get(i)
954 if !LVCanConvToString(lhs) {
955 break
956 }
957 buf[total-1] = LVAsString(lhs)
958 i--
959 total--
960 }
961 rhs = LString(strings.Join(buf, ""))
962 }
963 }
964 return rhs
965}
966
967func lessThan(L *LState, lhs, rhs LValue) bool {
968 // optimization for numbers

Callers 1

initFunction · 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…