示例#1
0
// makeMethodValue converts v from the rcvr+method index representation
// of a method value to an actual method func value, which is
// basically the receiver value with a special bit set, into a true
// func value - a value holding an actual func. The output is
// semantically equivalent to the input as far as the user of package
// reflect can tell, but the true func representation can be handled
// by code like Convert and Interface and Assign.
func makeMethodValue(op string, v Value) Value {
	if v.flag&flagMethod == 0 {
		panic("reflect: internal error: invalid use of makeMethodValue")
	}

	// Ignoring the flagMethod bit, v describes the receiver, not the method type.
	fl := v.flag & (flagRO | flagAddr | flagIndir)
	fl |= flag(v.typ.Kind())
	rcvr := Value{v.typ, v.ptr, fl}

	// v.Type returns the actual type of the method value.
	funcType := v.Type().(*rtype)

	// Indirect Go func value (dummy) to obtain
	// actual code address. (A Go func value is a pointer
	// to a C function pointer. http://golang.org/s/go11func.)
	//dummy := methodValueCall
	//code := **(**uintptr)(unsafe.Pointer(&dummy))
	code := hx.GetDynamic("", "new Closure(Go_reflect_methodVValueCCall.call,[])")

	// methodValue contains a stack map for use by the runtime
	_, _, _, stack := funcLayout(funcType, nil)

	fv := &methodValue{
		fn:     code,
		stack:  stack,
		method: int(v.flag) >> flagMethodShift,
		rcvr:   rcvr,
	}

	// Cause panic if method is not appropriate.
	// The panic would still happen during the call if we omit this,
	// but we want Interface() and other operations to fail early.
	methodReceiver(op, fv.rcvr, fv.method)

	return Value{funcType, unsafe.Pointer(fv), v.flag&flagRO | flag(Func)}
}
示例#2
0
	fs.dirlink(ip, ".", ip)
	fs.dirlink(ip, "..", ip)
	fs.cwd = ip
	fs.root = ip
	return fs
}

var fs = newFsys()

var doHaxeInit = true // no need for mutex as haxe is not multi-threaded
var fsinit = func() {
	// Haxe specific
	if doHaxeInit {
		log := "syscall.fsinit() called\n"
		doHaxeInit = false
		names := hx.GetDynamic("", "haxe.Resource.listNames()")
		l := hx.FgetInt("", names, "", "length")
		for n := 0; n < l; n++ {
			nam := hx.MethString("", names, "", "shift", 0)

			if len(nam) == 0 || nam[0] != '/' {
				log += "syscall.fsinit() file ignored, no leading '/' : " + nam + "\n"
			} else {
				bits := []int{}
				for i, c := range nam {
					if c == '/' {
						bits = append(bits, i)
					}
				}
				if len(bits) > 1 {
					for l := 1; l < len(bits); l++ {