package _syscall
import (
	πg "grumpy"
	π_reflect "reflect"
	π_syscall "syscall"
)
func initModule(πF *πg.Frame, _ []*πg.Object) (*πg.Object, *πg.BaseException) {
	ßEINTR := πg.InternStr("EINTR")
	ßError := πg.InternStr("Error")
	ßOSError := πg.InternStr("OSError")
	ßTrue := πg.InternStr("True")
	ßinvoke := πg.InternStr("invoke")
	ßisinstance := πg.InternStr("isinstance")
	ßtuple := πg.InternStr("tuple")
	var πTemp001 *πg.Object
	_ = πTemp001
	var πTemp002 map[string]*πg.Object
	_ = πTemp002
	var πTemp003 *πg.Object
	_ = πTemp003
	var πTemp004 []πg.Param
	_ = πTemp004
	var πE *πg.BaseException; _ = πE
	for ; πF.State() >= 0; πF.PopCheckpoint() {
		switch πF.State() {
		case 0:
		default: panic("unexpected function state")
		}
		// line 15: from __go__.syscall import EINTR
		πF.SetLineno(15)
		πTemp002 = map[string]*πg.Object{}
		if πTemp003, πE = πg.WrapNative(πF, π_reflect.ValueOf(π_syscall.EINTR)); πE != nil {
			continue
		}
		πTemp002["EINTR"] = πTemp003
		if πTemp001, πE = πg.ImportNativeModule(πF, "syscall", πTemp002); πE != nil {
			continue
		}
		if πTemp003, πE = πg.GetAttr(πF, πTemp001, ßEINTR, nil); πE != nil {
			continue
		}
		if πE = πF.Globals().SetItem(πF, ßEINTR.ToObject(), πTemp003); πE != nil {
			continue
		}
		// line 18: def invoke(func, *args):
		πF.SetLineno(18)
		πTemp004 = make([]πg.Param, 1)
		πTemp004[0] = πg.Param{Name: "func", Def: nil}
		πTemp001 = πg.NewFunction(πg.NewCode("invoke", "build/src/__python__/_syscall.py", πTemp004, πg.CodeFlagVarArg, func(πF *πg.Frame, πArgs []*πg.Object) (*πg.Object, *πg.BaseException) {
			var µfunc *πg.Object = πArgs[0]; _ = µfunc
			var µargs *πg.Object = πArgs[1]; _ = µargs
			var µresult *πg.Object = πg.UnboundLocal; _ = µresult
			var µerr *πg.Object = πg.UnboundLocal; _ = µerr
			var πTemp001 *πg.Object
			_ = πTemp001
			var πTemp002 bool
			_ = πTemp002
			var πTemp003 *πg.Object
			_ = πTemp003
			var πTemp004 []*πg.Object
			_ = πTemp004
			var πTemp005 *πg.Object
			_ = πTemp005
			var πTemp006 bool
			_ = πTemp006
			var πE *πg.BaseException; _ = πE
			for ; πF.State() >= 0; πF.PopCheckpoint() {
				switch πF.State() {
				case 0:
				default: panic("unexpected function state")
				}
				// line 19: while True:
				πF.SetLineno(19)
			Label1:
				if πTemp001, πE = πg.ResolveGlobal(πF, ßTrue); πE != nil {
					continue
				}
				if πTemp002, πE = πg.IsTrue(πF, πTemp001); πE != nil {
					continue
				}
				if !πTemp002 {
					goto Label2
				}
				// line 20: result = func(*args)
				πF.SetLineno(20)
				if πE = πg.CheckLocal(πF, µargs, "args"); πE != nil {
					continue
				}
				if πE = πg.CheckLocal(πF, µfunc, "func"); πE != nil {
					continue
				}
				if πTemp003, πE = πg.Invoke(πF, µfunc, nil, µargs, nil, nil); πE != nil {
					continue
				}
				µresult = πTemp003
				πTemp004 = πF.MakeArgs(2)
				if πE = πg.CheckLocal(πF, µresult, "result"); πE != nil {
					continue
				}
				πTemp004[0] = µresult
				if πTemp003, πE = πg.ResolveGlobal(πF, ßtuple); πE != nil {
					continue
				}
				πTemp004[1] = πTemp003
				if πTemp003, πE = πg.ResolveGlobal(πF, ßisinstance); πE != nil {
					continue
				}
				if πTemp005, πE = πTemp003.Call(πF, πTemp004, nil); πE != nil {
					continue
				}
				πF.FreeArgs(πTemp004)
				if πTemp006, πE = πg.IsTrue(πF, πTemp005); πE != nil {
					continue
				}
				if πTemp006 {
					goto Label3
				}
				goto Label4
				// line 21: if isinstance(result, tuple):
				πF.SetLineno(21)
			Label3:
				// line 22: err = result[-1]
				πF.SetLineno(22)
				if πTemp005, πE = πg.Neg(πF, πg.NewInt(1).ToObject()); πE != nil {
					continue
				}
				πTemp003 = πTemp005
				if πE = πg.CheckLocal(πF, µresult, "result"); πE != nil {
					continue
				}
				if πTemp005, πE = πg.GetItem(πF, µresult, πTemp003); πE != nil {
					continue
				}
				µerr = πTemp005
				// line 23: result = result[:-1]
				πF.SetLineno(23)
				if πTemp005, πE = πg.Neg(πF, πg.NewInt(1).ToObject()); πE != nil {
					continue
				}
				if πTemp003, πE = πg.SliceType.Call(πF, πg.Args{πg.None, πTemp005, πg.None}, nil); πE != nil {
					continue
				}
				if πE = πg.CheckLocal(πF, µresult, "result"); πE != nil {
					continue
				}
				if πTemp005, πE = πg.GetItem(πF, µresult, πTemp003); πE != nil {
					continue
				}
				µresult = πTemp005
				goto Label5
			Label4:
				// line 25: err = result
				πF.SetLineno(25)
				if πE = πg.CheckLocal(πF, µresult, "result"); πE != nil {
					continue
				}
				µerr = µresult
				// line 26: result = ()
				πF.SetLineno(26)
				πTemp003 = πg.NewTuple0().ToObject()
				µresult = πTemp003
				goto Label5
			Label5:
				if πE = πg.CheckLocal(πF, µerr, "err"); πE != nil {
					continue
				}
				if πTemp006, πE = πg.IsTrue(πF, µerr); πE != nil {
					continue
				}
				if πTemp006 {
					goto Label6
				}
				goto Label7
				// line 27: if err:
				πF.SetLineno(27)
			Label6:
				if πE = πg.CheckLocal(πF, µerr, "err"); πE != nil {
					continue
				}
				if πTemp005, πE = πg.ResolveGlobal(πF, ßEINTR); πE != nil {
					continue
				}
				if πTemp003, πE = πg.Eq(πF, µerr, πTemp005); πE != nil {
					continue
				}
				if πTemp006, πE = πg.IsTrue(πF, πTemp003); πE != nil {
					continue
				}
				if πTemp006 {
					goto Label8
				}
				goto Label9
				// line 28: if err == EINTR:
				πF.SetLineno(28)
			Label8:
				// line 29: continue
				πF.SetLineno(29)
				goto Label1
				goto Label9
			Label9:
				πTemp004 = πF.MakeArgs(1)
				if πE = πg.CheckLocal(πF, µerr, "err"); πE != nil {
					continue
				}
				if πTemp003, πE = πg.GetAttr(πF, µerr, ßError, nil); πE != nil {
					continue
				}
				if πTemp005, πE = πTemp003.Call(πF, nil, nil); πE != nil {
					continue
				}
				πTemp004[0] = πTemp005
				if πTemp003, πE = πg.ResolveGlobal(πF, ßOSError); πE != nil {
					continue
				}
				if πTemp005, πE = πTemp003.Call(πF, πTemp004, nil); πE != nil {
					continue
				}
				πF.FreeArgs(πTemp004)
				// line 30: raise OSError(err.Error())
				πF.SetLineno(30)
				πE = πF.Raise(πTemp005, nil, nil)
				continue
				goto Label7
			Label7:
				// line 31: return result
				πF.SetLineno(31)
				if πE = πg.CheckLocal(πF, µresult, "result"); πE != nil {
					continue
				}
				return µresult, nil
				goto Label1
				goto Label2
			Label2:
				return nil, nil
			}
			return nil, πE
		}), πF.Globals()).ToObject()
		if πE = πF.Globals().SetItem(πF, ßinvoke.ToObject(), πTemp001); πE != nil {
			continue
		}
		return nil, nil
	}
	return nil, πE
}
var Code *πg.Code
func init() {
	Code = πg.NewCode("<module>", "build/src/__python__/_syscall.py", nil, 0, initModule)
}
