MCPcopy
hub / github.com/gopherjs/gopherjs / Copy

Function Copy

compiler/natives/src/reflect/reflect.go:661–699  ·  view source on GitHub ↗

gopherjs:replace

(dst, src Value)

Source from the content-addressed store, hash-verified

659
660//gopherjs:replace
661func Copy(dst, src Value) int {
662 dk := dst.kind()
663 if dk != Array && dk != Slice {
664 panic(&ValueError{"reflect.Copy", dk})
665 }
666 if dk == Array {
667 dst.mustBeAssignable()
668 }
669 dst.mustBeExported()
670
671 sk := src.kind()
672 var stringCopy bool
673 if sk != Array && sk != Slice {
674 stringCopy = sk == String && dst.typ().Elem().Kind() == abi.Uint8
675 if !stringCopy {
676 panic(&ValueError{"reflect.Copy", sk})
677 }
678 }
679 src.mustBeExported()
680
681 if !stringCopy {
682 typesMustMatch("reflect.Copy", toRType(dst.typ().Elem()), toRType(src.typ().Elem()))
683 }
684
685 dstVal := dst.object()
686 if dk == Array {
687 dstVal = jsType(SliceOf(toRType(dst.typ().Elem()))).New(dstVal)
688 }
689
690 srcVal := src.object()
691 if sk == Array {
692 srcVal = jsType(SliceOf(toRType(src.typ().Elem()))).New(srcVal)
693 }
694
695 if stringCopy {
696 return js.Global.Call("$copyString", dstVal, srcVal).Int()
697 }
698 return js.Global.Call("$copySlice", dstVal, srcVal).Int()
699}
700
701//gopherjs:replace
702func methodReceiver(op string, v Value, methodIndex int) (rcvrtype *abi.Type, t *funcType, fn unsafe.Pointer) {

Callers

nothing calls this directly

Calls 10

toRTypeFunction · 0.85
SliceOfFunction · 0.85
typMethod · 0.80
jsTypeFunction · 0.70
KindMethod · 0.65
ElemMethod · 0.45
objectMethod · 0.45
NewMethod · 0.45
IntMethod · 0.45
CallMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…