MCPcopy
hub / github.com/yuin/gopher-lua / ToStringMeta

Method ToStringMeta

auxlib.go:420–429  ·  view source on GitHub ↗

* }}} */ * GopherLua original APIs {{{ */ ToStringMeta returns string representation of given LValue. This method calls the `__tostring` meta method if defined.

(lv LValue)

Source from the content-addressed store, hash-verified

418// ToStringMeta returns string representation of given LValue.
419// This method calls the `__tostring` meta method if defined.
420func (ls *LState) ToStringMeta(lv LValue) LValue {
421 if fn, ok := ls.metaOp1(lv, "__tostring").(*LFunction); ok {
422 ls.Push(fn)
423 ls.Push(lv)
424 ls.Call(1, 1)
425 return ls.reg.Pop()
426 } else {
427 return LString(lv.String())
428 }
429}
430
431// Set a module loader to the package.preload table.
432func (ls *LState) PreloadModule(name string, loader LGFunction) {

Callers 2

basePrintFunction · 0.80
baseToStringFunction · 0.80

Calls 6

metaOp1Method · 0.95
PushMethod · 0.95
CallMethod · 0.95
LStringTypeAlias · 0.85
PopMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected