// NewZlispWithFuncs returns a new *Zlisp instance with access to only the given builtin functions
961255
func NewZlispWithFuncs(funcs map[string]ZlispUserFunction) *Zlisp {
	env := new(Zlisp)
	env.baseTypeCtor = MakeUserFunction("__basetype_ctor", BaseTypeConstructorFunction)
	env.parser = env.NewParser()
	env.parser.Start()
	env.datastack = env.NewStack(DataStackSize)
	env.linearstack = env.NewStack(ScopeStackSize)

	glob := env.NewNamedScope("global")
	glob.IsGlobal = true
	env.linearstack.Push(glob)
	env.addrstack = env.NewStack(CallStackSize)
	env.loopstack = env.NewStack(LoopStackSize)
	env.builtins = make(map[int]*SexpFunction)
	env.reserved = make(map[int]bool)
	env.macros = make(map[int]*SexpFunction)
	env.symtable = make(map[string]int)
	env.revsymtable = make(map[int]string)
	env.nextsymbol = 1
	env.before = []PreHook{}
	env.after = []PostHook{}
	env.infixOps = make(map[string]*InfixOp)
	env.AddGlobal("null", SexpNull)
	env.AddGlobal("nil", SexpNull)

	for key, function := range funcs {
		sym := env.MakeSymbol(key)
		env.builtins[sym.number] = MakeUserFunction(key, function)
		env.AddFunction(key, function)
	}

	for _, word := range ReservedWords {
		sym := env.MakeSymbol(word)
		env.reserved[sym.number] = true
	}

	env.mainfunc = env.MakeFunction("__main", 0, false,
		make([]Instruction, 0), nil)
	env.curfunc = env.mainfunc
	env.pc = 0
	env.debugSymbolNotFound = false
	//env.debugSymbolNotFound = true
	//env.debugExec = true
	env.InitInfixOps()

	return env

}
1164426
func NewAtomicFS() *AtomicFS {
	fs := &AtomicFS{}
	fs.v.Store(make(ctxvfs.NameSpace))
	return fs
}
751257
func MakeFileSha512Func(baseDir string) function.Function {
	return makeFileHashFunction(baseDir, sha512.New, hex.EncodeToString)
}
1248526
func newNonTS() *SetNonTS {
	s := &SetNonTS{}
	s.m = make(map[interface{}]struct{})

	// Ensure interface compliance
	var _ Interface = s

	return s
}
155464
func (r DynamicRender) AddFromFilesFuncs(name string, funcMap template.FuncMap, files ...string) *template.Template {
	tname := filepath.Base(files[0])
	builder := &templateBuilder{templateName: tname, funcMap: funcMap, files: files}
	builder.buildType = filesFuncTemplateType
	r[name] = builder
	return builder.buildTemplate()
}
1334388
func createValueFuncs(funcMap FuncMap) map[string]reflect.Value {
	m := make(map[string]reflect.Value)
	addValueFuncs(m, funcMap)
	return m
}
667641
func printNICs(tsv bool, nics ...*crimson.NIC) {
	if len(nics) > 0 {
		p := newStdoutPrinter(tsv)
		defer p.Flush()
		if !tsv {
			p.Row("Name", "Machine", "MAC Address", "Switch", "Port")
		}
		for _, n := range nics {
			p.Row(n.Name, n.Machine, n.MacAddress, n.Switch, n.Switchport)
		}
	}
}
1230197
func NewBFlagsWithArgs(args []string) *BFlags {
	flags := NewBFlags()
	flags.Args = args
	return flags
}
1368604
func CreatePluginSysCCs(p *Provider) []SelfDescribingSysCC {
	var sdscs []SelfDescribingSysCC
	for _, pscc := range loadSysCCs(p) {
		sdscs = append(sdscs, &SysCCWrapper{SCC: pscc})
	}
	return sdscs
}
703749
func DefinedFunction(env *Zlisp, name string, args []Sexp) (Sexp, error) {
	//P("in DefinedFunction, args = '%#v'", args)
	narg := len(args)
	if narg != 1 {
		return SexpNull, WrongNargs
	}

	var checkme string
	switch nm := args[0].(type) {
	case *SexpStr:
		checkme = nm.S
	case *SexpSymbol:
		checkme = nm.name
	case *SexpFunction:
		return &SexpBool{Val: true}, nil
	default:
		return &SexpBool{Val: false}, nil
	}

	_, err, _ := env.LexicalLookupSymbol(env.MakeSymbol(checkme), nil)
	if err != nil {
		return &SexpBool{Val: false}, nil
	}
	return &SexpBool{Val: true}, nil
}
727576
func NewFS(fs http.FileSystem, strip string) *FS {
	fsm := FS{
		FileSystem: fs,
		Strip:      strip,
		Header:     make(http.Header),
	}
	return &fsm
}
1269567
func SlurpfileFunction(env *Zlisp, name string, args []Sexp) (Sexp, error) {
	if len(args) != 1 {
		return SexpNull, WrongNargs
	}
	var fn string
	switch fna := args[0].(type) {
	case *SexpStr:
		fn = fna.S
	default:
		return SexpNull, fmt.Errorf("slurp requires a string path to read. we got type %T / value = %v", args[0], args[0])
	}

	if !FileExists(string(fn)) {
		return SexpNull, fmt.Errorf("file '%s' does not exist", fn)
	}
	f, err := os.Open(fn)
	if err != nil {
		return SexpNull, err
	}
	defer f.Close()

	a := make([]Sexp, 0)

	bufIn := bufio.NewReader(f)
	lineNum := int64(1)
	for {
		lastline, err := bufIn.ReadBytes('\n')
		if err != nil && err != io.EOF {
			return SexpNull, err
		}
		n := len(lastline)
		if err == io.EOF && n == 0 {
			break
		}
		if n > 0 {
			if lastline[n-1] == '\n' {
				a = append(a, &SexpStr{S: string(lastline[:n-1])})
			} else {
				a = append(a, &SexpStr{S: string(lastline)})
			}
			lineNum += 1
		}

		if err == io.EOF {
			break
		}
	}

	VPrintf("read %d lines\n", lineNum)
	return env.NewSexpArray(a), nil
}
205655
func NewCmdSimpleFS(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
	return cli.Command{
		Name:         "fs",
		Usage:        "Perform filesystem operations",
		ArgumentHelp: "[arguments...]",
		Subcommands: append([]cli.Command{
			NewCmdSimpleFSList(cl, g),
			NewCmdSimpleFSCopy(cl, g),
			NewCmdSimpleFSMove(cl, g),
			NewCmdSimpleFSSymlink(cl, g),
			NewCmdSimpleFSRead(cl, g),
			NewCmdSimpleFSRemove(cl, g),
			NewCmdSimpleFSMkdir(cl, g),
			NewCmdSimpleFSStat(cl, g),
			NewCmdSimpleFSGetStatus(cl, g),
			NewCmdSimpleFSKill(cl, g),
			NewCmdSimpleFSPs(cl, g),
			NewCmdSimpleFSWrite(cl, g),
			NewCmdSimpleFSDebug(cl, g),
			NewCmdSimpleFSSetDebugLevel(cl, g),
			NewCmdSimpleFSHistory(cl, g),
			NewCmdSimpleFSQuota(cl, g),
			NewCmdSimpleFSRecover(cl, g),
			NewCmdSimpleFSReset(cl, g),
			NewCmdSimpleFSClearConflicts(cl, g),
			NewCmdSimpleFSSync(cl, g),
		}, getBuildSpecificFSCommands(cl, g)...),
	}
}
1003830
func NewPlugins(ps []Plugin, autoname bool, dedup bool) Plugins {
	sortPlugins(ps)
	return &plugins{
		plugins:  ps,
		autoname: autoname,
		dedup:    dedup,
	}
}
1150910
func NewNotIPAddressFunc(key Key, IPNets ...*net.IPNet) (Function, error) {
	if key != AWSSourceIP {
		return nil, fmt.Errorf("only %v key is allowed for %v condition", AWSSourceIP, notIPAddress)
	}

	return &notIPAddressFunc{ipAddressFunc{key, IPNets}}, nil
}
1253275
func NewDefaults() *args.GeneratorArgs {
	genericArgs := args.Default().WithoutDefaultFlagParsing()
	genericArgs.OutputFileBaseName = "zz_generated.register"
	return genericArgs
}
1210559
func NewFcall(sz uint32) *Fcall {
	fc := new(Fcall)
	fc.Buf = make([]byte, sz)

	return fc
}