package thread
import (
	πg "grumpy"
	π_reflect "reflect"
	π_sync "sync"
)
func initModule(πF *πg.Frame, _ []*πg.Object) (*πg.Object, *πg.BaseException) {
	ßLock := πg.InternStr("Lock")
	ßLockType := πg.InternStr("LockType")
	ßMutex := πg.InternStr("Mutex")
	ßUnlock := πg.InternStr("Unlock")
	ß__enter__ := πg.InternStr("__enter__")
	ß__exit__ := πg.InternStr("__exit__")
	ß__frame__ := πg.InternStr("__frame__")
	ß__init__ := πg.InternStr("__init__")
	ß__metaclass__ := πg.InternStr("__metaclass__")
	ß__module__ := πg.InternStr("__module__")
	ß__name__ := πg.InternStr("__name__")
	ß_mutex := πg.InternStr("_mutex")
	ßacquire := πg.InternStr("acquire")
	ßallocate_lock := πg.InternStr("allocate_lock")
	ßf_back := πg.InternStr("f_back")
	ßget_ident := πg.InternStr("get_ident")
	ßid := πg.InternStr("id")
	ßnew := πg.InternStr("new")
	ßobject := πg.InternStr("object")
	ßrelease := πg.InternStr("release")
	var πTemp001 *πg.Object
	_ = πTemp001
	var πTemp002 map[string]*πg.Object
	_ = πTemp002
	var πTemp003 *πg.Object
	_ = πTemp003
	var πTemp004 π_sync.Mutex
	_ = πTemp004
	var πTemp005 []πg.Param
	_ = πTemp005
	var πTemp006 *πg.Dict
	_ = πTemp006
	var πTemp007 []*πg.Object
	_ = πTemp007
	var πTemp008 *πg.Object
	_ = πTemp008
	var πTemp009 *πg.Object
	_ = πTemp009
	var πE *πg.BaseException; _ = πE
	for ; πF.State() >= 0; πF.PopCheckpoint() {
		switch πF.State() {
		case 0:
		default: panic("unexpected function state")
		}
		// line 1: from __go__.sync import type_Mutex as Mutex
		πF.SetLineno(1)
		πTemp002 = map[string]*πg.Object{}
		if πTemp003, πE = πg.WrapNative(πF, π_reflect.ValueOf(πTemp004)); πE != nil {
			continue
		}
		πTemp003 = πTemp003.Type().ToObject()
		πTemp002["Mutex"] = πTemp003
		if πTemp001, πE = πg.ImportNativeModule(πF, "sync", πTemp002); πE != nil {
			continue
		}
		if πTemp003, πE = πg.GetAttr(πF, πTemp001, ßMutex, nil); πE != nil {
			continue
		}
		if πE = πF.Globals().SetItem(πF, ßMutex.ToObject(), πTemp003); πE != nil {
			continue
		}
		// line 4: def get_ident():
		πF.SetLineno(4)
		πTemp005 = make([]πg.Param, 0)
		πTemp001 = πg.NewFunction(πg.NewCode("get_ident", "build/src/__python__/thread.py", πTemp005, 0, func(πF *πg.Frame, πArgs []*πg.Object) (*πg.Object, *πg.BaseException) {
			var µf *πg.Object = πg.UnboundLocal; _ = µf
			var πTemp001 *πg.Object
			_ = πTemp001
			var πTemp002 *πg.Object
			_ = πTemp002
			var πTemp003 bool
			_ = πTemp003
			var πTemp004 []*πg.Object
			_ = πTemp004
			var πE *πg.BaseException; _ = πE
			for ; πF.State() >= 0; πF.PopCheckpoint() {
				switch πF.State() {
				case 0:
				default: panic("unexpected function state")
				}
				// line 5: f = __frame__()
				πF.SetLineno(5)
				if πTemp001, πE = πg.ResolveGlobal(πF, ß__frame__); πE != nil {
					continue
				}
				if πTemp002, πE = πTemp001.Call(πF, nil, nil); πE != nil {
					continue
				}
				µf = πTemp002
				// line 6: while f.f_back:
				πF.SetLineno(6)
			Label1:
				if πE = πg.CheckLocal(πF, µf, "f"); πE != nil {
					continue
				}
				if πTemp001, πE = πg.GetAttr(πF, µf, ßf_back, nil); πE != nil {
					continue
				}
				if πTemp003, πE = πg.IsTrue(πF, πTemp001); πE != nil {
					continue
				}
				if !πTemp003 {
					goto Label2
				}
				// line 7: f = f.f_back
				πF.SetLineno(7)
				if πE = πg.CheckLocal(πF, µf, "f"); πE != nil {
					continue
				}
				if πTemp002, πE = πg.GetAttr(πF, µf, ßf_back, nil); πE != nil {
					continue
				}
				µf = πTemp002
				goto Label1
				goto Label2
			Label2:
				// line 8: return id(f)
				πF.SetLineno(8)
				πTemp004 = πF.MakeArgs(1)
				if πE = πg.CheckLocal(πF, µf, "f"); πE != nil {
					continue
				}
				πTemp004[0] = µf
				if πTemp001, πE = πg.ResolveGlobal(πF, ßid); πE != nil {
					continue
				}
				if πTemp002, πE = πTemp001.Call(πF, πTemp004, nil); πE != nil {
					continue
				}
				πF.FreeArgs(πTemp004)
				return πTemp002, nil
				return nil, nil
			}
			return nil, πE
		}), πF.Globals()).ToObject()
		if πE = πF.Globals().SetItem(πF, ßget_ident.ToObject(), πTemp001); πE != nil {
			continue
		}
		// line 11: class LockType(object):
		πF.SetLineno(11)
		πTemp007 = make([]*πg.Object, 1)
		if πTemp009, πE = πg.ResolveGlobal(πF, ßobject); πE != nil {
			continue
		}
		πTemp007[0] = πTemp009
		πTemp006 = πg.NewDict()
		if πTemp003, πE = πF.Globals().GetItem(πF, ß__name__.ToObject()); πE != nil {
			continue
		}
		if πE = πTemp006.SetItem(πF, ß__module__.ToObject(), πTemp003); πE != nil {
			continue
		}
		_, πE = πg.NewCode("LockType", "build/src/__python__/thread.py", nil, 0, func(πF *πg.Frame, _ []*πg.Object) (*πg.Object, *πg.BaseException) {
			πClass := πTemp006
			_ = πClass
			var πTemp001 *πg.Object
			_ = πTemp001
			var πTemp002 []πg.Param
			_ = πTemp002
			var πTemp003 *πg.Object
			_ = πTemp003
			var πTemp004 *πg.Object
			_ = πTemp004
			var πTemp005 *πg.Object
			_ = πTemp005
			var πTemp006 *πg.Object
			_ = πTemp006
			var πE *πg.BaseException; _ = πE
			for ; πF.State() >= 0; πF.PopCheckpoint() {
				switch πF.State() {
				case 0:
				default: panic("unexpected function state")
				}
				// line 12: def __init__(self):
				πF.SetLineno(12)
				πTemp002 = make([]πg.Param, 1)
				πTemp002[0] = πg.Param{Name: "self", Def: nil}
				πTemp001 = πg.NewFunction(πg.NewCode("__init__", "build/src/__python__/thread.py", πTemp002, 0, func(πF *πg.Frame, πArgs []*πg.Object) (*πg.Object, *πg.BaseException) {
					var µself *πg.Object = πArgs[0]; _ = µself
					var πTemp001 *πg.Object
					_ = πTemp001
					var πTemp002 *πg.Object
					_ = πTemp002
					var πE *πg.BaseException; _ = πE
					for ; πF.State() >= 0; πF.PopCheckpoint() {
						switch πF.State() {
						case 0:
						default: panic("unexpected function state")
						}
						// line 13: self._mutex = Mutex.new()
						πF.SetLineno(13)
						if πTemp001, πE = πg.ResolveGlobal(πF, ßMutex); πE != nil {
							continue
						}
						if πTemp002, πE = πg.GetAttr(πF, πTemp001, ßnew, nil); πE != nil {
							continue
						}
						if πTemp001, πE = πTemp002.Call(πF, nil, nil); πE != nil {
							continue
						}
						if πE = πg.Tie(πF, πg.TieTarget{Target: &πTemp002}, πTemp001); πE != nil {
							continue
						}
						if πE = πg.CheckLocal(πF, µself, "self"); πE != nil {
							continue
						}
						if πE = πg.SetAttr(πF, µself, ß_mutex, πTemp002); πE != nil {
							continue
						}
						return nil, nil
					}
					return nil, πE
				}), πF.Globals()).ToObject()
				if πE = πClass.SetItem(πF, ß__init__.ToObject(), πTemp001); πE != nil {
					continue
				}
				// line 15: def acquire(self):
				πF.SetLineno(15)
				πTemp002 = make([]πg.Param, 1)
				πTemp002[0] = πg.Param{Name: "self", Def: nil}
				πTemp003 = πg.NewFunction(πg.NewCode("acquire", "build/src/__python__/thread.py", πTemp002, 0, func(πF *πg.Frame, πArgs []*πg.Object) (*πg.Object, *πg.BaseException) {
					var µself *πg.Object = πArgs[0]; _ = µself
					var πTemp001 *πg.Object
					_ = πTemp001
					var πTemp002 *πg.Object
					_ = πTemp002
					var πE *πg.BaseException; _ = πE
					for ; πF.State() >= 0; πF.PopCheckpoint() {
						switch πF.State() {
						case 0:
						default: panic("unexpected function state")
						}
						// line 16: self._mutex.Lock()
						πF.SetLineno(16)
						if πE = πg.CheckLocal(πF, µself, "self"); πE != nil {
							continue
						}
						if πTemp001, πE = πg.GetAttr(πF, µself, ß_mutex, nil); πE != nil {
							continue
						}
						if πTemp002, πE = πg.GetAttr(πF, πTemp001, ßLock, nil); πE != nil {
							continue
						}
						if πTemp001, πE = πTemp002.Call(πF, nil, nil); πE != nil {
							continue
						}
						return nil, nil
					}
					return nil, πE
				}), πF.Globals()).ToObject()
				if πE = πClass.SetItem(πF, ßacquire.ToObject(), πTemp003); πE != nil {
					continue
				}
				// line 18: def release(self):
				πF.SetLineno(18)
				πTemp002 = make([]πg.Param, 1)
				πTemp002[0] = πg.Param{Name: "self", Def: nil}
				πTemp004 = πg.NewFunction(πg.NewCode("release", "build/src/__python__/thread.py", πTemp002, 0, func(πF *πg.Frame, πArgs []*πg.Object) (*πg.Object, *πg.BaseException) {
					var µself *πg.Object = πArgs[0]; _ = µself
					var πTemp001 *πg.Object
					_ = πTemp001
					var πTemp002 *πg.Object
					_ = πTemp002
					var πE *πg.BaseException; _ = πE
					for ; πF.State() >= 0; πF.PopCheckpoint() {
						switch πF.State() {
						case 0:
						default: panic("unexpected function state")
						}
						// line 19: self._mutex.Unlock()
						πF.SetLineno(19)
						if πE = πg.CheckLocal(πF, µself, "self"); πE != nil {
							continue
						}
						if πTemp001, πE = πg.GetAttr(πF, µself, ß_mutex, nil); πE != nil {
							continue
						}
						if πTemp002, πE = πg.GetAttr(πF, πTemp001, ßUnlock, nil); πE != nil {
							continue
						}
						if πTemp001, πE = πTemp002.Call(πF, nil, nil); πE != nil {
							continue
						}
						return nil, nil
					}
					return nil, πE
				}), πF.Globals()).ToObject()
				if πE = πClass.SetItem(πF, ßrelease.ToObject(), πTemp004); πE != nil {
					continue
				}
				// line 21: def __enter__(self):
				πF.SetLineno(21)
				πTemp002 = make([]πg.Param, 1)
				πTemp002[0] = πg.Param{Name: "self", Def: nil}
				πTemp005 = πg.NewFunction(πg.NewCode("__enter__", "build/src/__python__/thread.py", πTemp002, 0, func(πF *πg.Frame, πArgs []*πg.Object) (*πg.Object, *πg.BaseException) {
					var µself *πg.Object = πArgs[0]; _ = µself
					var πTemp001 *πg.Object
					_ = πTemp001
					var πTemp002 *πg.Object
					_ = πTemp002
					var πE *πg.BaseException; _ = πE
					for ; πF.State() >= 0; πF.PopCheckpoint() {
						switch πF.State() {
						case 0:
						default: panic("unexpected function state")
						}
						// line 22: self.acquire()
						πF.SetLineno(22)
						if πE = πg.CheckLocal(πF, µself, "self"); πE != nil {
							continue
						}
						if πTemp001, πE = πg.GetAttr(πF, µself, ßacquire, nil); πE != nil {
							continue
						}
						if πTemp002, πE = πTemp001.Call(πF, nil, nil); πE != nil {
							continue
						}
						return nil, nil
					}
					return nil, πE
				}), πF.Globals()).ToObject()
				if πE = πClass.SetItem(πF, ß__enter__.ToObject(), πTemp005); πE != nil {
					continue
				}
				// line 24: def __exit__(self, *args):
				πF.SetLineno(24)
				πTemp002 = make([]πg.Param, 1)
				πTemp002[0] = πg.Param{Name: "self", Def: nil}
				πTemp006 = πg.NewFunction(πg.NewCode("__exit__", "build/src/__python__/thread.py", πTemp002, πg.CodeFlagVarArg, func(πF *πg.Frame, πArgs []*πg.Object) (*πg.Object, *πg.BaseException) {
					var µself *πg.Object = πArgs[0]; _ = µself
					var µargs *πg.Object = πArgs[1]; _ = µargs
					var πTemp001 *πg.Object
					_ = πTemp001
					var πTemp002 *πg.Object
					_ = πTemp002
					var πE *πg.BaseException; _ = πE
					for ; πF.State() >= 0; πF.PopCheckpoint() {
						switch πF.State() {
						case 0:
						default: panic("unexpected function state")
						}
						// line 25: self.release()
						πF.SetLineno(25)
						if πE = πg.CheckLocal(πF, µself, "self"); πE != nil {
							continue
						}
						if πTemp001, πE = πg.GetAttr(πF, µself, ßrelease, nil); πE != nil {
							continue
						}
						if πTemp002, πE = πTemp001.Call(πF, nil, nil); πE != nil {
							continue
						}
						return nil, nil
					}
					return nil, πE
				}), πF.Globals()).ToObject()
				if πE = πClass.SetItem(πF, ß__exit__.ToObject(), πTemp006); πE != nil {
					continue
				}
				return nil, nil
			}
			return nil, πE
		}).Eval(πF, πF.Globals(), nil, nil)
		if πE != nil {
			continue
		}
		if πTemp008, πE = πTemp006.GetItem(πF, ß__metaclass__.ToObject()); πE != nil {
			continue
		}
		if πTemp008 == nil {
			πTemp008 = πg.TypeType.ToObject()
		}
		if πTemp009, πE = πTemp008.Call(πF, []*πg.Object{πg.NewStr("LockType").ToObject(), πg.NewTuple(πTemp007...).ToObject(), πTemp006.ToObject()}, nil); πE != nil {
			continue
		}
		if πE = πF.Globals().SetItem(πF, ßLockType.ToObject(), πTemp009); πE != nil {
			continue
		}
		// line 28: def allocate_lock():
		πF.SetLineno(28)
		πTemp005 = make([]πg.Param, 0)
		πTemp003 = πg.NewFunction(πg.NewCode("allocate_lock", "build/src/__python__/thread.py", πTemp005, 0, func(πF *πg.Frame, πArgs []*πg.Object) (*πg.Object, *πg.BaseException) {
			var πTemp001 *πg.Object
			_ = πTemp001
			var πTemp002 *πg.Object
			_ = πTemp002
			var πE *πg.BaseException; _ = πE
			for ; πF.State() >= 0; πF.PopCheckpoint() {
				switch πF.State() {
				case 0:
				default: panic("unexpected function state")
				}
				// line 29: """Dummy implementation of thread.allocate_lock()."""
				πF.SetLineno(29)
				// line 30: return LockType()
				πF.SetLineno(30)
				if πTemp001, πE = πg.ResolveGlobal(πF, ßLockType); πE != nil {
					continue
				}
				if πTemp002, πE = πTemp001.Call(πF, nil, nil); πE != nil {
					continue
				}
				return πTemp002, nil
				return nil, nil
			}
			return nil, πE
		}), πF.Globals()).ToObject()
		if πE = πF.Globals().SetItem(πF, ßallocate_lock.ToObject(), πTemp003); πE != nil {
			continue
		}
		return nil, nil
	}
	return nil, πE
}
var Code *πg.Code
func init() {
	Code = πg.NewCode("<module>", "build/src/__python__/thread.py", nil, 0, initModule)
}
