// Loader is used for preloading a module
163560
func Loader(L *lua.LState) int {

	// register functions to the table
	mod := L.SetFuncs(L.NewTable(), exports)

	// set up meta table
	mt := L.NewTable()
	L.SetField(mt, "__index", L.NewClosure(moduleIndex))
	L.SetField(mt, "__call", L.NewClosure(moduleCall))
	L.SetMetatable(mod, mt)

	shMetaTable := L.NewTypeMetatable(luaShTypeName)
	L.SetField(shMetaTable, "__call", L.NewFunction(shCall))
	L.SetField(shMetaTable, "__index", L.NewFunction(shIndex))

	// returns the module
	L.Push(mod)
	return 1
}
228485
func NewLoader(backends ...backend.Backend) *Loader {
	l := Loader{
		backends: backends,
	}

	if len(l.backends) == 0 {
		l.backends = append(l.backends, env.NewBackend())
	}

	return &l
}
582235
func WithLoader(l loader.Loader) Option {
	return func(o *Options) {
		o.Loader = l
	}
}
448456
func (l hcl2Loader) loadFile(filename string) (configurable, []string, error) {
	var f *hcl2.File
	var diags hcl2.Diagnostics
	if strings.HasSuffix(filename, ".json") {
		f, diags = l.Parser.ParseJSONFile(filename)
	} else {
		f, diags = l.Parser.ParseHCLFile(filename)
	}
	if diags.HasErrors() {
		// Return diagnostics as an error; callers may type-assert this to
		// recover the original diagnostics, if it doesn't end up wrapped
		// in another error.
		return nil, nil, diags
	}

	return &hcl2Configurable{
		SourceFilename: filename,
		Body:           f.Body,
	}, nil, nil
}
898691
func (t *Tree) Loaded() bool {
	t.lock.RLock()
	defer t.lock.RUnlock()
	return t.children != nil
}
1279168
func SpecLoader(specFileOrDirs []string, createBlkTxTables bool) (*Projection, error) {
	var projection *Projection
	var err error

	if len(specFileOrDirs) == 0 {
		return nil, fmt.Errorf("please provide a spec file or directory")
	}

	projection, err = NewProjectionFromFolder(specFileOrDirs...)
	if err != nil {
		return nil, fmt.Errorf("error parsing spec: %v", err)
	}

	if createBlkTxTables {
		// add block & tx to tables definition
		blkTxTables := getBlockTxTablesDefinition()

		for k, v := range blkTxTables {
			projection.Tables[k] = v
		}

	}

	return projection, nil
}
711080
func (c *Context) loadPackage(stack []string, path string) (*Package, error) {
	if pkg, ok := c.pkgs[path]; ok {
		// already loaded, just return
		return pkg, nil
	}

	p, err := c.importer.Import(path)
	if err != nil {
		return nil, err
	}

	stack = append(stack, p.ImportPath)
	var stale bool
	for i, im := range p.Imports {
		for _, p := range stack {
			if p == im {
				return nil, fmt.Errorf("import cycle detected: %s", strings.Join(append(stack, im), " -> "))
			}
		}
		pkg, err := c.loadPackage(stack, im)
		if err != nil {
			return nil, err
		}

		// update the import path as the import may have been discovered via vendoring.
		p.Imports[i] = pkg.ImportPath
		stale = stale || !pkg.NotStale
	}

	pkg, err := c.newPackage(p)
	if err != nil {
		return nil, errors.Wrapf(err, "loadPackage(%q)", path)
	}
	pkg.Main = pkg.Name == "main"
	pkg.NotStale = !(stale || pkg.isStale())
	c.pkgs[p.ImportPath] = pkg
	return pkg, nil
}
1022881
func (loader *PluginLoader) Initialize() error {
	for _, p := range loader.plugins {
		err := p.Init()
		if err != nil {
			return err
		}
	}

	return nil
}
1070440
func CronLoader(b backend.B) caching.Loader {
	return func(c context.Context, k caching.Key, v *caching.Value) (*caching.Value, error) {
		return caching.CacheLoad(c, b, k, v)
	}
}
786042
func LoadReader(r io.Reader) error {
	env, err := Read(r)
	if err != nil {
		return err
	}
	LoadMap(env, false)
	return nil
}
307776
func (query Query) Preload(record interface{}, field string) error {
	path := strings.Split(field, ".")

	rv := reflect.ValueOf(record)
	if rv.Kind() != reflect.Ptr || rv.IsNil() {
		panic("grimoire: record parameter must be a pointer.")
	}

	preload := traversePreloadTarget(rv.Elem(), path)
	if len(preload) == 0 {
		return nil
	}

	schemaType := preload[0].schema.Type()
	refIndex, fkIndex, column := getPreloadInfo(schemaType, path[len(path)-1])

	addrs, ids := collectPreloadTarget(preload, refIndex)
	if len(ids) == 0 {
		return nil
	}

	// prepare temp result variable for querying
	rt := preload[0].field.Type()
	if rt.Kind() == reflect.Slice || rt.Kind() == reflect.Array || rt.Kind() == reflect.Ptr {
		rt = rt.Elem()
	}

	slice := reflect.MakeSlice(reflect.SliceOf(rt), 0, len(ids))
	result := reflect.New(slice.Type())
	result.Elem().Set(slice)

	// query all records using collected ids.
	err := query.Where(c.In(c.I(column), ids...)).All(result.Interface())
	if err != nil {
		return err
	}

	// map results.
	result = result.Elem()
	for i := 0; i < result.Len(); i++ {
		curr := result.Index(i)
		id := getPreloadID(curr.FieldByIndex(fkIndex))

		for _, addr := range addrs[id] {
			if addr.Kind() == reflect.Slice {
				addr.Set(reflect.Append(addr, curr))
			} else if addr.Kind() == reflect.Ptr {
				currP := reflect.New(curr.Type())
				currP.Elem().Set(curr)
				addr.Set(currP)
			} else {
				addr.Set(curr)
			}
		}
	}

	return nil
}
203252
func PluginLoader(opts map[string]string) (map[string]interface{}, error) {
	conf := map[string]interface{}{}
	if v, err := strconv.ParseBool(opts["driver.raw_exec.enable"]); err == nil {
		conf["enabled"] = v
	}
	if v, err := strconv.ParseBool(opts["driver.raw_exec.no_cgroups"]); err == nil {
		conf["no_cgroups"] = v
	}
	return conf, nil
}
986143
func serviceLoader(h http.Handler, svcs ...service) http.Handler {
	for _, svc := range svcs {
		h = svc(h)
	}
	return h
}
1018779
func (l *propertiesLoader) Load(out interface{}) error {
	properties := make(p.Properties)
	if err := properties.Load(l.r); err != nil {
		return err
	}
	o := out.(*map[string]string)
	*o = map[string]string(properties)
	return nil
}
886414
func FileLoader() Reactor {
	return Reactive(func(v Reactor, err error, d interface{}) {
		if err != nil {
			v.ReplyError(err)
			return
		}

		var file string
		var ok bool

		if file, ok = d.(string); !ok {
			v.ReplyError(ErrValueType)
			return
		}

		var data []byte

		if data, err = ioutil.ReadFile(file); err != nil {
			v.ReplyError(err)
			return
		}

		v.Reply(string(data))
	})
}
1206723
func (s *DB) Preload(column string, conditions ...interface{}) *DB {
	return s.clone().search.Preload(column, conditions...).db
}
1191776
func (l *jsonLoader) Load(out interface{}) error {
	var buf bytes.Buffer
	buf.ReadFrom(l.r)
	if err := json.Unmarshal(buf.Bytes(), out); err != nil {
		return err
	}
	return nil
}