├── .gitignore ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── cmd ├── Makefile ├── help.go ├── main.go ├── methods.go ├── packages.go ├── quit.go ├── set.go ├── set_highlight.go ├── set_width.go ├── show.go ├── show_highlight.go ├── show_width.go └── whatis.go ├── commands.go ├── main.go ├── main_grl.go ├── make_env.go ├── make_env_test.go ├── msg.go ├── preprocess.go ├── repl.go ├── repl_imports.go ├── subcmds.go ├── testdata ├── .gitignore └── string_imports.go └── validate.go /.gitignore: -------------------------------------------------------------------------------- 1 | /*~ 2 | /go-fish 3 | /go-fish-grl 4 | /make_env 5 | /testdata/string_imports.gone 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | sudo: false 4 | env: 5 | go: 6 | - 1.4 7 | 8 | script: 9 | - GOBIN=$HOME; export GOBIN 10 | - go get 11 | - go get "github.com/0xfaded/eval" 12 | - go get "github.com/mgutz/ansi" 13 | - go get "github.com/rocky/go-fish/cmd" 14 | - go get "github.com/rocky/go-types" 15 | - go get "github.com/rocky/go-loader" 16 | - go build 17 | - go build make_env.go 18 | - go install make_env.go 19 | - $HOME/make_env > repl_imports.next && mv repl_imports.next repl_imports.go 20 | # need to work on not running out of source tree 21 | # - go test -v 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Rocky Bernstein 2 | All rights reserved 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | 24 | The views and conclusions contained in the software and documentation 25 | are those of the authors and should not be interpreted as representing 26 | official policies, either expressed or implied. 27 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Comments starting with #: below are remake GNU Makefile comments. See 2 | # https://github.com/rocky/remake/wiki/Rake-tasks-for-gnu-make 3 | 4 | .PHONY: all exports test check clean cmd 5 | 6 | #: Same as: make go-fish 7 | all: go-fish 8 | 9 | #: The non-GNU Readline REPL front-end to the go-interactive evaluator 10 | go-fish: repl_imports.go main.go repl.go cmd 11 | go build -o go-fish main.go 12 | 13 | #: The GNU Readline REPL front-end to the go-interactive evaluator 14 | go-fish-grl: repl_imports.go main_grl.go repl.go 15 | go build -o go-fish-grl main_grl.go 16 | 17 | cmd: 18 | cd cmd && go build 19 | 20 | main.go: repl_imports.go 21 | 22 | #: Subsidiary program to import packages into go-fish 23 | make_env: make_env.go 24 | @echo go build make_env.go 25 | 26 | # Note: we have to create the next repl_imports.go to a new place 27 | # either outside of this directory or to a non-go extension, otherwise 28 | # make_env will try to read the file it is trying to create! 29 | 30 | #: The recreated extracted imports by running make_env 31 | repl_imports.go: make_env 32 | ./make_env > repl_imports.next && mv repl_imports.next repl_imports.go 33 | 34 | #: Check stuff 35 | test: make_env.go 36 | go test -v 37 | 38 | #: Same as: make test 39 | check: test 40 | 41 | #: Remove derived files. 42 | clean: 43 | for file in make_env go-fish go-fish-grl repl_import.go ; do \ 44 | if test -e "$$file" ; then rm $$file ; fi \ 45 | done 46 | 47 | #: Install this puppy 48 | install: 49 | go install 50 | [ -x ./go-fish ] && cp ./go-fish $$GOBIN/go-fish 51 | [ -x ./go-fish-grl ] && cp ./go-fish $$GOBIN/go-fish-grl 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | go-fish - Yet another Go REPL (read, eval, print loop) 2 | ============================================================================ 3 | 4 | [![Build Status](https://travis-ci.org/rocky/go-fish.png)](https://travis-ci.org/rocky/go-fish) [![GoDoc](https://godoc.org/github.com/rocky/go-fish?status.svg)](https://godoc.org/github.com/rocky/go-fish) 5 | 6 | This project provides an interactive environment for evaluating go 7 | expressions. 8 | 9 | Yeah, we know of some others. I think this one has more promise. The 10 | heavy lifting for eval is provided by the Carl Chatfield's 11 | [eval](https://github.com/0xfaded/eval) package. 12 | 13 | Setup 14 | ----- 15 | 16 | * Make sure our Go environment is setup, e.g. *$GOBIN*, *$GOPATH*, ... 17 | * Make sure you have a version 1.3ish Go installed. 18 | 19 | ``` 20 | $ go get github.com/rocky/go-fish 21 | $ cd $GOPATH/src/github.com/rocky/go-fish 22 | $ make install # or look at Makefile 23 | ``` 24 | 25 | If you have 26 | [go-gnureadline](https://code.google.com/p/go-gnureadline/) installed 27 | and want the GNU readline support. In addition to the above try: 28 | 29 | ``` 30 | $ make go-fish-grl 31 | $ make install 32 | ``` 33 | 34 | If you have [remake](https://github.com/rocky/remake) installed, you can change *make* above to *remake -x* to see the simple *go* and shell commands that get run. (And *remake --tasks* is also your friend.) 35 | 36 | Using 37 | ----- 38 | 39 | Run `go-fish` or `go-fish-grl`. For now, we have only a static 40 | environment provided and that's exactly the environment that *go-fish* 41 | uses for itself. (In other words this is ideally suited to introspect 42 | about itself). Since it uses *eval* and that package is a reasonable size program, 43 | many of the packages like *os*, *fmt*, *strconv*, *errors*, *exec*, etc. are 44 | available. Look at the import list in file *repl_imports.go* for the 45 | exact list, or type *pkgs* inside *go-fish* (as shown below) for a list. 46 | 47 | Two global variables have been defined: *env*, and *results*. *env* 48 | the environment that is defined, again largely by 49 | *eval_imports.go*. As you enter expresions, the results are saved in 50 | slice *results*. To quit, enter `Ctrl-D` (EOF) or the word `quit`. 51 | 52 | Here's a sample session: 53 | 54 | ```console 55 | $ ./go-fish 56 | == A simple Go eval REPL == 57 | 58 | Results of expression are stored in variable slice "results". 59 | The environment is stored in global variable "env". 60 | 61 | Enter expressions to be evaluated at the "gofish>" prompt. 62 | 63 | To see all results, type: "results". 64 | 65 | To quit, enter: "quit" or Ctrl-D (EOF). 66 | To get help, enter: "help". 67 | gofish> 10+len("abc" + "def") 68 | Kind = Type = int 69 | results[0] = 16 70 | gofish> os.Stderr 71 | os.Stderr 72 | Kind = ptr 73 | Type = *os.File 74 | results[1] = &{0x1882d120} 75 | gofish> fmt.Fprintln(os.Stderr, os.Getenv("GOPATH")) 76 | /home/rocky/go 77 | Kind = Multi-Value 78 | 15, nil 79 | gofish> help * 80 | All command names: 81 | help packages quit 82 | gofish> packages 83 | All imported packages: 84 | ansi binary eval fmt math rand scanner sync time 85 | ast bufio exec io os reflect sort syscall token 86 | atomic bytes filepath ioutil parser repl strconv tabwriter unicode 87 | big errors flag log pprof runtime strings testing utf8 88 | gofish> pkg ansi 89 | === Package ansi ("github.com/mgutz/ansi"): === 90 | Constants of ansi: 91 | Reset 92 | Functions of ansi: 93 | Color ColorCode ColorFunc DisableColors 94 | gofish> quit 95 | go-fish: That's all folks... 96 | $ 97 | ``` 98 | 99 | See Also 100 | -------- 101 | 102 | * [What's left to do?](https://github.com/rocky/go-fish/wiki/What%27s-left-to-do%3F) 103 | * [go-play](http://code.google.com/p/go-play): A locally-run HTML5 web interface for experimenting with Go code 104 | * [gub](https://github.com/rocky/ssa-interp): A Go debugger based on the SSA interpreter 105 | 106 | [![endorse rocky](https://api.coderwall.com/rocky/endorsecount.png)](https://coderwall.com/rocky) 107 | -------------------------------------------------------------------------------- /cmd/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be forwarded to the 2 | # to top-level directories 3 | .PHONY: check check-quick test test-quick all 4 | 5 | all: 6 | $(MAKE) -C .. 7 | 8 | %: 9 | $(MAKE) -C ../.. $@ 10 | -------------------------------------------------------------------------------- /cmd/help.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package fishcmd 6 | 7 | import ( 8 | "sort" 9 | "strings" 10 | "code.google.com/p/go-columnize" 11 | "github.com/rocky/go-fish" 12 | ) 13 | 14 | func init() { 15 | name := "help" 16 | repl.Cmds[name] = &repl.CmdInfo{ 17 | Fn: HelpCommand, 18 | Help: `help [*command* | * ] 19 | 20 | To evaluate an expression, just type the expression. 21 | 22 | If the first word of the line starts with a gofish command, then that 23 | takes precendence. For example, "help" is a gofish command. 24 | 25 | Typing "help *" will print a list of available gofish commands. 26 | 27 | When "help and an argument is given, if it is '*' a list of repl 28 | commands is shown. Otherwise the argument is checked to see if it is 29 | command name. For example 'help quit' gives help on the 'quit' 30 | debugger command. 31 | 32 | `, 33 | 34 | Min_args: 0, 35 | Max_args: 2, 36 | } 37 | repl.AddToCategory("support", name) 38 | repl.AddAlias("?", name) 39 | // Down the line we'll have abbrevs 40 | repl.AddAlias("h", name) 41 | } 42 | 43 | // HelpCommand implements the command: 44 | // help [*name* |* ] 45 | // which gives help. 46 | func HelpCommand(args []string) { 47 | if len(args) == 1 { 48 | repl.Msg(repl.Cmds["help"].Help) 49 | } else { 50 | what := args[1] 51 | cmd := repl.LookupCmd(what) 52 | if what == "*" { 53 | var names []string 54 | for k, _ := range repl.Cmds { 55 | names = append(names, k) 56 | } 57 | repl.Section("All command names:") 58 | sort.Strings(names) 59 | opts := columnize.DefaultOptions() 60 | opts.LinePrefix = " " 61 | opts.DisplayWidth = repl.Maxwidth 62 | mems := strings.TrimRight(columnize.Columnize(names, opts), 63 | "\n") 64 | repl.Msg(mems) 65 | } else if what == "categories" { 66 | repl.Section("Categories") 67 | for k, _ := range repl.Categories { 68 | repl.Msg("\t %s", k) 69 | } 70 | } else if info := repl.Cmds[cmd]; info != nil { 71 | // if len(args) > 2 { 72 | // if info.SubcmdMgr != nil { 73 | // repl.HelpSubCommand(info.SubcmdMgr, args) 74 | // return 75 | // } 76 | // } 77 | repl.Msg(info.Help) 78 | if len(info.Aliases) > 0 { 79 | repl.Msg("Aliases: %s", 80 | strings.Join(info.Aliases, ", ")) 81 | } 82 | } else if cmds := repl.Categories[what]; len(cmds) > 0 { 83 | repl.Section("Commands in class: %s", what) 84 | sort.Strings(cmds) 85 | opts := columnize.DefaultOptions() 86 | opts.DisplayWidth = repl.Maxwidth 87 | mems := strings.TrimRight(columnize.Columnize(cmds, opts), 88 | "\n") 89 | repl.Msg(mems) 90 | } else { 91 | repl.Errmsg("Can't find help for %s", what) 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /cmd/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Stub 6 | 7 | package fishcmd 8 | 9 | // Init is just a stub to call from the outside to allow 10 | // import not to complain and to force the rest of the init() 11 | // routines to run 12 | func Init() { 13 | } 14 | -------------------------------------------------------------------------------- /cmd/methods.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2015 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package fishcmd 6 | 7 | import ( 8 | "reflect" 9 | "strings" 10 | "github.com/rocky/eval" 11 | "github.com/rocky/go-fish" 12 | ) 13 | 14 | func init() { 15 | name := "method" 16 | repl.Cmds[name] = &repl.CmdInfo{ 17 | Fn: MethodCommand, 18 | Help: `method *package-type-or-value* [*package-type-or-value* ...] 19 | 20 | Show information about methods of a package, type, or value. 21 | 22 | If a type name is given, then information is given about the methods 23 | of that type. Likewise, if a value or package name is given, the methods 24 | of that value or package are given. 25 | `, 26 | 27 | Min_args: 1, 28 | Max_args: -1, // Max_args < 0 means an arbitrary number 29 | } 30 | repl.AddToCategory("support", name) 31 | repl.AddAlias("fn", name) 32 | repl.AddAlias("func", name) 33 | } 34 | 35 | func printMethodsOf(fullname string) { 36 | pkgName := "." 37 | name := fullname 38 | names := strings.Split(fullname, ".") 39 | pkg := repl.Env 40 | ok := true 41 | if len(names) > 1 { 42 | pkgName = names[0] 43 | name = names[1] 44 | pkg, ok = repl.Env.Pkg(pkgName).(*eval.SimpleEnv) 45 | if !ok || pkg == nil { 46 | repl.Errmsg("Can't find package %s", pkgName) 47 | return 48 | } 49 | } else { 50 | pkg, ok = repl.Env.Pkg(fullname).(*eval.SimpleEnv) 51 | if !ok || pkg == nil { 52 | repl.Errmsg("Can't find package %s", pkgName) 53 | return 54 | } 55 | fnNames := []string {} 56 | for name := range pkg.Funcs { 57 | fnNames = append(fnNames, name) 58 | } 59 | repl.PrintSorted("Functions of package " + fullname, fnNames) 60 | return 61 | } 62 | if v, ok := pkg.Vars[name]; ok { 63 | methods := map[string] reflect.Value {} 64 | for i:= 0; i < v.Type().NumMethod(); i++ { 65 | meth := v.Method(i) 66 | name := meth.Type().Name() 67 | if name != "" { 68 | methods[name] = v 69 | } 70 | } 71 | if len(methods) == 0 { 72 | repl.Msg("No methods found for variable %s", fullname) 73 | } else { 74 | printReflectMap("Methods for variable " + fullname, methods) 75 | } 76 | } else if v, ok := pkg.Types[name]; ok { 77 | if v == nil { 78 | repl.Errmsg("Don't have method info recorded for type %s", fullname) 79 | return 80 | } 81 | methods := map[string] reflect.Type {} 82 | for i:= 0; i < v.NumMethod(); i++ { 83 | meth := v.Method(i) 84 | name := meth.Name 85 | methods[name] = v 86 | } 87 | if len(methods) == 0 { 88 | repl.Msg("No methods found for type %s", fullname) 89 | } else { 90 | printReflectTypeMap("Methods for type " + fullname, methods) 91 | } 92 | } else { 93 | repl.Errmsg("Can't find member %s in package %s", name, pkgName) 94 | } 95 | } 96 | 97 | // MethodCommand implements the command: 98 | // method *name* [name*...] 99 | // which shows information about a package or lists all packages. 100 | func MethodCommand(args []string) { 101 | for _, name := range args[1:len(args)] { 102 | printMethodsOf(name) 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /cmd/packages.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2015 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package fishcmd 6 | 7 | import ( 8 | "reflect" 9 | "github.com/rocky/eval" 10 | "github.com/rocky/go-fish" 11 | ) 12 | 13 | func init() { 14 | name := "packages" 15 | repl.Cmds[name] = &repl.CmdInfo{ 16 | Fn: PackageCommand, 17 | Help: `packages [*package* [*package* ...] ] 18 | 19 | Show information about imported packages. 20 | 21 | If a package name is given, then detailed information is given about 22 | that package import. Otherwise we give a list of imported packages. 23 | `, 24 | 25 | Min_args: 0, 26 | Max_args: -1, // Max_args < 0 means an arbitrary number 27 | } 28 | repl.AddToCategory("support", name) 29 | repl.AddAlias("pkg", name) 30 | repl.AddAlias("pkgs", name) 31 | repl.AddAlias("package", name) 32 | } 33 | 34 | func printReflectMap(title string, m map[string] reflect.Value) { 35 | if len(m) > 0 { 36 | list := []string {} 37 | for item := range m { 38 | list = append(list, item) 39 | } 40 | repl.PrintSorted(title, list) 41 | } 42 | } 43 | 44 | func printReflectTypeMap(title string, m map[string] reflect.Type) { 45 | if len(m) > 0 { 46 | list := []string {} 47 | for item := range m { 48 | list = append(list, item) 49 | } 50 | repl.PrintSorted(title, list) 51 | } 52 | } 53 | 54 | // PackageCommand implements the command: 55 | // package [*name* [name*...]] 56 | // which shows information about a package or lists all packages. 57 | func PackageCommand(args []string) { 58 | if len(args) > 1 { 59 | for _, pkg_name := range args[1:len(args)] { 60 | 61 | pkg := repl.Env.Pkg(pkg_name) 62 | if pkg != nil { 63 | repl.Section("=== Package %s: ===", pkg_name) 64 | simplePkg := pkg.(*eval.SimpleEnv) 65 | printReflectMap("Constants of "+pkg_name, simplePkg.Consts) 66 | printReflectMap("Functions of "+pkg_name, simplePkg.Funcs) 67 | printReflectTypeMap("Types of "+pkg_name, simplePkg.Types) 68 | printReflectMap("Variables of "+pkg_name, simplePkg.Vars) 69 | } else { 70 | repl.Errmsg("Package %s not imported", pkg_name) 71 | } 72 | } 73 | } else { 74 | pkgNames := []string {} 75 | for pkg := range repl.Env.Pkgs { 76 | pkgNames = append(pkgNames, pkg) 77 | } 78 | repl.PrintSorted("All imported packages", pkgNames) 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /cmd/quit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // quit command 6 | 7 | package fishcmd 8 | 9 | import ( 10 | "strconv" 11 | "github.com/rocky/go-fish" 12 | ) 13 | 14 | func init() { 15 | name := "quit" 16 | repl.Cmds[name] = &repl.CmdInfo{ 17 | Fn: QuitCommand, 18 | Help: `quit [exit-code] 19 | 20 | Terminates program. If an exit code is given, that is the exit code 21 | for the program. Zero (normal termination) is used if no 22 | termintation code. 23 | `, 24 | 25 | Min_args: 0, 26 | Max_args: 1, 27 | } 28 | repl.AddToCategory("support", name) 29 | repl.Aliases["q"] = name 30 | } 31 | 32 | func QuitCommand(args []string) { 33 | rc := 0 34 | if len(args) == 2 { 35 | new_rc, ok := strconv.Atoi(args[1]) 36 | if ok == nil { rc = new_rc } else { 37 | repl.Errmsg("Expecting integer return code; got %s.", 38 | args[1]) 39 | return 40 | } 41 | } 42 | repl.Msg("go-fish: That's all folks...") 43 | 44 | repl.LeaveREPL = true 45 | repl.ExitCode = rc 46 | } 47 | -------------------------------------------------------------------------------- /cmd/set.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // set command 6 | 7 | package fishcmd 8 | 9 | import ( 10 | "github.com/rocky/go-fish" 11 | ) 12 | 13 | func init() { 14 | name := "set" 15 | repl.Cmds[name] = &repl.CmdInfo{ 16 | SubcmdMgr: &repl.SubcmdMgr{ 17 | Name : name, 18 | Subcmds: make(repl.SubcmdMap), 19 | }, 20 | Fn: SetCommand, 21 | Help: `Modifies parts of the REPL environment. 22 | 23 | Type "set" for a list of "set" subcommands and what they do. 24 | Type "help set *" for just a list of "set" subcommands. 25 | `, 26 | Min_args: 0, 27 | Max_args: 3, 28 | } 29 | repl.AddToCategory("support", name) 30 | } 31 | 32 | 33 | type onoff uint8 34 | const ( 35 | ONOFF_ON = iota 36 | ONOFF_OFF 37 | ONOFF_UNKNOWN 38 | ) 39 | 40 | func ParseOnOff(onoff string) onoff { 41 | switch onoff { 42 | case "on", "1", "yes": 43 | return ONOFF_ON 44 | case "off", "0", "none": 45 | return ONOFF_OFF 46 | default: 47 | return ONOFF_UNKNOWN 48 | } 49 | } 50 | 51 | func init() { 52 | parent := "set" 53 | repl.AddSubCommand(parent, &repl.SubcmdInfo{ 54 | Fn: SetHighlightSubcmd, 55 | Help: `Modifies parts of the debugger environment. 56 | 57 | You can give unique prefix of the name of a subcommand to get 58 | information about just that subcommand. 59 | 60 | Type "set" for a list of "set" subcommands and what they do.`, 61 | Min_args: 0, 62 | Max_args: 3, 63 | }) 64 | } 65 | 66 | // setCommand implements the debugger command: 67 | // set [*subcommand*] 68 | // which modifies parts of the debugger environment. 69 | func SetCommand(args []string) { 70 | repl.SubcmdMgrCommand(args) 71 | } 72 | -------------------------------------------------------------------------------- /cmd/set_highlight.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // set highlight - use terminal highlight? 6 | 7 | package fishcmd 8 | 9 | import ( 10 | "github.com/rocky/go-fish" 11 | ) 12 | 13 | func init() { 14 | parent := "set" 15 | repl.AddSubCommand(parent, &repl.SubcmdInfo{ 16 | Fn: SetHighlightSubcmd, 17 | Help: `set highlight [on|off] 18 | 19 | Sets whether terminal highlighting is to be used`, 20 | Min_args: 0, 21 | Max_args: 1, 22 | Short_help: "use terminal highlight", 23 | Name: "highlight", 24 | }) 25 | } 26 | 27 | func SetHighlightSubcmd(args []string) { 28 | onoff := "on" 29 | if len(args) == 3 { 30 | onoff = args[2] 31 | } 32 | switch ParseOnOff(onoff) { 33 | case ONOFF_ON: 34 | if *repl.Highlight { 35 | repl.Errmsg("Highlight is already on") 36 | } else { 37 | repl.Msg("Setting highlight on") 38 | *repl.Highlight = true 39 | } 40 | case ONOFF_OFF: 41 | if !*repl.Highlight { 42 | repl.Errmsg("highight is already off") 43 | } else { 44 | repl.Msg("Setting highlight off") 45 | *repl.Highlight = false 46 | } 47 | case ONOFF_UNKNOWN: 48 | repl.Msg("Expecting 'on' or 'off', got '%s'; nothing done", onoff) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /cmd/set_width.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // set width - set width of line 6 | 7 | package fishcmd 8 | 9 | import ( 10 | "github.com/rocky/go-fish" 11 | ) 12 | 13 | func init() { 14 | parent := "set" 15 | repl.AddSubCommand(parent, &repl.SubcmdInfo{ 16 | Fn: SetWidthSubcmd, 17 | Help: `set width num 18 | 19 | Sets the line length the REPL thinks we have`, 20 | Min_args: 1, 21 | Max_args: 1, 22 | Short_help: "set line width", 23 | Name: "width", 24 | }) 25 | } 26 | 27 | func SetWidthSubcmd(args []string) { 28 | i, err := repl.GetInt(args[2], "line width", 0, 10000) 29 | if err != nil { return } 30 | repl.Maxwidth = i 31 | ShowWidthSubcmd(args) 32 | } 33 | -------------------------------------------------------------------------------- /cmd/show.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // show command 6 | 7 | package fishcmd 8 | 9 | import ( 10 | "github.com/rocky/go-fish" 11 | ) 12 | 13 | func init() { 14 | name := "show" 15 | repl.Cmds[name] = &repl.CmdInfo{ 16 | SubcmdMgr: &repl.SubcmdMgr{ 17 | Name : name, 18 | Subcmds: make(repl.SubcmdMap), 19 | }, 20 | Fn: ShowCommand, 21 | Help: `Generic command for showing things about the debugger. 22 | 23 | Type "set" for a list of "set" subcommands and what they do. 24 | Type "help set *" for just a list of "info" subcommands.`, 25 | Min_args: 0, 26 | Max_args: 3, 27 | } 28 | repl.AddToCategory("support", name) 29 | } 30 | 31 | func init() { 32 | name := "show" 33 | repl.Cmds[name] = &repl.CmdInfo{ 34 | SubcmdMgr: &repl.SubcmdMgr{ 35 | Name : name, 36 | Subcmds: make(repl.SubcmdMap), 37 | }, 38 | Fn: ShowCommand, 39 | Help: `Show parts of the debugger environment. 40 | 41 | Type "show" for a list of "show" subcommands and what they do. 42 | Type "help show *" for just a list of "show" subcommands.`, 43 | Min_args: 0, 44 | Max_args: 3, 45 | } 46 | repl.AddToCategory("support", name) 47 | } 48 | 49 | func ShowOnOff(subcmdName string, on bool) { 50 | if on { 51 | repl.Msg("%s is on.", subcmdName) 52 | } else { 53 | repl.Msg("%s is off.", subcmdName) 54 | } 55 | } 56 | 57 | // show implements the debugger command: 58 | // show [*subcommand] 59 | // which is a generic command for setting things about the debugged program. 60 | func ShowCommand(args []string) { 61 | repl.SubcmdMgrCommand(args) 62 | } 63 | -------------------------------------------------------------------------------- /cmd/show_highlight.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // show highlight - whether to use terminal highlight? 6 | 7 | package fishcmd 8 | 9 | import ( 10 | "github.com/rocky/go-fish" 11 | ) 12 | 13 | func init() { 14 | parent := "show" 15 | repl.AddSubCommand(parent, &repl.SubcmdInfo{ 16 | Fn: ShowHighlightSubcmd, 17 | Help: `show highlight 18 | 19 | Show whether terminal highlighting is used`, 20 | Min_args: 0, 21 | Max_args: 0, 22 | Short_help: "show terminal highlight", 23 | Name: "highlight", 24 | }) 25 | } 26 | 27 | func ShowHighlightSubcmd(args []string) { 28 | ShowOnOff(args[1], *repl.Highlight) 29 | } 30 | -------------------------------------------------------------------------------- /cmd/show_width.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // set width - set width of line 6 | 7 | package fishcmd 8 | 9 | import ( 10 | "github.com/rocky/go-fish" 11 | ) 12 | 13 | func init() { 14 | parent := "show" 15 | repl.AddSubCommand(parent, &repl.SubcmdInfo{ 16 | Fn: ShowWidthSubcmd, 17 | Help: `show width 18 | 19 | Show the line length the REPL thinks we have`, 20 | Min_args: 0, 21 | Max_args: 0, 22 | Short_help: "show line width", 23 | Name: "width", 24 | }) 25 | } 26 | 27 | func ShowWidthSubcmd(args []string) { 28 | repl.Msg("Line width is %d", repl.Maxwidth) 29 | } 30 | -------------------------------------------------------------------------------- /cmd/whatis.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2015 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // whatis command 6 | 7 | package fishcmd 8 | 9 | import ( 10 | "strings" 11 | "go/parser" 12 | "github.com/rocky/go-fish" 13 | "github.com/rocky/eval" 14 | ) 15 | 16 | func init() { 17 | name := "whatis" 18 | repl.Cmds[name] = &repl.CmdInfo{ 19 | Fn: WhatisCommand, 20 | Help: `whatis expression 21 | 22 | Shows the type checker information for an expression. As a special 23 | cases 24 | if expression is a package name, we'll confirm that. 25 | if the expression is a type, we'll show reflect.Kind information 26 | `, 27 | 28 | Min_args: 0, 29 | Max_args: -1, 30 | } 31 | repl.AddToCategory("data", name) 32 | } 33 | 34 | func WhatisCommand(args []string) { 35 | if len(args) == 2 { 36 | arg := args[1] 37 | if _, ok := repl.Env.Pkg(arg).(*eval.SimpleEnv); ok { 38 | repl.Msg("`%s' is a package", arg) 39 | return 40 | } 41 | ids := strings.Split(arg, ".") 42 | if len(ids) == 1 { 43 | name := ids[0] 44 | if typ := repl.Env.Type(name); typ != nil { 45 | repl.Msg("%s is a type: %s", typ.String()) 46 | return 47 | } 48 | } 49 | if len(ids) == 2 { 50 | pkgName := ids[0] 51 | name := ids[1] 52 | if pkg, ok := repl.Env.Pkg(pkgName).(*eval.SimpleEnv); ok { 53 | if typ := pkg.Type(name); typ != nil { 54 | repl.Msg("%s is a kind: %s", arg, typ.Kind()) 55 | repl.Msg("%s is a type: %v", arg, typ) 56 | return 57 | } 58 | } 59 | } 60 | } 61 | line := repl.CmdLine[len(args[0]):len(repl.CmdLine)] 62 | if expr, err := parser.ParseExpr(line); err != nil { 63 | if pair := eval.FormatErrorPos(line, err.Error()); len(pair) == 2 { 64 | repl.Msg(pair[0]) 65 | repl.Msg(pair[1]) 66 | } 67 | repl.Errmsg("parse error: %s\n", err) 68 | } else if cexpr, errs := eval.CheckExpr(expr, repl.Env); len(errs) != 0 { 69 | for _, cerr := range errs { 70 | repl.Msg("%v", cerr) 71 | } 72 | } else { 73 | repl.Section(cexpr.String()) 74 | if cexpr.IsConst() { 75 | repl.Msg("constant:\t%s", cexpr.Const()) 76 | } 77 | knownTypes := cexpr.KnownType() 78 | if len(knownTypes) == 1{ 79 | repl.Msg("type:\t%s", knownTypes[0]) 80 | } else { 81 | for i, v := range knownTypes { 82 | repl.Msg("type[%d]:\t%s", i, v) 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /commands.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package repl 6 | 7 | type CmdFunc func([]string) 8 | 9 | type CmdInfo struct { 10 | Help string 11 | Category string 12 | Min_args int 13 | Max_args int 14 | Fn CmdFunc 15 | Aliases []string 16 | SubcmdMgr *SubcmdMgr 17 | } 18 | 19 | // Cmds contains a list of the top-level REPL commands we implement. 20 | // For example, "quit", and "help" are REPL commands. 21 | var Cmds map[string]*CmdInfo = make(map[string]*CmdInfo) 22 | 23 | 24 | // Aliases maps a name to its underlying gofish command name. 25 | // For example, "?" is an alias for "help". 26 | var Aliases map[string]string = make(map[string]string) 27 | 28 | // Categories maps a REPL category name into the list of 29 | // REPL commands in that category. 30 | var Categories map[string] []string = make(map[string] []string) 31 | 32 | // AddAlias adds "alias" for a command name "cmdname" 33 | func AddAlias(alias string, cmdname string) bool { 34 | if unalias := Aliases[alias]; unalias != "" { 35 | return false 36 | } 37 | Aliases[alias] = cmdname 38 | Cmds[cmdname].Aliases = append(Cmds[cmdname].Aliases, alias) 39 | return true 40 | } 41 | 42 | // AddToCategory adds "cmdname" into general category "category". 43 | func AddToCategory(category string, cmdname string) { 44 | Categories[category] = append(Categories[category], cmdname) 45 | // Cmds[cmdname].category = category 46 | } 47 | 48 | 49 | // LookupCmd canonicalize parameter cmd, by changing it to the underlying 50 | // gofish command if it is an alias. 51 | func LookupCmd(cmd string) (string) { 52 | if Cmds[cmd] == nil { 53 | cmd = Aliases[cmd]; 54 | } 55 | return cmd 56 | } 57 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | // Copyright 2013-2014 Rocky Bernstein 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package main 7 | 8 | // This is a simple REPL (read-eval-print loop) for Go. 9 | 10 | // (rocky) My intent here is to have something that I can debug in 11 | // the ssa-debugger tortoise/gub.sh. Right now that can't handle the 12 | // unsafe package, pointers, and calls to C code. So that let's out 13 | // go-gnureadline and lineedit. 14 | // See also main_gr.go for GNU readline code. 15 | import ( 16 | "bufio" 17 | "fmt" 18 | "os" 19 | "reflect" 20 | 21 | "github.com/rocky/go-fish" 22 | "github.com/rocky/go-fish/cmd" 23 | ) 24 | 25 | func intro_text() { 26 | repl.Section("== A simple Go eval REPL ==") 27 | fmt.Printf(` 28 | Results of expression are stored in variable slice "results". 29 | The environment is stored in global variable "env". 30 | Short form assignment, e.g. a, b := 1, 2, is supported. 31 | 32 | Enter expressions to be evaluated at the "gofish>" prompt. 33 | 34 | To see all results, type: "results". 35 | 36 | To quit, enter: "quit" or Ctrl-D (EOF). 37 | To get help, enter: "help". 38 | `) 39 | 40 | } 41 | 42 | // Set up the Go package, function, constant, variable environment; then REPL 43 | // (Read, Eval, Print, and Loop). 44 | func main() { 45 | 46 | // A place to store result values of expressions entered 47 | // interactively 48 | env := repl.MakeEvalEnv() 49 | 50 | // Make this truly self-referential 51 | env.Vars["env"] = reflect.ValueOf(env) 52 | 53 | intro_text() 54 | 55 | repl.Input = bufio.NewReader(os.Stdin) 56 | 57 | // Initialize REPL commands 58 | fishcmd.Init() 59 | 60 | repl.REPL(env, repl.SimpleReadLine, repl.SimpleInspect) 61 | os.Exit(repl.ExitCode) 62 | } 63 | -------------------------------------------------------------------------------- /main_grl.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | // Copyright 2013-2015 Rocky Bernstein 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package main 8 | 9 | // This simple REPL (read-eval-print loop) for Go using GNU Readline 10 | 11 | import ( 12 | "fmt" 13 | "os" 14 | "reflect" 15 | 16 | "github.com/rocky/go-gnureadline" 17 | "github.com/davecgh/go-spew/spew" 18 | "github.com/rocky/go-fish" 19 | "github.com/rocky/go-fish/cmd" 20 | ) 21 | 22 | func intro_text() { 23 | repl.Section("== A Go eval REPL with GNU Readline support ==") 24 | fmt.Printf(` 25 | Results of expression are stored in variable slice "results". 26 | The environment is stored in global variable "env". 27 | Short form assignment, e.g. a, b := 1, 2, is supported. 28 | 29 | Enter expressions to be evaluated at the "gofish>" prompt. 30 | 31 | To see all results, type: "results". 32 | 33 | To quit, enter: "quit" or Ctrl-D (EOF). 34 | To get help, enter: "help". 35 | `) 36 | 37 | } 38 | 39 | // history_file is file name where history entries were and are to be saved. If 40 | // the empty string, no history is saved and no history read in initially. 41 | var historyFile string 42 | 43 | // term is the current environment TERM value, e.g. "gnome", "xterm", or "vt100" 44 | var term string 45 | 46 | // gnuReadLineSetup is boilerplate initialization for GNU Readline. 47 | func gnuReadLineSetup() { 48 | term = os.Getenv("TERM") 49 | historyFile = repl.HistoryFile(".go-fish") 50 | if historyFile != "" { 51 | gnureadline.ReadHistory(historyFile) 52 | } 53 | // Set maximum number of history entries 54 | gnureadline.StifleHistory(100) 55 | } 56 | 57 | // gnuReadLineTermination has GNU Readline Termination tasks: 58 | // save history file if ane, and reset the terminal. 59 | func gnuReadLineTermination() { 60 | if historyFile != "" { 61 | gnureadline.WriteHistory(historyFile) 62 | } 63 | if term != "" { 64 | gnureadline.Rl_reset_terminal(term) 65 | } 66 | } 67 | 68 | func spewInspect(a ...interface{}) string { 69 | value := a[0].(reflect.Value) 70 | return spew.Sprint(value.Interface()) 71 | } 72 | 73 | 74 | 75 | // Set up the Go package, function, constant, variable environment; then REPL 76 | // (Read, Eval, Print, and Loop). 77 | func main() { 78 | 79 | // A place to store result values of expressions entered 80 | // interactively 81 | env := repl.MakeEvalEnv() 82 | 83 | // Make this truly self-referential 84 | env.Vars["env"] = reflect.ValueOf(env) 85 | 86 | intro_text() 87 | gnuReadLineSetup() 88 | 89 | defer gnuReadLineTermination() 90 | 91 | // Initialize REPL commands 92 | fishcmd.Init() 93 | 94 | repl.REPL(env, gnureadline.Readline, spewInspect) 95 | os.Exit(repl.ExitCode) 96 | } 97 | -------------------------------------------------------------------------------- /make_env.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2015 Rocky Bernstein. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // +build ignore 5 | 6 | // A tool for creating declarations that get fed into the REPL 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "go/ast" 12 | "go/build" 13 | "go/token" 14 | "log" 15 | "os" 16 | "sort" 17 | "strings" 18 | "unicode" 19 | "github.com/rocky/go-types" 20 | "github.com/rocky/go-loader" 21 | ) 22 | 23 | // StartingImport is the import from which we start gathering 24 | // package imports from. 25 | const DefaultStartingImport = "github.com/rocky/go-fish" 26 | const DefaultPackage = "repl" 27 | // const DefaultStartingImport = "github.com/0xfaded/eval" 28 | 29 | // MyImport is the import string name of this package that the output 30 | // Go code will live in. We have to treat that special because we 31 | // can't include it in an import which causes circular imports. Also, 32 | // variables in this import should not have the package name included 33 | // in it. For example we use refer to function SimpleReadline as 34 | // SimpleReadLine, not repl.SimpleReadline 35 | const MyImport = "github.com/rocky/go-fish" 36 | 37 | // excludeSyscallConst excludes "syscall" constants from the output. 38 | // "syscall" has architecture and/OS specific constants that make 39 | // it hard to test this program automatically. So unless specifically 40 | // asked for, we will exclude it by default. 41 | var excludeSyscallConsts bool = true 42 | 43 | // isExportedIdent returns false if e is an Ident with name "_". 44 | // These identifers have no associated types.Object, and thus no type. 45 | // isExportedIdent also returns false if identifier e doesn't start 46 | // with an uppercase character and thus is not exported. 47 | func isExportedIdent(e ast.Expr) bool { 48 | id, ok := e.(*ast.Ident) 49 | return !(ok && id.Name == "_") && unicode.IsUpper(rune(id.Name[0])) 50 | } 51 | 52 | func memberFromDecl(decl ast.Decl, program *loader.Program, 53 | consts []*string, funcs []*string, types []*string, vars []*string) ( 54 | []*string, []*string, []*string, []*string) { 55 | switch decl := decl.(type) { 56 | case *ast.GenDecl: // import, const, type or var 57 | switch decl.Tok { 58 | case token.CONST: 59 | for _, spec := range decl.Specs { 60 | for _, id := range spec.(*ast.ValueSpec).Names { 61 | if isExportedIdent(id) { 62 | consts = append(consts, &id.Name) 63 | } 64 | } 65 | } 66 | 67 | case token.VAR: 68 | for _, spec := range decl.Specs { 69 | for _, id := range spec.(*ast.ValueSpec).Names { 70 | if isExportedIdent(id) { 71 | vars = append(vars, &id.Name) 72 | } 73 | } 74 | } 75 | 76 | case token.TYPE: 77 | for _, spec := range decl.Specs { 78 | id := spec.(*ast.TypeSpec).Name 79 | if isExportedIdent(id) { 80 | types = append(types, &id.Name) 81 | } 82 | } 83 | } 84 | 85 | case *ast.FuncDecl: 86 | id := decl.Name 87 | if decl.Recv == nil && id.Name == "init" { 88 | return consts, funcs, types, vars 89 | } 90 | if isExportedIdent(id) && !strings.HasPrefix(id.Name, "Test") { 91 | // Can't handle receiver methods yet 92 | if decl.Recv == nil { 93 | filename := program.Fset.File(decl.Pos()).Name() 94 | if ! strings.HasSuffix(filename, "_test.go") { 95 | funcs = append(funcs, &id.Name) 96 | } 97 | } 98 | } 99 | } 100 | return consts, funcs, types, vars 101 | } 102 | 103 | func fullIdentName(path, pkg, ident string) (fullname string) { 104 | fullname = pkg + "." + ident 105 | if "repl" == pkg && MyImport == path { 106 | // This is me my package! We can't include repl 107 | fullname = ident 108 | } 109 | return fullname 110 | } 111 | 112 | func extractPackageSymbols(pkg_info *loader.PackageInfo, 113 | program *loader.Program) { 114 | 115 | typed_decls := map[string]string { 116 | "math.MaxInt64": "int64", 117 | "math.MaxUint16": "uint16", 118 | "math.MaxUint32": "uint32", 119 | "math.MaxUint64": "uint64", 120 | "math.MaxUint8": "uint8", 121 | "math.MinInt64": "int64", 122 | "syscall.CLONE_IO": "uint64", 123 | "syscall.IN_CLASSA_NET": "uint64", 124 | "syscall.IN_CLASSB_NET": "uint64", 125 | "syscall.IN_CLASSC_NET": "uint64", 126 | "syscall.IN_ONESHOT": "uint64", 127 | "syscall.LINUX_REBOOT_CMD_CAD_ON": "uint64", 128 | "syscall.LINUX_REBOOT_CMD_HALT": "uint64", 129 | "syscall.LINUX_REBOOT_CMD_RESTART2": "uint64", 130 | "syscall.LINUX_REBOOT_CMD_SW_SUSPEND": "uint64", 131 | "syscall.LINUX_REBOOT_MAGIC1": "uint64", 132 | "syscall.MS_MGC_MSK": "uint64", 133 | "syscall.MS_MGC_VAL": "uint64", 134 | "syscall.RTF_ADDRCLASSMASK": "uint64", 135 | "syscall.RTF_LOCAL": "uint64", 136 | "syscall.RT_TABLE_MAX": "uint64", 137 | "syscall.TIOCGDEV": "uint64", 138 | "syscall.TIOCGPTN": "uint64", 139 | "syscall.TUNGETFEATURES": "uint64", 140 | "syscall.TUNGETIFF": "uint64", 141 | "syscall.TUNGETSNDBUF": "uint64", 142 | "syscall.TUNGETVNETHDRSZ": "uint64", 143 | "syscall.WCLONE": "uint64", 144 | } 145 | 146 | name := pkg_info.Pkg.Name() 147 | path := pkg_info.Pkg.Path() 148 | if len(pkg_info.Files) > 0 { 149 | // Go source package. 150 | consts := make([]*string, 0, 10) 151 | vars := make([]*string, 0, 10) 152 | types := make([]*string, 0, 10) 153 | funcs := make([]*string, 0, 10) 154 | for _, file := range pkg_info.Files { 155 | for _, decl := range file.Decls { 156 | consts, funcs, types, vars = 157 | memberFromDecl(decl, program, consts, funcs, types, vars) 158 | } 159 | } 160 | fmt.Println("\tconsts = make(map[string] reflect.Value)") 161 | 162 | if name == "syscall" && excludeSyscallConsts { 163 | fmt.Println("\t//syscall constants excluded") 164 | } else { 165 | for _, v := range consts { 166 | fullname := fullIdentName(path, name, *v) 167 | if typename, found := typed_decls[fullname]; found { 168 | fmt.Printf("\tconsts[\"%s\"] = reflect.ValueOf(%s(%s))\n", 169 | *v, typename, fullname) 170 | } else { 171 | fmt.Printf("\tconsts[\"%s\"] = reflect.ValueOf(%s)\n", *v, fullname) 172 | } 173 | } 174 | } 175 | 176 | fmt.Println("\n\tfuncs = make(map[string] reflect.Value)") 177 | for _, v := range funcs { 178 | fullname := fullIdentName(path, name, *v) 179 | fmt.Printf("\tfuncs[\"%s\"] = reflect.ValueOf(%s)\n", *v, fullname) 180 | } 181 | 182 | fmt.Println("\n\ttypes = make(map[string] reflect.Type)") 183 | for _, v := range types { 184 | fullname := fullIdentName(path, name, *v) 185 | fmt.Printf("\ttypes[\"%s\"] = reflect.TypeOf(new(%s)).Elem()\n", 186 | *v, fullname) 187 | } 188 | 189 | fmt.Println("\n\tvars = make(map[string] reflect.Value)") 190 | for _, v := range vars { 191 | fullname := fullIdentName(path, name, *v) 192 | fmt.Printf("\tvars[\"%s\"] = reflect.ValueOf(&%s)\n", *v, 193 | fullname) 194 | } 195 | 196 | fmt.Printf(` pkgs["%s"] = &eval.SimpleEnv { 197 | Consts: consts, 198 | Funcs: funcs, 199 | Types: types, 200 | Vars: vars, 201 | Pkgs: pkgs, 202 | } 203 | `, name) 204 | } 205 | 206 | // } else { 207 | // // GC-compiled binary package. 208 | // // No code. 209 | // // No position information. 210 | // scope := p.Object.Scope() 211 | // for _, name := range scope.Names() { 212 | // obj := scope.Lookup(name) 213 | // memberFromObject(p, obj, nil) 214 | // if obj, ok := obj.(*types.TypeName); ok { 215 | // named := obj.Type().(*types.Named) 216 | // for i, n := 0, named.NumMethods(); i < n; i++ { 217 | // memberFromObject(p, named.Method(i), nil) 218 | // } 219 | // } 220 | // } 221 | 222 | 223 | } 224 | 225 | // By is the type of a "less" function that defines the ordering of 226 | // its Planet arguments. 227 | type By func(p1, p2 *loader.PackageInfo) bool 228 | 229 | // Sort is a method on the function type, By, that sorts the argument 230 | // slice according to the function. 231 | func (by By) Sort(pkg_infos []*loader.PackageInfo) { 232 | ps := &packageInfoSorter{ 233 | pkg_infos: pkg_infos, 234 | by: by, // The Sort method's receiver is the function (closure) that defines the sort order. 235 | } 236 | sort.Sort(ps) 237 | } 238 | 239 | // packageInfoSorter joins a By function and a slice of 240 | // importer.PackageInfos to be sorted. 241 | type packageInfoSorter struct { 242 | pkg_infos []*loader.PackageInfo 243 | by func(p1, p2 *loader.PackageInfo) bool // Closure used in the Less method. 244 | } 245 | 246 | // Len is part of sort.Interface. 247 | func (s *packageInfoSorter) Len() int { 248 | return len(s.pkg_infos) 249 | } 250 | 251 | // Swap is part of sort.Interface. 252 | // Swap is part of sort.Interface. 253 | func (s *packageInfoSorter) Swap(i, j int) { 254 | s.pkg_infos[i], s.pkg_infos[j] = s.pkg_infos[j], s.pkg_infos[i] 255 | } 256 | 257 | // Less is part of sort.Interface. It is implemented by calling the 258 | // "by" closure in the sorter. 259 | func (s *packageInfoSorter) Less(i, j int) bool { 260 | return s.by(s.pkg_infos[i], s.pkg_infos[j]) 261 | } 262 | 263 | // writePreamble prints the initial boiler-plate Go package code. That 264 | // is it starts out: 265 | // package repl; import (... ) 266 | // Packages that end in _test are removed from the list of imported 267 | // packages and this stripped down list is returned. 268 | func writePreamble(pkg_infos map[*types.Package]*loader.PackageInfo, 269 | name string, startingImport string, pkgName string) []*loader.PackageInfo { 270 | path := func(p1, p2 *loader.PackageInfo) bool { 271 | return p1.Pkg.Path() < p2.Pkg.Path() 272 | } 273 | pkg_infos2 := []*loader.PackageInfo {} 274 | for _,pi := range(pkg_infos) { 275 | pkg_infos2 = append(pkg_infos2, pi) 276 | } 277 | By(path).Sort(pkg_infos2) 278 | fmt.Printf(`package %s 279 | 280 | import ( 281 | `, pkgName) 282 | kept_pkgs := []*loader.PackageInfo {} 283 | for _, pkg_info := range pkg_infos2 { 284 | path := pkg_info.Pkg.Path() 285 | if !strings.HasSuffix(path, "_test") { 286 | if MyImport != path { 287 | fmt.Printf("\t\"%s\"\n", path) 288 | } 289 | kept_pkgs = append(kept_pkgs, pkg_info) 290 | } 291 | } 292 | fmt.Printf(`) 293 | 294 | // %sEnvironment adds to eval.Env those packages included 295 | // with import "%s". 296 | 297 | func %sEnvironment() *eval.SimpleEnv { 298 | var consts map[string] reflect.Value 299 | var vars map[string] reflect.Value 300 | var types map[string] reflect.Type 301 | var funcs map[string] reflect.Value 302 | var pkgs map[string] eval.Env = make(map[string] eval.Env) 303 | 304 | `, name, startingImport, name) 305 | return kept_pkgs 306 | } 307 | 308 | // writePostamble finishes of the Go code 309 | func writePostamble() { 310 | fmt.Printf(` 311 | mainEnv := eval.MakeSimpleEnv() 312 | mainEnv.Pkgs = pkgs 313 | return mainEnv 314 | }`) 315 | } 316 | 317 | // main creates a Go program that adds to a github.com/0xfaded/eval 318 | // environment (of type eval.Env) the transitive closure of imports 319 | // for a given starting package. Here we use github.com/0xfaded/eval. 320 | func main() { 321 | startingImport := DefaultStartingImport 322 | pkgName := DefaultPackage 323 | numArgs := len(os.Args) 324 | if numArgs == 2 { 325 | startingImport = os.Args[1] 326 | } else if numArgs == 3 { 327 | startingImport = os.Args[1] 328 | pkgName = os.Args[2] 329 | } else if numArgs > 3 { 330 | fmt.Printf("usage: %s [starting-import [package-name]]\n") 331 | os.Exit(1) 332 | } 333 | fmt.Printf("// starting import: \"%s\"\n", startingImport) 334 | 335 | importPkgs := map[string]bool{startingImport: false} 336 | 337 | 338 | config := loader.Config{ 339 | Build: &build.Default, 340 | SourceImports: true, 341 | ImportPkgs: importPkgs, 342 | } 343 | 344 | var pkgs_string []string = make([] string, 0, 10) 345 | pkgs_string = append(pkgs_string, startingImport) 346 | 347 | program, err := config.Load() 348 | if err != nil { 349 | log.Fatal(err) 350 | } 351 | 352 | var errpkgs []string 353 | 354 | pkg_infos := writePreamble(program.AllPackages, "Eval", 355 | startingImport, pkgName) 356 | 357 | for _, pkg_info := range pkg_infos { 358 | extractPackageSymbols(pkg_info, program) 359 | } 360 | if errpkgs != nil { 361 | log.Fatal("couldn't create these SSA packages due to type errors: %s", 362 | strings.Join(errpkgs, ", ")) 363 | } 364 | 365 | writePostamble() 366 | 367 | } 368 | -------------------------------------------------------------------------------- /make_env_test.go: -------------------------------------------------------------------------------- 1 | package repl_test 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | "os" 8 | "os/exec" 9 | "strings" 10 | "testing" 11 | ) 12 | 13 | const slash = string(os.PathSeparator) 14 | 15 | // Runs make_env and then compares output. 16 | func TestMakeEnv(t *testing.T) { 17 | 18 | got, err := exec.Command("go", "build", "-o", "make_env", "make_env.go").Output() 19 | if err != nil { 20 | fmt.Printf("Error running: go build -o make_env make_env.go: %s %s", got, err) 21 | log.Fatal(err) 22 | } 23 | 24 | got, err = exec.Command("./make_env", "strings").Output() 25 | if err != nil { 26 | fmt.Printf("Error running ./make_env: %s", got) 27 | log.Fatal(err) 28 | } 29 | 30 | 31 | rightFileName := fmt.Sprintf("testdata%sstring_imports.go", slash) 32 | 33 | var rightFile *os.File 34 | rightFile, err = os.Open(rightFileName) // For read access. 35 | if err != nil { 36 | log.Fatal(err) 37 | } 38 | 39 | data := make([]byte, 500000) 40 | count, err := rightFile.Read(data) 41 | if err != nil { 42 | t.Errorf("Failed to read 'right' data file %s:", rightFileName) 43 | log.Fatal(err) 44 | } 45 | want := string(data[0:count]) 46 | if string(got) != want { 47 | gotName := fmt.Sprintf("testdata%sstring_imports.got", slash) 48 | gotLines := strings.Split(string(got), "\n") 49 | wantLines := strings.Split(string(want), "\n") 50 | wantLen := len(wantLines) 51 | for i, line := range(gotLines) { 52 | if i == wantLen { 53 | fmt.Println("want results are shorter than got results, line", i+1) 54 | break 55 | } 56 | if line != wantLines[i] { 57 | fmt.Println("results differ starting at line", i+1) 58 | fmt.Println("got:\n", line) 59 | fmt.Println("want:\n", wantLines[i]) 60 | break 61 | } 62 | } 63 | if err := ioutil.WriteFile(gotName, got, 0666); err == nil { 64 | fmt.Printf("Full results are in file %s\n", gotName) 65 | } 66 | t.Errorf("make_env comparison test failed") 67 | } 68 | 69 | // Print a helpful hint if we don't make it to the end. 70 | hint := "Run manually" 71 | defer func() { 72 | if hint != "" { 73 | fmt.Println("FAIL") 74 | fmt.Println(hint) 75 | } else { 76 | fmt.Println("PASS") 77 | } 78 | }() 79 | 80 | hint = "" // call off the hounds 81 | return 82 | } 83 | -------------------------------------------------------------------------------- /msg.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package repl 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | "sort" 11 | "strings" 12 | 13 | "github.com/mgutz/ansi" 14 | "code.google.com/p/go-columnize" 15 | ) 16 | 17 | var termReset, termBold, termHighlight string 18 | 19 | func init() { 20 | termReset = ansi.ColorCode("reset") 21 | termBold = ansi.ColorCode("+b") 22 | termHighlight = ansi.ColorCode("+h") 23 | } 24 | 25 | func Errmsg(format string, a ...interface{}) (n int, err error) { 26 | if *Highlight { 27 | format = termHighlight + format + termReset + "\n" 28 | } else { 29 | format = "** " + format + "\n" 30 | } 31 | return fmt.Fprintf(os.Stdout, format, a...) 32 | } 33 | 34 | func MsgNoCr(format string, a ...interface{}) (n int, err error) { 35 | format = format 36 | return fmt.Fprintf(os.Stdout, format, a...) 37 | } 38 | 39 | func Msg(format string, a ...interface{}) (n int, err error) { 40 | format = format + "\n" 41 | return fmt.Fprintf(os.Stdout, format, a...) 42 | } 43 | 44 | // A more emphasized version of msg. For section headings. 45 | func Section(format string, a ...interface{}) (n int, err error) { 46 | if *Highlight { 47 | format = termBold + format + termReset + "\n" 48 | } else { 49 | format = format + "\n" 50 | } 51 | return fmt.Fprintf(os.Stdout, format, a...) 52 | } 53 | 54 | func PrintSorted(title string, names []string) { 55 | Section(title + ":") 56 | sort.Strings(names) 57 | opts := columnize.DefaultOptions() 58 | opts.LinePrefix = " " 59 | opts.DisplayWidth = Maxwidth 60 | columnizedNames := strings.TrimRight(columnize.Columnize(names, opts), 61 | "\n") 62 | Msg(columnizedNames) 63 | 64 | } 65 | -------------------------------------------------------------------------------- /preprocess.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // REPL Command processing 6 | 7 | package repl 8 | 9 | import ( 10 | "strings" 11 | ) 12 | 13 | var CmdLine string 14 | 15 | func wasProcessed(line string) bool { 16 | CmdLine = strings.Trim(line, " \t\n") 17 | args := strings.Split(CmdLine, " ") 18 | if len(args) == 0 || len(args[0]) == 0 { 19 | Msg("Empty line skipped") 20 | // gnureadline.RemoveHistory(gnureadline.HistoryLength()-1) 21 | return true 22 | } 23 | if args[0][0] == '/' && len(args) > 1 && args[0][1] == '/' { 24 | // gnureadline.RemoveHistory(gnureadline.HistoryLength()-1) 25 | Msg(line) // echo line but do nothing 26 | return true 27 | } 28 | 29 | name := args[0] 30 | if newname := LookupCmd(name); newname != "" { 31 | name = newname 32 | } 33 | cmd := Cmds[name]; 34 | 35 | if cmd != nil { 36 | if ArgCountOK(cmd.Min_args, cmd.Max_args, args) { 37 | Cmds[name].Fn(args) 38 | } 39 | return true 40 | } 41 | return false 42 | } 43 | -------------------------------------------------------------------------------- /repl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2015 Rocky Bernstein. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package go-fish is a simple REPL (read-eval-print loop) for GO using 6 | // http://github.com/0xfaded/eval to the heavy lifting to implement 7 | // the eval() part. 8 | // 9 | // Inside this package we provide two front-ends, one which uses GNU 10 | // Readline (http://code.google.com/p/go-gnureadline) and one which doesn't. 11 | // Feel free to add patches to support other kinds of readline support. 12 | // 13 | package repl 14 | 15 | // We separate this from the main package so that the main package 16 | // can provide its own readline function. This could be, for example, 17 | // GNU Readline, lineedit or something else. 18 | import ( 19 | "bufio" 20 | "flag" 21 | "fmt" 22 | "go/ast" 23 | "io" 24 | "os" 25 | "path/filepath" 26 | "reflect" 27 | "strconv" 28 | "strings" 29 | 30 | "github.com/rocky/eval" 31 | ) 32 | 33 | var Highlight = flag.Bool("highlight", true, `use syntax highlighting in output`) 34 | 35 | // Maxwidth is the size of the line. We will try to wrap text that is 36 | // longer than this. It like the COLUMNS environment variable 37 | var Maxwidth int 38 | 39 | // ReadLineFnType is function signature for a common read line 40 | // interface that we support. 41 | type ReadLineFnType func(prompt string, add_history ... bool) (string, error) 42 | var readLineFn ReadLineFnType 43 | 44 | type InspectFnType func(a ...interface{}) string 45 | 46 | 47 | var initial_cwd string 48 | 49 | // GOFISH_RESTART_CMD is a string that was used to invoke gofish. 50 | //If we want to restart gofish, this is what we'll use. 51 | var GOFISH_RESTART_CMD string 52 | 53 | 54 | // HistoryFile returns a string file name to use for saving command 55 | // history entries. 56 | func HistoryFile(history_basename string) string { 57 | home_dir := os.Getenv("HOME") 58 | if home_dir == "" { 59 | // FIXME: also try ~ ? 60 | fmt.Println("ignoring history file; environment variable HOME not set") 61 | return "" 62 | } 63 | history_file := filepath.Join(home_dir, history_basename) 64 | if fi, err := os.Stat(history_file); err != nil { 65 | fmt.Println("No history file found to read in: ", err.Error()) 66 | } else { 67 | if fi.IsDir() { 68 | Errmsg("Ignoring history file %s; is a directory, should be a file", 69 | history_file) 70 | return "" 71 | } 72 | } 73 | return history_file 74 | } 75 | 76 | // Input is a workaround for the fact that ReadLineFnType doesn't have 77 | // an input parameter, but SimpleReadLine below needs a 78 | // *bufioReader. So set this global variable beforehand if you are using 79 | // SimpleReadLine. 80 | var Input *bufio.Reader 81 | 82 | // SimpleReadLine is simple replacement for GNU readline. 83 | // prompt is the command prompt to print before reading input. 84 | // add_history is ignored, but provided as a parameter to match 85 | // those readline interfaces that do support saving command history. 86 | func SimpleReadLine(prompt string, add_history ... bool) (string, error) { 87 | fmt.Printf(prompt) 88 | line, err := Input.ReadString('\n') 89 | if err == nil { 90 | line = strings.TrimRight(line, "\r\n") 91 | } 92 | return line, err 93 | } 94 | 95 | func SimpleInspect(a ...interface{}) string { 96 | value := a[0].(reflect.Value) 97 | return eval.Inspect(value) 98 | } 99 | 100 | func init() { 101 | widthstr := os.Getenv("COLUMNS") 102 | initial_cwd, _ = os.Getwd() 103 | GOFISH_RESTART_CMD = os.Getenv("GOFISH_RESTART_CMD") 104 | if len(widthstr) == 0 { 105 | Maxwidth = 80 106 | } else if i, err := strconv.Atoi(widthstr); err == nil { 107 | Maxwidth = i 108 | } 109 | } 110 | 111 | // MakeEvalEnv creates an environment to use in evaluation. The 112 | // environment is exactly that environment needed by eval 113 | // automatically extracted from the package eval 114 | // (http://github.com/0xfaded/eval). 115 | func MakeEvalEnv() *eval.SimpleEnv { 116 | return EvalEnvironment() 117 | } 118 | 119 | // LeaveREPL is set when we want to quit. 120 | var LeaveREPL bool = false 121 | 122 | // ExitCode is the exit code this program will set on exit. 123 | var ExitCode int = 0 124 | 125 | // Env is the evaluation environment we are working with. 126 | var Env *eval.SimpleEnv 127 | 128 | // REPL is the read, eval, and print loop. 129 | func REPL(env *eval.SimpleEnv, readLineFn ReadLineFnType, inspectFn InspectFnType) { 130 | 131 | var err error 132 | 133 | // A place to store result values of expressions entered 134 | // interactively 135 | results := make([]interface{}, 0, 10) 136 | env.Vars["results"] = reflect.ValueOf(&results) 137 | 138 | Env = env 139 | exprs := 0 140 | line, err := readLineFn("gofish> ", true) 141 | for true { 142 | if err != nil { 143 | if err == io.EOF { break } 144 | panic(err) 145 | } 146 | if wasProcessed(line) { 147 | if LeaveREPL {break} 148 | line, err = readLineFn("gofish> ", true) 149 | continue 150 | } 151 | if stmt, err := eval.ParseStmt(line); err != nil { 152 | if pair := eval.FormatErrorPos(line, err.Error()); len(pair) == 2 { 153 | Msg(pair[0]) 154 | Msg(pair[1]) 155 | } 156 | Errmsg("parse error: %s", err) 157 | } else if expr, ok := stmt.(*ast.ExprStmt); ok { 158 | if cexpr, errs := eval.CheckExpr(expr.X, env); len(errs) != 0 { 159 | for _, cerr := range errs { 160 | Errmsg("%v", cerr) 161 | } 162 | } else if vals, err := eval.EvalExpr(cexpr, env); err != nil { 163 | Errmsg("panic: %s", err) 164 | } else if len(vals) == 0 { 165 | fmt.Printf("Kind=Slice\nvoid\n") 166 | } else if len(vals) == 1 { 167 | value := (vals)[0] 168 | if value.IsValid() { 169 | kind := value.Kind().String() 170 | typ := value.Type().String() 171 | if typ != kind { 172 | Msg("Kind = %v", kind) 173 | Msg("Type = %v", typ) 174 | } else { 175 | Msg("Kind = Type = %v", kind) 176 | } 177 | Msg("results[%d] = %s", exprs, inspectFn(value)) 178 | exprs += 1 179 | results = append(results, (vals)[0].Interface()) 180 | } else { 181 | Msg("%s", value) 182 | } 183 | } else { 184 | Msg("Kind = Multi-Value") 185 | size := len(vals) 186 | for i, v := range vals { 187 | fmt.Printf("%s", inspectFn(v)) 188 | if i < size-1 { fmt.Printf(", ") } 189 | } 190 | Msg("") 191 | exprs += 1 192 | results = append(results, vals) 193 | } 194 | } else { 195 | if cstmt, errs := eval.CheckStmt(stmt, env); len(errs) != 0 { 196 | for _, cerr := range errs { 197 | Errmsg("%v", cerr) 198 | } 199 | } else if _, err := eval.InterpStmt(cstmt, env); err != nil { 200 | Errmsg("panic: %s", err) 201 | } 202 | } 203 | line, err = readLineFn("gofish> ", true) 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /repl_imports.go: -------------------------------------------------------------------------------- 1 | // starting import: "github.com/rocky/go-fish" 2 | package repl 3 | 4 | import ( 5 | "bufio" 6 | "bytes" 7 | "code.google.com/p/go-columnize" 8 | "encoding/binary" 9 | "errors" 10 | "flag" 11 | "fmt" 12 | "github.com/0xfaded/reflectext" 13 | "github.com/mgutz/ansi" 14 | "github.com/rocky/eval" 15 | "go/ast" 16 | "go/parser" 17 | "go/scanner" 18 | "go/token" 19 | "io" 20 | "io/ioutil" 21 | "log" 22 | "math" 23 | "math/big" 24 | "math/rand" 25 | "os" 26 | "os/exec" 27 | "path/filepath" 28 | "reflect" 29 | "regexp" 30 | "regexp/syntax" 31 | "runtime" 32 | "runtime/pprof" 33 | "sort" 34 | "strconv" 35 | "strings" 36 | "sync" 37 | "sync/atomic" 38 | "syscall" 39 | "testing" 40 | "text/tabwriter" 41 | "time" 42 | "unicode" 43 | "unicode/utf8" 44 | ) 45 | 46 | // EvalEnvironment adds to eval.Env those packages included 47 | // with import "github.com/rocky/go-fish". 48 | 49 | func EvalEnvironment() *eval.SimpleEnv { 50 | var consts map[string] reflect.Value 51 | var vars map[string] reflect.Value 52 | var types map[string] reflect.Type 53 | var funcs map[string] reflect.Value 54 | var pkgs map[string] eval.Env = make(map[string] eval.Env) 55 | 56 | consts = make(map[string] reflect.Value) 57 | consts["MaxScanTokenSize"] = reflect.ValueOf(bufio.MaxScanTokenSize) 58 | 59 | funcs = make(map[string] reflect.Value) 60 | funcs["NewReaderSize"] = reflect.ValueOf(bufio.NewReaderSize) 61 | funcs["NewReader"] = reflect.ValueOf(bufio.NewReader) 62 | funcs["NewWriterSize"] = reflect.ValueOf(bufio.NewWriterSize) 63 | funcs["NewWriter"] = reflect.ValueOf(bufio.NewWriter) 64 | funcs["NewReadWriter"] = reflect.ValueOf(bufio.NewReadWriter) 65 | funcs["NewScanner"] = reflect.ValueOf(bufio.NewScanner) 66 | funcs["ScanBytes"] = reflect.ValueOf(bufio.ScanBytes) 67 | funcs["ScanRunes"] = reflect.ValueOf(bufio.ScanRunes) 68 | funcs["ScanLines"] = reflect.ValueOf(bufio.ScanLines) 69 | funcs["ScanWords"] = reflect.ValueOf(bufio.ScanWords) 70 | 71 | types = make(map[string] reflect.Type) 72 | types["Reader"] = reflect.TypeOf(new(bufio.Reader)).Elem() 73 | types["Writer"] = reflect.TypeOf(new(bufio.Writer)).Elem() 74 | types["ReadWriter"] = reflect.TypeOf(new(bufio.ReadWriter)).Elem() 75 | types["Scanner"] = reflect.TypeOf(new(bufio.Scanner)).Elem() 76 | types["SplitFunc"] = reflect.TypeOf(new(bufio.SplitFunc)).Elem() 77 | 78 | vars = make(map[string] reflect.Value) 79 | vars["ErrInvalidUnreadByte"] = reflect.ValueOf(&bufio.ErrInvalidUnreadByte) 80 | vars["ErrInvalidUnreadRune"] = reflect.ValueOf(&bufio.ErrInvalidUnreadRune) 81 | vars["ErrBufferFull"] = reflect.ValueOf(&bufio.ErrBufferFull) 82 | vars["ErrNegativeCount"] = reflect.ValueOf(&bufio.ErrNegativeCount) 83 | vars["ErrTooLong"] = reflect.ValueOf(&bufio.ErrTooLong) 84 | vars["ErrNegativeAdvance"] = reflect.ValueOf(&bufio.ErrNegativeAdvance) 85 | vars["ErrAdvanceTooFar"] = reflect.ValueOf(&bufio.ErrAdvanceTooFar) 86 | pkgs["bufio"] = &eval.SimpleEnv { 87 | Consts: consts, 88 | Funcs: funcs, 89 | Types: types, 90 | Vars: vars, 91 | Pkgs: pkgs, 92 | } 93 | consts = make(map[string] reflect.Value) 94 | consts["MinRead"] = reflect.ValueOf(bytes.MinRead) 95 | 96 | funcs = make(map[string] reflect.Value) 97 | funcs["NewBuffer"] = reflect.ValueOf(bytes.NewBuffer) 98 | funcs["NewBufferString"] = reflect.ValueOf(bytes.NewBufferString) 99 | funcs["Count"] = reflect.ValueOf(bytes.Count) 100 | funcs["Contains"] = reflect.ValueOf(bytes.Contains) 101 | funcs["Index"] = reflect.ValueOf(bytes.Index) 102 | funcs["LastIndex"] = reflect.ValueOf(bytes.LastIndex) 103 | funcs["IndexRune"] = reflect.ValueOf(bytes.IndexRune) 104 | funcs["IndexAny"] = reflect.ValueOf(bytes.IndexAny) 105 | funcs["LastIndexAny"] = reflect.ValueOf(bytes.LastIndexAny) 106 | funcs["SplitN"] = reflect.ValueOf(bytes.SplitN) 107 | funcs["SplitAfterN"] = reflect.ValueOf(bytes.SplitAfterN) 108 | funcs["Split"] = reflect.ValueOf(bytes.Split) 109 | funcs["SplitAfter"] = reflect.ValueOf(bytes.SplitAfter) 110 | funcs["Fields"] = reflect.ValueOf(bytes.Fields) 111 | funcs["FieldsFunc"] = reflect.ValueOf(bytes.FieldsFunc) 112 | funcs["Join"] = reflect.ValueOf(bytes.Join) 113 | funcs["HasPrefix"] = reflect.ValueOf(bytes.HasPrefix) 114 | funcs["HasSuffix"] = reflect.ValueOf(bytes.HasSuffix) 115 | funcs["Map"] = reflect.ValueOf(bytes.Map) 116 | funcs["Repeat"] = reflect.ValueOf(bytes.Repeat) 117 | funcs["ToUpper"] = reflect.ValueOf(bytes.ToUpper) 118 | funcs["ToLower"] = reflect.ValueOf(bytes.ToLower) 119 | funcs["ToTitle"] = reflect.ValueOf(bytes.ToTitle) 120 | funcs["ToUpperSpecial"] = reflect.ValueOf(bytes.ToUpperSpecial) 121 | funcs["ToLowerSpecial"] = reflect.ValueOf(bytes.ToLowerSpecial) 122 | funcs["ToTitleSpecial"] = reflect.ValueOf(bytes.ToTitleSpecial) 123 | funcs["Title"] = reflect.ValueOf(bytes.Title) 124 | funcs["TrimLeftFunc"] = reflect.ValueOf(bytes.TrimLeftFunc) 125 | funcs["TrimRightFunc"] = reflect.ValueOf(bytes.TrimRightFunc) 126 | funcs["TrimFunc"] = reflect.ValueOf(bytes.TrimFunc) 127 | funcs["TrimPrefix"] = reflect.ValueOf(bytes.TrimPrefix) 128 | funcs["TrimSuffix"] = reflect.ValueOf(bytes.TrimSuffix) 129 | funcs["IndexFunc"] = reflect.ValueOf(bytes.IndexFunc) 130 | funcs["LastIndexFunc"] = reflect.ValueOf(bytes.LastIndexFunc) 131 | funcs["Trim"] = reflect.ValueOf(bytes.Trim) 132 | funcs["TrimLeft"] = reflect.ValueOf(bytes.TrimLeft) 133 | funcs["TrimRight"] = reflect.ValueOf(bytes.TrimRight) 134 | funcs["TrimSpace"] = reflect.ValueOf(bytes.TrimSpace) 135 | funcs["Runes"] = reflect.ValueOf(bytes.Runes) 136 | funcs["Replace"] = reflect.ValueOf(bytes.Replace) 137 | funcs["EqualFold"] = reflect.ValueOf(bytes.EqualFold) 138 | funcs["IndexByte"] = reflect.ValueOf(bytes.IndexByte) 139 | funcs["Equal"] = reflect.ValueOf(bytes.Equal) 140 | funcs["Compare"] = reflect.ValueOf(bytes.Compare) 141 | funcs["NewReader"] = reflect.ValueOf(bytes.NewReader) 142 | 143 | types = make(map[string] reflect.Type) 144 | types["Buffer"] = reflect.TypeOf(new(bytes.Buffer)).Elem() 145 | types["Reader"] = reflect.TypeOf(new(bytes.Reader)).Elem() 146 | 147 | vars = make(map[string] reflect.Value) 148 | vars["ErrTooLarge"] = reflect.ValueOf(&bytes.ErrTooLarge) 149 | pkgs["bytes"] = &eval.SimpleEnv { 150 | Consts: consts, 151 | Funcs: funcs, 152 | Types: types, 153 | Vars: vars, 154 | Pkgs: pkgs, 155 | } 156 | consts = make(map[string] reflect.Value) 157 | consts["VERSION"] = reflect.ValueOf(columnize.VERSION) 158 | 159 | funcs = make(map[string] reflect.Value) 160 | funcs["DefaultOptions"] = reflect.ValueOf(columnize.DefaultOptions) 161 | funcs["SetOptions"] = reflect.ValueOf(columnize.SetOptions) 162 | funcs["CellSize"] = reflect.ValueOf(columnize.CellSize) 163 | funcs["ToStringSliceFromIndexable"] = reflect.ValueOf(columnize.ToStringSliceFromIndexable) 164 | funcs["ToStringSlice"] = reflect.ValueOf(columnize.ToStringSlice) 165 | funcs["Columnize"] = reflect.ValueOf(columnize.Columnize) 166 | funcs["ColumnizeS"] = reflect.ValueOf(columnize.ColumnizeS) 167 | 168 | types = make(map[string] reflect.Type) 169 | types["Opts_t"] = reflect.TypeOf(new(columnize.Opts_t)).Elem() 170 | types["KeyValuePair_t"] = reflect.TypeOf(new(columnize.KeyValuePair_t)).Elem() 171 | 172 | vars = make(map[string] reflect.Value) 173 | pkgs["columnize"] = &eval.SimpleEnv { 174 | Consts: consts, 175 | Funcs: funcs, 176 | Types: types, 177 | Vars: vars, 178 | Pkgs: pkgs, 179 | } 180 | consts = make(map[string] reflect.Value) 181 | consts["MaxVarintLen16"] = reflect.ValueOf(binary.MaxVarintLen16) 182 | consts["MaxVarintLen32"] = reflect.ValueOf(binary.MaxVarintLen32) 183 | consts["MaxVarintLen64"] = reflect.ValueOf(binary.MaxVarintLen64) 184 | 185 | funcs = make(map[string] reflect.Value) 186 | funcs["Read"] = reflect.ValueOf(binary.Read) 187 | funcs["Write"] = reflect.ValueOf(binary.Write) 188 | funcs["Size"] = reflect.ValueOf(binary.Size) 189 | funcs["PutUvarint"] = reflect.ValueOf(binary.PutUvarint) 190 | funcs["Uvarint"] = reflect.ValueOf(binary.Uvarint) 191 | funcs["PutVarint"] = reflect.ValueOf(binary.PutVarint) 192 | funcs["Varint"] = reflect.ValueOf(binary.Varint) 193 | funcs["ReadUvarint"] = reflect.ValueOf(binary.ReadUvarint) 194 | funcs["ReadVarint"] = reflect.ValueOf(binary.ReadVarint) 195 | 196 | types = make(map[string] reflect.Type) 197 | types["ByteOrder"] = reflect.TypeOf(new(binary.ByteOrder)).Elem() 198 | 199 | vars = make(map[string] reflect.Value) 200 | vars["LittleEndian"] = reflect.ValueOf(&binary.LittleEndian) 201 | vars["BigEndian"] = reflect.ValueOf(&binary.BigEndian) 202 | pkgs["binary"] = &eval.SimpleEnv { 203 | Consts: consts, 204 | Funcs: funcs, 205 | Types: types, 206 | Vars: vars, 207 | Pkgs: pkgs, 208 | } 209 | consts = make(map[string] reflect.Value) 210 | 211 | funcs = make(map[string] reflect.Value) 212 | funcs["New"] = reflect.ValueOf(errors.New) 213 | 214 | types = make(map[string] reflect.Type) 215 | 216 | vars = make(map[string] reflect.Value) 217 | pkgs["errors"] = &eval.SimpleEnv { 218 | Consts: consts, 219 | Funcs: funcs, 220 | Types: types, 221 | Vars: vars, 222 | Pkgs: pkgs, 223 | } 224 | consts = make(map[string] reflect.Value) 225 | consts["ContinueOnError"] = reflect.ValueOf(flag.ContinueOnError) 226 | consts["ExitOnError"] = reflect.ValueOf(flag.ExitOnError) 227 | consts["PanicOnError"] = reflect.ValueOf(flag.PanicOnError) 228 | 229 | funcs = make(map[string] reflect.Value) 230 | funcs["VisitAll"] = reflect.ValueOf(flag.VisitAll) 231 | funcs["Visit"] = reflect.ValueOf(flag.Visit) 232 | funcs["Lookup"] = reflect.ValueOf(flag.Lookup) 233 | funcs["Set"] = reflect.ValueOf(flag.Set) 234 | funcs["PrintDefaults"] = reflect.ValueOf(flag.PrintDefaults) 235 | funcs["NFlag"] = reflect.ValueOf(flag.NFlag) 236 | funcs["Arg"] = reflect.ValueOf(flag.Arg) 237 | funcs["NArg"] = reflect.ValueOf(flag.NArg) 238 | funcs["Args"] = reflect.ValueOf(flag.Args) 239 | funcs["BoolVar"] = reflect.ValueOf(flag.BoolVar) 240 | funcs["Bool"] = reflect.ValueOf(flag.Bool) 241 | funcs["IntVar"] = reflect.ValueOf(flag.IntVar) 242 | funcs["Int"] = reflect.ValueOf(flag.Int) 243 | funcs["Int64Var"] = reflect.ValueOf(flag.Int64Var) 244 | funcs["Int64"] = reflect.ValueOf(flag.Int64) 245 | funcs["UintVar"] = reflect.ValueOf(flag.UintVar) 246 | funcs["Uint"] = reflect.ValueOf(flag.Uint) 247 | funcs["Uint64Var"] = reflect.ValueOf(flag.Uint64Var) 248 | funcs["Uint64"] = reflect.ValueOf(flag.Uint64) 249 | funcs["StringVar"] = reflect.ValueOf(flag.StringVar) 250 | funcs["String"] = reflect.ValueOf(flag.String) 251 | funcs["Float64Var"] = reflect.ValueOf(flag.Float64Var) 252 | funcs["Float64"] = reflect.ValueOf(flag.Float64) 253 | funcs["DurationVar"] = reflect.ValueOf(flag.DurationVar) 254 | funcs["Duration"] = reflect.ValueOf(flag.Duration) 255 | funcs["Var"] = reflect.ValueOf(flag.Var) 256 | funcs["Parse"] = reflect.ValueOf(flag.Parse) 257 | funcs["Parsed"] = reflect.ValueOf(flag.Parsed) 258 | funcs["NewFlagSet"] = reflect.ValueOf(flag.NewFlagSet) 259 | 260 | types = make(map[string] reflect.Type) 261 | types["Value"] = reflect.TypeOf(new(flag.Value)).Elem() 262 | types["Getter"] = reflect.TypeOf(new(flag.Getter)).Elem() 263 | types["ErrorHandling"] = reflect.TypeOf(new(flag.ErrorHandling)).Elem() 264 | types["FlagSet"] = reflect.TypeOf(new(flag.FlagSet)).Elem() 265 | types["Flag"] = reflect.TypeOf(new(flag.Flag)).Elem() 266 | 267 | vars = make(map[string] reflect.Value) 268 | vars["ErrHelp"] = reflect.ValueOf(&flag.ErrHelp) 269 | vars["Usage"] = reflect.ValueOf(&flag.Usage) 270 | vars["CommandLine"] = reflect.ValueOf(&flag.CommandLine) 271 | pkgs["flag"] = &eval.SimpleEnv { 272 | Consts: consts, 273 | Funcs: funcs, 274 | Types: types, 275 | Vars: vars, 276 | Pkgs: pkgs, 277 | } 278 | consts = make(map[string] reflect.Value) 279 | 280 | funcs = make(map[string] reflect.Value) 281 | funcs["Fprintf"] = reflect.ValueOf(fmt.Fprintf) 282 | funcs["Printf"] = reflect.ValueOf(fmt.Printf) 283 | funcs["Sprintf"] = reflect.ValueOf(fmt.Sprintf) 284 | funcs["Errorf"] = reflect.ValueOf(fmt.Errorf) 285 | funcs["Fprint"] = reflect.ValueOf(fmt.Fprint) 286 | funcs["Print"] = reflect.ValueOf(fmt.Print) 287 | funcs["Sprint"] = reflect.ValueOf(fmt.Sprint) 288 | funcs["Fprintln"] = reflect.ValueOf(fmt.Fprintln) 289 | funcs["Println"] = reflect.ValueOf(fmt.Println) 290 | funcs["Sprintln"] = reflect.ValueOf(fmt.Sprintln) 291 | funcs["Scan"] = reflect.ValueOf(fmt.Scan) 292 | funcs["Scanln"] = reflect.ValueOf(fmt.Scanln) 293 | funcs["Scanf"] = reflect.ValueOf(fmt.Scanf) 294 | funcs["Sscan"] = reflect.ValueOf(fmt.Sscan) 295 | funcs["Sscanln"] = reflect.ValueOf(fmt.Sscanln) 296 | funcs["Sscanf"] = reflect.ValueOf(fmt.Sscanf) 297 | funcs["Fscan"] = reflect.ValueOf(fmt.Fscan) 298 | funcs["Fscanln"] = reflect.ValueOf(fmt.Fscanln) 299 | funcs["Fscanf"] = reflect.ValueOf(fmt.Fscanf) 300 | 301 | types = make(map[string] reflect.Type) 302 | types["State"] = reflect.TypeOf(new(fmt.State)).Elem() 303 | types["Formatter"] = reflect.TypeOf(new(fmt.Formatter)).Elem() 304 | types["Stringer"] = reflect.TypeOf(new(fmt.Stringer)).Elem() 305 | types["GoStringer"] = reflect.TypeOf(new(fmt.GoStringer)).Elem() 306 | types["ScanState"] = reflect.TypeOf(new(fmt.ScanState)).Elem() 307 | types["Scanner"] = reflect.TypeOf(new(fmt.Scanner)).Elem() 308 | 309 | vars = make(map[string] reflect.Value) 310 | pkgs["fmt"] = &eval.SimpleEnv { 311 | Consts: consts, 312 | Funcs: funcs, 313 | Types: types, 314 | Vars: vars, 315 | Pkgs: pkgs, 316 | } 317 | consts = make(map[string] reflect.Value) 318 | 319 | funcs = make(map[string] reflect.Value) 320 | funcs["FuncOf"] = reflect.ValueOf(reflectext.FuncOf) 321 | funcs["InterfaceOf"] = reflect.ValueOf(reflectext.InterfaceOf) 322 | funcs["StructOf"] = reflect.ValueOf(reflectext.StructOf) 323 | funcs["ArrayOf"] = reflect.ValueOf(reflectext.ArrayOf) 324 | funcs["Name"] = reflect.ValueOf(reflectext.Name) 325 | 326 | types = make(map[string] reflect.Type) 327 | 328 | vars = make(map[string] reflect.Value) 329 | vars["Available"] = reflect.ValueOf(&reflectext.Available) 330 | pkgs["reflectext"] = &eval.SimpleEnv { 331 | Consts: consts, 332 | Funcs: funcs, 333 | Types: types, 334 | Vars: vars, 335 | Pkgs: pkgs, 336 | } 337 | consts = make(map[string] reflect.Value) 338 | consts["Reset"] = reflect.ValueOf(ansi.Reset) 339 | 340 | funcs = make(map[string] reflect.Value) 341 | funcs["ColorCode"] = reflect.ValueOf(ansi.ColorCode) 342 | funcs["Color"] = reflect.ValueOf(ansi.Color) 343 | funcs["ColorFunc"] = reflect.ValueOf(ansi.ColorFunc) 344 | funcs["DisableColors"] = reflect.ValueOf(ansi.DisableColors) 345 | 346 | types = make(map[string] reflect.Type) 347 | 348 | vars = make(map[string] reflect.Value) 349 | pkgs["ansi"] = &eval.SimpleEnv { 350 | Consts: consts, 351 | Funcs: funcs, 352 | Types: types, 353 | Vars: vars, 354 | Pkgs: pkgs, 355 | } 356 | consts = make(map[string] reflect.Value) 357 | consts["EnvUnknown"] = reflect.ValueOf(eval.EnvUnknown) 358 | consts["EnvVar"] = reflect.ValueOf(eval.EnvVar) 359 | consts["EnvFunc"] = reflect.ValueOf(eval.EnvFunc) 360 | consts["EnvConst"] = reflect.ValueOf(eval.EnvConst) 361 | 362 | funcs = make(map[string] reflect.Value) 363 | funcs["ConstValueOf"] = reflect.ValueOf(eval.ConstValueOf) 364 | funcs["SetCheckIdent"] = reflect.ValueOf(eval.SetCheckIdent) 365 | funcs["SetEvalIdent"] = reflect.ValueOf(eval.SetEvalIdent) 366 | funcs["SetCheckSelectorExpr"] = reflect.ValueOf(eval.SetCheckSelectorExpr) 367 | funcs["SetEvalSelectorExpr"] = reflect.ValueOf(eval.SetEvalSelectorExpr) 368 | funcs["CheckExpr"] = reflect.ValueOf(eval.CheckExpr) 369 | funcs["CheckIdent"] = reflect.ValueOf(eval.CheckIdent) 370 | funcs["CheckSelectorExpr"] = reflect.ValueOf(eval.CheckSelectorExpr) 371 | funcs["CheckStmt"] = reflect.ValueOf(eval.CheckStmt) 372 | funcs["NewConstInteger"] = reflect.ValueOf(eval.NewConstInteger) 373 | funcs["NewConstFloat"] = reflect.ValueOf(eval.NewConstFloat) 374 | funcs["NewConstImag"] = reflect.ValueOf(eval.NewConstImag) 375 | funcs["NewConstRune"] = reflect.ValueOf(eval.NewConstRune) 376 | funcs["NewConstInt64"] = reflect.ValueOf(eval.NewConstInt64) 377 | funcs["NewConstUint64"] = reflect.ValueOf(eval.NewConstUint64) 378 | funcs["NewConstFloat64"] = reflect.ValueOf(eval.NewConstFloat64) 379 | funcs["NewConstComplex128"] = reflect.ValueOf(eval.NewConstComplex128) 380 | funcs["MakeSimpleEnv"] = reflect.ValueOf(eval.MakeSimpleEnv) 381 | funcs["Eval"] = reflect.ValueOf(eval.Eval) 382 | funcs["EvalEnv"] = reflect.ValueOf(eval.EvalEnv) 383 | funcs["Interpret"] = reflect.ValueOf(eval.Interpret) 384 | funcs["ParseStmt"] = reflect.ValueOf(eval.ParseStmt) 385 | funcs["EvalExpr"] = reflect.ValueOf(eval.EvalExpr) 386 | funcs["EvalIdent"] = reflect.ValueOf(eval.EvalIdent) 387 | funcs["EvalSelectorExpr"] = reflect.ValueOf(eval.EvalSelectorExpr) 388 | funcs["Inspect"] = reflect.ValueOf(eval.Inspect) 389 | funcs["InspectShort"] = reflect.ValueOf(eval.InspectShort) 390 | funcs["InterpStmt"] = reflect.ValueOf(eval.InterpStmt) 391 | funcs["FormatErrorPos"] = reflect.ValueOf(eval.FormatErrorPos) 392 | 393 | types = make(map[string] reflect.Type) 394 | types["Expr"] = reflect.TypeOf(new(eval.Expr)).Elem() 395 | types["Stmt"] = reflect.TypeOf(new(eval.Stmt)).Elem() 396 | types["BadExpr"] = reflect.TypeOf(new(eval.BadExpr)).Elem() 397 | types["Ident"] = reflect.TypeOf(new(eval.Ident)).Elem() 398 | types["Ellipsis"] = reflect.TypeOf(new(eval.Ellipsis)).Elem() 399 | types["BasicLit"] = reflect.TypeOf(new(eval.BasicLit)).Elem() 400 | types["FuncLit"] = reflect.TypeOf(new(eval.FuncLit)).Elem() 401 | types["CompositeLit"] = reflect.TypeOf(new(eval.CompositeLit)).Elem() 402 | types["ParenExpr"] = reflect.TypeOf(new(eval.ParenExpr)).Elem() 403 | types["SelectorExpr"] = reflect.TypeOf(new(eval.SelectorExpr)).Elem() 404 | types["IndexExpr"] = reflect.TypeOf(new(eval.IndexExpr)).Elem() 405 | types["SliceExpr"] = reflect.TypeOf(new(eval.SliceExpr)).Elem() 406 | types["TypeAssertExpr"] = reflect.TypeOf(new(eval.TypeAssertExpr)).Elem() 407 | types["CallExpr"] = reflect.TypeOf(new(eval.CallExpr)).Elem() 408 | types["StarExpr"] = reflect.TypeOf(new(eval.StarExpr)).Elem() 409 | types["UnaryExpr"] = reflect.TypeOf(new(eval.UnaryExpr)).Elem() 410 | types["BinaryExpr"] = reflect.TypeOf(new(eval.BinaryExpr)).Elem() 411 | types["KeyValueExpr"] = reflect.TypeOf(new(eval.KeyValueExpr)).Elem() 412 | types["ArrayType"] = reflect.TypeOf(new(eval.ArrayType)).Elem() 413 | types["StructType"] = reflect.TypeOf(new(eval.StructType)).Elem() 414 | types["FuncType"] = reflect.TypeOf(new(eval.FuncType)).Elem() 415 | types["InterfaceType"] = reflect.TypeOf(new(eval.InterfaceType)).Elem() 416 | types["MapType"] = reflect.TypeOf(new(eval.MapType)).Elem() 417 | types["ChanType"] = reflect.TypeOf(new(eval.ChanType)).Elem() 418 | types["Field"] = reflect.TypeOf(new(eval.Field)).Elem() 419 | types["FieldList"] = reflect.TypeOf(new(eval.FieldList)).Elem() 420 | types["AssignStmt"] = reflect.TypeOf(new(eval.AssignStmt)).Elem() 421 | types["BranchStmt"] = reflect.TypeOf(new(eval.BranchStmt)).Elem() 422 | types["CaseClause"] = reflect.TypeOf(new(eval.CaseClause)).Elem() 423 | types["BlockStmt"] = reflect.TypeOf(new(eval.BlockStmt)).Elem() 424 | types["EmptyStmt"] = reflect.TypeOf(new(eval.EmptyStmt)).Elem() 425 | types["ExprStmt"] = reflect.TypeOf(new(eval.ExprStmt)).Elem() 426 | types["IfStmt"] = reflect.TypeOf(new(eval.IfStmt)).Elem() 427 | types["LabeledStmt"] = reflect.TypeOf(new(eval.LabeledStmt)).Elem() 428 | types["ForStmt"] = reflect.TypeOf(new(eval.ForStmt)).Elem() 429 | types["ReturnStmt"] = reflect.TypeOf(new(eval.ReturnStmt)).Elem() 430 | types["SwitchStmt"] = reflect.TypeOf(new(eval.SwitchStmt)).Elem() 431 | types["TypeSwitchStmt"] = reflect.TypeOf(new(eval.TypeSwitchStmt)).Elem() 432 | types["BigComplex"] = reflect.TypeOf(new(eval.BigComplex)).Elem() 433 | types["Byte"] = reflect.TypeOf(new(eval.Byte)).Elem() 434 | types["CheckIdentFn"] = reflect.TypeOf(new(eval.CheckIdentFn)).Elem() 435 | types["EvalIdentFn"] = reflect.TypeOf(new(eval.EvalIdentFn)).Elem() 436 | types["CheckSelectorExprFn"] = reflect.TypeOf(new(eval.CheckSelectorExprFn)).Elem() 437 | types["EvalSelectorExprFn"] = reflect.TypeOf(new(eval.EvalSelectorExprFn)).Elem() 438 | types["ConstNumber"] = reflect.TypeOf(new(eval.ConstNumber)).Elem() 439 | types["ConstType"] = reflect.TypeOf(new(eval.ConstType)).Elem() 440 | types["ConstIntType"] = reflect.TypeOf(new(eval.ConstIntType)).Elem() 441 | types["ConstShiftedIntType"] = reflect.TypeOf(new(eval.ConstShiftedIntType)).Elem() 442 | types["ConstRuneType"] = reflect.TypeOf(new(eval.ConstRuneType)).Elem() 443 | types["ConstFloatType"] = reflect.TypeOf(new(eval.ConstFloatType)).Elem() 444 | types["ConstComplexType"] = reflect.TypeOf(new(eval.ConstComplexType)).Elem() 445 | types["ConstStringType"] = reflect.TypeOf(new(eval.ConstStringType)).Elem() 446 | types["ConstNilType"] = reflect.TypeOf(new(eval.ConstNilType)).Elem() 447 | types["ConstBoolType"] = reflect.TypeOf(new(eval.ConstBoolType)).Elem() 448 | types["EnvSource"] = reflect.TypeOf(new(eval.EnvSource)).Elem() 449 | types["Env"] = reflect.TypeOf(new(eval.Env)).Elem() 450 | types["SimpleEnv"] = reflect.TypeOf(new(eval.SimpleEnv)).Elem() 451 | types["ErrBadBasicLit"] = reflect.TypeOf(new(eval.ErrBadBasicLit)).Elem() 452 | types["ErrUndefined"] = reflect.TypeOf(new(eval.ErrUndefined)).Elem() 453 | types["ErrInvalidIndirect"] = reflect.TypeOf(new(eval.ErrInvalidIndirect)).Elem() 454 | types["ErrUndefinedFieldOrMethod"] = reflect.TypeOf(new(eval.ErrUndefinedFieldOrMethod)).Elem() 455 | types["ErrCallNonFuncType"] = reflect.TypeOf(new(eval.ErrCallNonFuncType)).Elem() 456 | types["ErrDuplicateArg"] = reflect.TypeOf(new(eval.ErrDuplicateArg)).Elem() 457 | types["ErrBadReturnValue"] = reflect.TypeOf(new(eval.ErrBadReturnValue)).Elem() 458 | types["ErrWrongNumberOfReturnValues"] = reflect.TypeOf(new(eval.ErrWrongNumberOfReturnValues)).Elem() 459 | types["ErrWrongNumberOfArgs"] = reflect.TypeOf(new(eval.ErrWrongNumberOfArgs)).Elem() 460 | types["ErrWrongArgType"] = reflect.TypeOf(new(eval.ErrWrongArgType)).Elem() 461 | types["ErrInvalidEllipsisInCall"] = reflect.TypeOf(new(eval.ErrInvalidEllipsisInCall)).Elem() 462 | types["ErrMissingValue"] = reflect.TypeOf(new(eval.ErrMissingValue)).Elem() 463 | types["ErrMultiInSingleContext"] = reflect.TypeOf(new(eval.ErrMultiInSingleContext)).Elem() 464 | types["ErrBadMapIndex"] = reflect.TypeOf(new(eval.ErrBadMapIndex)).Elem() 465 | types["ErrNonIntegerIndex"] = reflect.TypeOf(new(eval.ErrNonIntegerIndex)).Elem() 466 | types["ErrIndexOutOfBounds"] = reflect.TypeOf(new(eval.ErrIndexOutOfBounds)).Elem() 467 | types["ErrInvalidIndexOperation"] = reflect.TypeOf(new(eval.ErrInvalidIndexOperation)).Elem() 468 | types["ErrInvalidSliceIndex"] = reflect.TypeOf(new(eval.ErrInvalidSliceIndex)).Elem() 469 | types["ErrInvalidSliceOperation"] = reflect.TypeOf(new(eval.ErrInvalidSliceOperation)).Elem() 470 | types["ErrUnaddressableSliceOperand"] = reflect.TypeOf(new(eval.ErrUnaddressableSliceOperand)).Elem() 471 | types["ErrInvalidIndex"] = reflect.TypeOf(new(eval.ErrInvalidIndex)).Elem() 472 | types["ErrDivideByZero"] = reflect.TypeOf(new(eval.ErrDivideByZero)).Elem() 473 | types["ErrInvalidBinaryOperation"] = reflect.TypeOf(new(eval.ErrInvalidBinaryOperation)).Elem() 474 | types["ErrInvalidUnaryOperation"] = reflect.TypeOf(new(eval.ErrInvalidUnaryOperation)).Elem() 475 | types["ErrInvalidAddressOf"] = reflect.TypeOf(new(eval.ErrInvalidAddressOf)).Elem() 476 | types["ErrInvalidRecvFrom"] = reflect.TypeOf(new(eval.ErrInvalidRecvFrom)).Elem() 477 | types["ErrBadConversion"] = reflect.TypeOf(new(eval.ErrBadConversion)).Elem() 478 | types["ErrBadConstConversion"] = reflect.TypeOf(new(eval.ErrBadConstConversion)).Elem() 479 | types["ErrTruncatedConstant"] = reflect.TypeOf(new(eval.ErrTruncatedConstant)).Elem() 480 | types["ErrOverflowedConstant"] = reflect.TypeOf(new(eval.ErrOverflowedConstant)).Elem() 481 | types["ErrUntypedNil"] = reflect.TypeOf(new(eval.ErrUntypedNil)).Elem() 482 | types["ErrTypeUsedAsExpression"] = reflect.TypeOf(new(eval.ErrTypeUsedAsExpression)).Elem() 483 | types["ErrUncomparableMapKey"] = reflect.TypeOf(new(eval.ErrUncomparableMapKey)).Elem() 484 | types["ErrMissingMapKey"] = reflect.TypeOf(new(eval.ErrMissingMapKey)).Elem() 485 | types["ErrBadMapKey"] = reflect.TypeOf(new(eval.ErrBadMapKey)).Elem() 486 | types["ErrDuplicateMapKey"] = reflect.TypeOf(new(eval.ErrDuplicateMapKey)).Elem() 487 | types["ErrBadMapValue"] = reflect.TypeOf(new(eval.ErrBadMapValue)).Elem() 488 | types["ErrBadArrayKey"] = reflect.TypeOf(new(eval.ErrBadArrayKey)).Elem() 489 | types["ErrArrayKeyOutOfBounds"] = reflect.TypeOf(new(eval.ErrArrayKeyOutOfBounds)).Elem() 490 | types["ErrDuplicateArrayKey"] = reflect.TypeOf(new(eval.ErrDuplicateArrayKey)).Elem() 491 | types["ErrBadArrayValue"] = reflect.TypeOf(new(eval.ErrBadArrayValue)).Elem() 492 | types["ErrUnknownStructField"] = reflect.TypeOf(new(eval.ErrUnknownStructField)).Elem() 493 | types["ErrInvalidStructField"] = reflect.TypeOf(new(eval.ErrInvalidStructField)).Elem() 494 | types["ErrDuplicateStructField"] = reflect.TypeOf(new(eval.ErrDuplicateStructField)).Elem() 495 | types["ErrMixedStructValues"] = reflect.TypeOf(new(eval.ErrMixedStructValues)).Elem() 496 | types["ErrWrongNumberOfStructValues"] = reflect.TypeOf(new(eval.ErrWrongNumberOfStructValues)).Elem() 497 | types["ErrMissingCompositeLitType"] = reflect.TypeOf(new(eval.ErrMissingCompositeLitType)).Elem() 498 | types["ErrBadStructValue"] = reflect.TypeOf(new(eval.ErrBadStructValue)).Elem() 499 | types["ErrInvalidTypeAssert"] = reflect.TypeOf(new(eval.ErrInvalidTypeAssert)).Elem() 500 | types["ErrImpossibleTypeAssert"] = reflect.TypeOf(new(eval.ErrImpossibleTypeAssert)).Elem() 501 | types["ErrBuiltinWrongNumberOfArgs"] = reflect.TypeOf(new(eval.ErrBuiltinWrongNumberOfArgs)).Elem() 502 | types["ErrBuiltinWrongArgType"] = reflect.TypeOf(new(eval.ErrBuiltinWrongArgType)).Elem() 503 | types["ErrBuiltinMismatchedArgs"] = reflect.TypeOf(new(eval.ErrBuiltinMismatchedArgs)).Elem() 504 | types["ErrBuiltinNonTypeArg"] = reflect.TypeOf(new(eval.ErrBuiltinNonTypeArg)).Elem() 505 | types["ErrBuiltinInvalidEllipsis"] = reflect.TypeOf(new(eval.ErrBuiltinInvalidEllipsis)).Elem() 506 | types["ErrMakeBadType"] = reflect.TypeOf(new(eval.ErrMakeBadType)).Elem() 507 | types["ErrMakeNonIntegerArg"] = reflect.TypeOf(new(eval.ErrMakeNonIntegerArg)).Elem() 508 | types["ErrMakeLenGtrThanCap"] = reflect.TypeOf(new(eval.ErrMakeLenGtrThanCap)).Elem() 509 | types["ErrAppendFirstArgNotSlice"] = reflect.TypeOf(new(eval.ErrAppendFirstArgNotSlice)).Elem() 510 | types["ErrAppendFirstArgNotVariadic"] = reflect.TypeOf(new(eval.ErrAppendFirstArgNotVariadic)).Elem() 511 | types["ErrCopyArgsMustBeSlices"] = reflect.TypeOf(new(eval.ErrCopyArgsMustBeSlices)).Elem() 512 | types["ErrCopyArgsHaveDifferentEltTypes"] = reflect.TypeOf(new(eval.ErrCopyArgsHaveDifferentEltTypes)).Elem() 513 | types["ErrDeleteFirstArgNotMap"] = reflect.TypeOf(new(eval.ErrDeleteFirstArgNotMap)).Elem() 514 | types["ErrStupidShift"] = reflect.TypeOf(new(eval.ErrStupidShift)).Elem() 515 | types["ErrNonNameInDeclaration"] = reflect.TypeOf(new(eval.ErrNonNameInDeclaration)).Elem() 516 | types["ErrNoNewNamesInDeclaration"] = reflect.TypeOf(new(eval.ErrNoNewNamesInDeclaration)).Elem() 517 | types["ErrCannotAssignToUnaddressable"] = reflect.TypeOf(new(eval.ErrCannotAssignToUnaddressable)).Elem() 518 | types["ErrCannotAssignToType"] = reflect.TypeOf(new(eval.ErrCannotAssignToType)).Elem() 519 | types["ErrAssignCountMismatch"] = reflect.TypeOf(new(eval.ErrAssignCountMismatch)).Elem() 520 | types["ErrNonBoolCondition"] = reflect.TypeOf(new(eval.ErrNonBoolCondition)).Elem() 521 | types["ErrInvalidCase"] = reflect.TypeOf(new(eval.ErrInvalidCase)).Elem() 522 | types["ErrNonInterfaceTypeSwitch"] = reflect.TypeOf(new(eval.ErrNonInterfaceTypeSwitch)).Elem() 523 | types["ErrImpossibleTypeCase"] = reflect.TypeOf(new(eval.ErrImpossibleTypeCase)).Elem() 524 | types["State"] = reflect.TypeOf(new(eval.State)).Elem() 525 | types["PanicUser"] = reflect.TypeOf(new(eval.PanicUser)).Elem() 526 | types["PanicDivideByZero"] = reflect.TypeOf(new(eval.PanicDivideByZero)).Elem() 527 | types["PanicInvalidDereference"] = reflect.TypeOf(new(eval.PanicInvalidDereference)).Elem() 528 | types["PanicIndexOutOfBounds"] = reflect.TypeOf(new(eval.PanicIndexOutOfBounds)).Elem() 529 | types["PanicSliceOutOfBounds"] = reflect.TypeOf(new(eval.PanicSliceOutOfBounds)).Elem() 530 | types["PanicInterfaceConversion"] = reflect.TypeOf(new(eval.PanicInterfaceConversion)).Elem() 531 | types["PanicUncomparableType"] = reflect.TypeOf(new(eval.PanicUncomparableType)).Elem() 532 | types["PanicUnhashableType"] = reflect.TypeOf(new(eval.PanicUnhashableType)).Elem() 533 | types["Rune"] = reflect.TypeOf(new(eval.Rune)).Elem() 534 | types["UntypedNil"] = reflect.TypeOf(new(eval.UntypedNil)).Elem() 535 | 536 | vars = make(map[string] reflect.Value) 537 | vars["ByteType"] = reflect.ValueOf(&eval.ByteType) 538 | vars["ConstInt"] = reflect.ValueOf(&eval.ConstInt) 539 | vars["ConstShiftedInt"] = reflect.ValueOf(&eval.ConstShiftedInt) 540 | vars["ConstRune"] = reflect.ValueOf(&eval.ConstRune) 541 | vars["ConstFloat"] = reflect.ValueOf(&eval.ConstFloat) 542 | vars["ConstComplex"] = reflect.ValueOf(&eval.ConstComplex) 543 | vars["ConstString"] = reflect.ValueOf(&eval.ConstString) 544 | vars["ConstNil"] = reflect.ValueOf(&eval.ConstNil) 545 | vars["ConstBool"] = reflect.ValueOf(&eval.ConstBool) 546 | vars["EvalNil"] = reflect.ValueOf(&eval.EvalNil) 547 | vars["RuneType"] = reflect.ValueOf(&eval.RuneType) 548 | pkgs["eval"] = &eval.SimpleEnv { 549 | Consts: consts, 550 | Funcs: funcs, 551 | Types: types, 552 | Vars: vars, 553 | Pkgs: pkgs, 554 | } 555 | consts = make(map[string] reflect.Value) 556 | 557 | funcs = make(map[string] reflect.Value) 558 | funcs["AddAlias"] = reflect.ValueOf(AddAlias) 559 | funcs["AddToCategory"] = reflect.ValueOf(AddToCategory) 560 | funcs["LookupCmd"] = reflect.ValueOf(LookupCmd) 561 | funcs["Errmsg"] = reflect.ValueOf(Errmsg) 562 | funcs["MsgNoCr"] = reflect.ValueOf(MsgNoCr) 563 | funcs["Msg"] = reflect.ValueOf(Msg) 564 | funcs["Section"] = reflect.ValueOf(Section) 565 | funcs["PrintSorted"] = reflect.ValueOf(PrintSorted) 566 | funcs["HistoryFile"] = reflect.ValueOf(HistoryFile) 567 | funcs["SimpleReadLine"] = reflect.ValueOf(SimpleReadLine) 568 | funcs["SimpleInspect"] = reflect.ValueOf(SimpleInspect) 569 | funcs["MakeEvalEnv"] = reflect.ValueOf(MakeEvalEnv) 570 | funcs["REPL"] = reflect.ValueOf(REPL) 571 | funcs["EvalEnvironment"] = reflect.ValueOf(EvalEnvironment) 572 | funcs["AddSubCommand"] = reflect.ValueOf(AddSubCommand) 573 | funcs["ListSubCommandArgs"] = reflect.ValueOf(ListSubCommandArgs) 574 | funcs["HelpSubCommand"] = reflect.ValueOf(HelpSubCommand) 575 | funcs["UnknownSubCommand"] = reflect.ValueOf(UnknownSubCommand) 576 | funcs["SubcmdMgrCommand"] = reflect.ValueOf(SubcmdMgrCommand) 577 | funcs["ArgCountOK"] = reflect.ValueOf(ArgCountOK) 578 | funcs["GetInt"] = reflect.ValueOf(GetInt) 579 | funcs["GetUInt"] = reflect.ValueOf(GetUInt) 580 | 581 | types = make(map[string] reflect.Type) 582 | types["CmdFunc"] = reflect.TypeOf(new(CmdFunc)).Elem() 583 | types["CmdInfo"] = reflect.TypeOf(new(CmdInfo)).Elem() 584 | types["ReadLineFnType"] = reflect.TypeOf(new(ReadLineFnType)).Elem() 585 | types["InspectFnType"] = reflect.TypeOf(new(InspectFnType)).Elem() 586 | types["SubcmdFunc"] = reflect.TypeOf(new(SubcmdFunc)).Elem() 587 | types["SubcmdInfo"] = reflect.TypeOf(new(SubcmdInfo)).Elem() 588 | types["SubcmdMap"] = reflect.TypeOf(new(SubcmdMap)).Elem() 589 | types["SubcmdMgr"] = reflect.TypeOf(new(SubcmdMgr)).Elem() 590 | types["NumError"] = reflect.TypeOf(new(NumError)).Elem() 591 | 592 | vars = make(map[string] reflect.Value) 593 | vars["Cmds"] = reflect.ValueOf(&Cmds) 594 | vars["Aliases"] = reflect.ValueOf(&Aliases) 595 | vars["Categories"] = reflect.ValueOf(&Categories) 596 | vars["CmdLine"] = reflect.ValueOf(&CmdLine) 597 | vars["Highlight"] = reflect.ValueOf(&Highlight) 598 | vars["Maxwidth"] = reflect.ValueOf(&Maxwidth) 599 | vars["GOFISH_RESTART_CMD"] = reflect.ValueOf(&GOFISH_RESTART_CMD) 600 | vars["Input"] = reflect.ValueOf(&Input) 601 | vars["LeaveREPL"] = reflect.ValueOf(&LeaveREPL) 602 | vars["ExitCode"] = reflect.ValueOf(&ExitCode) 603 | vars["Env"] = reflect.ValueOf(&Env) 604 | vars["Subcmds"] = reflect.ValueOf(&Subcmds) 605 | pkgs["repl"] = &eval.SimpleEnv { 606 | Consts: consts, 607 | Funcs: funcs, 608 | Types: types, 609 | Vars: vars, 610 | Pkgs: pkgs, 611 | } 612 | consts = make(map[string] reflect.Value) 613 | consts["SEND"] = reflect.ValueOf(ast.SEND) 614 | consts["RECV"] = reflect.ValueOf(ast.RECV) 615 | consts["FilterFuncDuplicates"] = reflect.ValueOf(ast.FilterFuncDuplicates) 616 | consts["FilterUnassociatedComments"] = reflect.ValueOf(ast.FilterUnassociatedComments) 617 | consts["FilterImportDuplicates"] = reflect.ValueOf(ast.FilterImportDuplicates) 618 | consts["Bad"] = reflect.ValueOf(ast.Bad) 619 | consts["Pkg"] = reflect.ValueOf(ast.Pkg) 620 | consts["Con"] = reflect.ValueOf(ast.Con) 621 | consts["Typ"] = reflect.ValueOf(ast.Typ) 622 | consts["Var"] = reflect.ValueOf(ast.Var) 623 | consts["Fun"] = reflect.ValueOf(ast.Fun) 624 | consts["Lbl"] = reflect.ValueOf(ast.Lbl) 625 | 626 | funcs = make(map[string] reflect.Value) 627 | funcs["NewIdent"] = reflect.ValueOf(ast.NewIdent) 628 | funcs["IsExported"] = reflect.ValueOf(ast.IsExported) 629 | funcs["NewCommentMap"] = reflect.ValueOf(ast.NewCommentMap) 630 | funcs["FileExports"] = reflect.ValueOf(ast.FileExports) 631 | funcs["PackageExports"] = reflect.ValueOf(ast.PackageExports) 632 | funcs["FilterDecl"] = reflect.ValueOf(ast.FilterDecl) 633 | funcs["FilterFile"] = reflect.ValueOf(ast.FilterFile) 634 | funcs["FilterPackage"] = reflect.ValueOf(ast.FilterPackage) 635 | funcs["MergePackageFiles"] = reflect.ValueOf(ast.MergePackageFiles) 636 | funcs["SortImports"] = reflect.ValueOf(ast.SortImports) 637 | funcs["NotNilFilter"] = reflect.ValueOf(ast.NotNilFilter) 638 | funcs["Fprint"] = reflect.ValueOf(ast.Fprint) 639 | funcs["Print"] = reflect.ValueOf(ast.Print) 640 | funcs["NewPackage"] = reflect.ValueOf(ast.NewPackage) 641 | funcs["NewScope"] = reflect.ValueOf(ast.NewScope) 642 | funcs["NewObj"] = reflect.ValueOf(ast.NewObj) 643 | funcs["Walk"] = reflect.ValueOf(ast.Walk) 644 | funcs["Inspect"] = reflect.ValueOf(ast.Inspect) 645 | 646 | types = make(map[string] reflect.Type) 647 | types["Node"] = reflect.TypeOf(new(ast.Node)).Elem() 648 | types["Expr"] = reflect.TypeOf(new(ast.Expr)).Elem() 649 | types["Stmt"] = reflect.TypeOf(new(ast.Stmt)).Elem() 650 | types["Decl"] = reflect.TypeOf(new(ast.Decl)).Elem() 651 | types["Comment"] = reflect.TypeOf(new(ast.Comment)).Elem() 652 | types["CommentGroup"] = reflect.TypeOf(new(ast.CommentGroup)).Elem() 653 | types["Field"] = reflect.TypeOf(new(ast.Field)).Elem() 654 | types["FieldList"] = reflect.TypeOf(new(ast.FieldList)).Elem() 655 | types["BadExpr"] = reflect.TypeOf(new(ast.BadExpr)).Elem() 656 | types["Ident"] = reflect.TypeOf(new(ast.Ident)).Elem() 657 | types["Ellipsis"] = reflect.TypeOf(new(ast.Ellipsis)).Elem() 658 | types["BasicLit"] = reflect.TypeOf(new(ast.BasicLit)).Elem() 659 | types["FuncLit"] = reflect.TypeOf(new(ast.FuncLit)).Elem() 660 | types["CompositeLit"] = reflect.TypeOf(new(ast.CompositeLit)).Elem() 661 | types["ParenExpr"] = reflect.TypeOf(new(ast.ParenExpr)).Elem() 662 | types["SelectorExpr"] = reflect.TypeOf(new(ast.SelectorExpr)).Elem() 663 | types["IndexExpr"] = reflect.TypeOf(new(ast.IndexExpr)).Elem() 664 | types["SliceExpr"] = reflect.TypeOf(new(ast.SliceExpr)).Elem() 665 | types["TypeAssertExpr"] = reflect.TypeOf(new(ast.TypeAssertExpr)).Elem() 666 | types["CallExpr"] = reflect.TypeOf(new(ast.CallExpr)).Elem() 667 | types["StarExpr"] = reflect.TypeOf(new(ast.StarExpr)).Elem() 668 | types["UnaryExpr"] = reflect.TypeOf(new(ast.UnaryExpr)).Elem() 669 | types["BinaryExpr"] = reflect.TypeOf(new(ast.BinaryExpr)).Elem() 670 | types["KeyValueExpr"] = reflect.TypeOf(new(ast.KeyValueExpr)).Elem() 671 | types["ChanDir"] = reflect.TypeOf(new(ast.ChanDir)).Elem() 672 | types["ArrayType"] = reflect.TypeOf(new(ast.ArrayType)).Elem() 673 | types["StructType"] = reflect.TypeOf(new(ast.StructType)).Elem() 674 | types["FuncType"] = reflect.TypeOf(new(ast.FuncType)).Elem() 675 | types["InterfaceType"] = reflect.TypeOf(new(ast.InterfaceType)).Elem() 676 | types["MapType"] = reflect.TypeOf(new(ast.MapType)).Elem() 677 | types["ChanType"] = reflect.TypeOf(new(ast.ChanType)).Elem() 678 | types["BadStmt"] = reflect.TypeOf(new(ast.BadStmt)).Elem() 679 | types["DeclStmt"] = reflect.TypeOf(new(ast.DeclStmt)).Elem() 680 | types["EmptyStmt"] = reflect.TypeOf(new(ast.EmptyStmt)).Elem() 681 | types["LabeledStmt"] = reflect.TypeOf(new(ast.LabeledStmt)).Elem() 682 | types["ExprStmt"] = reflect.TypeOf(new(ast.ExprStmt)).Elem() 683 | types["SendStmt"] = reflect.TypeOf(new(ast.SendStmt)).Elem() 684 | types["IncDecStmt"] = reflect.TypeOf(new(ast.IncDecStmt)).Elem() 685 | types["AssignStmt"] = reflect.TypeOf(new(ast.AssignStmt)).Elem() 686 | types["GoStmt"] = reflect.TypeOf(new(ast.GoStmt)).Elem() 687 | types["DeferStmt"] = reflect.TypeOf(new(ast.DeferStmt)).Elem() 688 | types["ReturnStmt"] = reflect.TypeOf(new(ast.ReturnStmt)).Elem() 689 | types["BranchStmt"] = reflect.TypeOf(new(ast.BranchStmt)).Elem() 690 | types["BlockStmt"] = reflect.TypeOf(new(ast.BlockStmt)).Elem() 691 | types["IfStmt"] = reflect.TypeOf(new(ast.IfStmt)).Elem() 692 | types["CaseClause"] = reflect.TypeOf(new(ast.CaseClause)).Elem() 693 | types["SwitchStmt"] = reflect.TypeOf(new(ast.SwitchStmt)).Elem() 694 | types["TypeSwitchStmt"] = reflect.TypeOf(new(ast.TypeSwitchStmt)).Elem() 695 | types["CommClause"] = reflect.TypeOf(new(ast.CommClause)).Elem() 696 | types["SelectStmt"] = reflect.TypeOf(new(ast.SelectStmt)).Elem() 697 | types["ForStmt"] = reflect.TypeOf(new(ast.ForStmt)).Elem() 698 | types["RangeStmt"] = reflect.TypeOf(new(ast.RangeStmt)).Elem() 699 | types["Spec"] = reflect.TypeOf(new(ast.Spec)).Elem() 700 | types["ImportSpec"] = reflect.TypeOf(new(ast.ImportSpec)).Elem() 701 | types["ValueSpec"] = reflect.TypeOf(new(ast.ValueSpec)).Elem() 702 | types["TypeSpec"] = reflect.TypeOf(new(ast.TypeSpec)).Elem() 703 | types["BadDecl"] = reflect.TypeOf(new(ast.BadDecl)).Elem() 704 | types["GenDecl"] = reflect.TypeOf(new(ast.GenDecl)).Elem() 705 | types["FuncDecl"] = reflect.TypeOf(new(ast.FuncDecl)).Elem() 706 | types["File"] = reflect.TypeOf(new(ast.File)).Elem() 707 | types["Package"] = reflect.TypeOf(new(ast.Package)).Elem() 708 | types["CommentMap"] = reflect.TypeOf(new(ast.CommentMap)).Elem() 709 | types["Filter"] = reflect.TypeOf(new(ast.Filter)).Elem() 710 | types["MergeMode"] = reflect.TypeOf(new(ast.MergeMode)).Elem() 711 | types["FieldFilter"] = reflect.TypeOf(new(ast.FieldFilter)).Elem() 712 | types["Importer"] = reflect.TypeOf(new(ast.Importer)).Elem() 713 | types["Scope"] = reflect.TypeOf(new(ast.Scope)).Elem() 714 | types["Object"] = reflect.TypeOf(new(ast.Object)).Elem() 715 | types["ObjKind"] = reflect.TypeOf(new(ast.ObjKind)).Elem() 716 | types["Visitor"] = reflect.TypeOf(new(ast.Visitor)).Elem() 717 | 718 | vars = make(map[string] reflect.Value) 719 | pkgs["ast"] = &eval.SimpleEnv { 720 | Consts: consts, 721 | Funcs: funcs, 722 | Types: types, 723 | Vars: vars, 724 | Pkgs: pkgs, 725 | } 726 | consts = make(map[string] reflect.Value) 727 | consts["PackageClauseOnly"] = reflect.ValueOf(parser.PackageClauseOnly) 728 | consts["ImportsOnly"] = reflect.ValueOf(parser.ImportsOnly) 729 | consts["ParseComments"] = reflect.ValueOf(parser.ParseComments) 730 | consts["Trace"] = reflect.ValueOf(parser.Trace) 731 | consts["DeclarationErrors"] = reflect.ValueOf(parser.DeclarationErrors) 732 | consts["SpuriousErrors"] = reflect.ValueOf(parser.SpuriousErrors) 733 | consts["AllErrors"] = reflect.ValueOf(parser.AllErrors) 734 | 735 | funcs = make(map[string] reflect.Value) 736 | funcs["ParseFile"] = reflect.ValueOf(parser.ParseFile) 737 | funcs["ParseDir"] = reflect.ValueOf(parser.ParseDir) 738 | funcs["ParseExpr"] = reflect.ValueOf(parser.ParseExpr) 739 | 740 | types = make(map[string] reflect.Type) 741 | types["Mode"] = reflect.TypeOf(new(parser.Mode)).Elem() 742 | 743 | vars = make(map[string] reflect.Value) 744 | pkgs["parser"] = &eval.SimpleEnv { 745 | Consts: consts, 746 | Funcs: funcs, 747 | Types: types, 748 | Vars: vars, 749 | Pkgs: pkgs, 750 | } 751 | consts = make(map[string] reflect.Value) 752 | consts["ScanComments"] = reflect.ValueOf(scanner.ScanComments) 753 | 754 | funcs = make(map[string] reflect.Value) 755 | funcs["PrintError"] = reflect.ValueOf(scanner.PrintError) 756 | 757 | types = make(map[string] reflect.Type) 758 | types["Error"] = reflect.TypeOf(new(scanner.Error)).Elem() 759 | types["ErrorList"] = reflect.TypeOf(new(scanner.ErrorList)).Elem() 760 | types["ErrorHandler"] = reflect.TypeOf(new(scanner.ErrorHandler)).Elem() 761 | types["Scanner"] = reflect.TypeOf(new(scanner.Scanner)).Elem() 762 | types["Mode"] = reflect.TypeOf(new(scanner.Mode)).Elem() 763 | 764 | vars = make(map[string] reflect.Value) 765 | pkgs["scanner"] = &eval.SimpleEnv { 766 | Consts: consts, 767 | Funcs: funcs, 768 | Types: types, 769 | Vars: vars, 770 | Pkgs: pkgs, 771 | } 772 | consts = make(map[string] reflect.Value) 773 | consts["NoPos"] = reflect.ValueOf(token.NoPos) 774 | consts["ILLEGAL"] = reflect.ValueOf(token.ILLEGAL) 775 | consts["EOF"] = reflect.ValueOf(token.EOF) 776 | consts["COMMENT"] = reflect.ValueOf(token.COMMENT) 777 | consts["IDENT"] = reflect.ValueOf(token.IDENT) 778 | consts["INT"] = reflect.ValueOf(token.INT) 779 | consts["FLOAT"] = reflect.ValueOf(token.FLOAT) 780 | consts["IMAG"] = reflect.ValueOf(token.IMAG) 781 | consts["CHAR"] = reflect.ValueOf(token.CHAR) 782 | consts["STRING"] = reflect.ValueOf(token.STRING) 783 | consts["ADD"] = reflect.ValueOf(token.ADD) 784 | consts["SUB"] = reflect.ValueOf(token.SUB) 785 | consts["MUL"] = reflect.ValueOf(token.MUL) 786 | consts["QUO"] = reflect.ValueOf(token.QUO) 787 | consts["REM"] = reflect.ValueOf(token.REM) 788 | consts["AND"] = reflect.ValueOf(token.AND) 789 | consts["OR"] = reflect.ValueOf(token.OR) 790 | consts["XOR"] = reflect.ValueOf(token.XOR) 791 | consts["SHL"] = reflect.ValueOf(token.SHL) 792 | consts["SHR"] = reflect.ValueOf(token.SHR) 793 | consts["AND_NOT"] = reflect.ValueOf(token.AND_NOT) 794 | consts["ADD_ASSIGN"] = reflect.ValueOf(token.ADD_ASSIGN) 795 | consts["SUB_ASSIGN"] = reflect.ValueOf(token.SUB_ASSIGN) 796 | consts["MUL_ASSIGN"] = reflect.ValueOf(token.MUL_ASSIGN) 797 | consts["QUO_ASSIGN"] = reflect.ValueOf(token.QUO_ASSIGN) 798 | consts["REM_ASSIGN"] = reflect.ValueOf(token.REM_ASSIGN) 799 | consts["AND_ASSIGN"] = reflect.ValueOf(token.AND_ASSIGN) 800 | consts["OR_ASSIGN"] = reflect.ValueOf(token.OR_ASSIGN) 801 | consts["XOR_ASSIGN"] = reflect.ValueOf(token.XOR_ASSIGN) 802 | consts["SHL_ASSIGN"] = reflect.ValueOf(token.SHL_ASSIGN) 803 | consts["SHR_ASSIGN"] = reflect.ValueOf(token.SHR_ASSIGN) 804 | consts["AND_NOT_ASSIGN"] = reflect.ValueOf(token.AND_NOT_ASSIGN) 805 | consts["LAND"] = reflect.ValueOf(token.LAND) 806 | consts["LOR"] = reflect.ValueOf(token.LOR) 807 | consts["ARROW"] = reflect.ValueOf(token.ARROW) 808 | consts["INC"] = reflect.ValueOf(token.INC) 809 | consts["DEC"] = reflect.ValueOf(token.DEC) 810 | consts["EQL"] = reflect.ValueOf(token.EQL) 811 | consts["LSS"] = reflect.ValueOf(token.LSS) 812 | consts["GTR"] = reflect.ValueOf(token.GTR) 813 | consts["ASSIGN"] = reflect.ValueOf(token.ASSIGN) 814 | consts["NOT"] = reflect.ValueOf(token.NOT) 815 | consts["NEQ"] = reflect.ValueOf(token.NEQ) 816 | consts["LEQ"] = reflect.ValueOf(token.LEQ) 817 | consts["GEQ"] = reflect.ValueOf(token.GEQ) 818 | consts["DEFINE"] = reflect.ValueOf(token.DEFINE) 819 | consts["ELLIPSIS"] = reflect.ValueOf(token.ELLIPSIS) 820 | consts["LPAREN"] = reflect.ValueOf(token.LPAREN) 821 | consts["LBRACK"] = reflect.ValueOf(token.LBRACK) 822 | consts["LBRACE"] = reflect.ValueOf(token.LBRACE) 823 | consts["COMMA"] = reflect.ValueOf(token.COMMA) 824 | consts["PERIOD"] = reflect.ValueOf(token.PERIOD) 825 | consts["RPAREN"] = reflect.ValueOf(token.RPAREN) 826 | consts["RBRACK"] = reflect.ValueOf(token.RBRACK) 827 | consts["RBRACE"] = reflect.ValueOf(token.RBRACE) 828 | consts["SEMICOLON"] = reflect.ValueOf(token.SEMICOLON) 829 | consts["COLON"] = reflect.ValueOf(token.COLON) 830 | consts["BREAK"] = reflect.ValueOf(token.BREAK) 831 | consts["CASE"] = reflect.ValueOf(token.CASE) 832 | consts["CHAN"] = reflect.ValueOf(token.CHAN) 833 | consts["CONST"] = reflect.ValueOf(token.CONST) 834 | consts["CONTINUE"] = reflect.ValueOf(token.CONTINUE) 835 | consts["DEFAULT"] = reflect.ValueOf(token.DEFAULT) 836 | consts["DEFER"] = reflect.ValueOf(token.DEFER) 837 | consts["ELSE"] = reflect.ValueOf(token.ELSE) 838 | consts["FALLTHROUGH"] = reflect.ValueOf(token.FALLTHROUGH) 839 | consts["FOR"] = reflect.ValueOf(token.FOR) 840 | consts["FUNC"] = reflect.ValueOf(token.FUNC) 841 | consts["GO"] = reflect.ValueOf(token.GO) 842 | consts["GOTO"] = reflect.ValueOf(token.GOTO) 843 | consts["IF"] = reflect.ValueOf(token.IF) 844 | consts["IMPORT"] = reflect.ValueOf(token.IMPORT) 845 | consts["INTERFACE"] = reflect.ValueOf(token.INTERFACE) 846 | consts["MAP"] = reflect.ValueOf(token.MAP) 847 | consts["PACKAGE"] = reflect.ValueOf(token.PACKAGE) 848 | consts["RANGE"] = reflect.ValueOf(token.RANGE) 849 | consts["RETURN"] = reflect.ValueOf(token.RETURN) 850 | consts["SELECT"] = reflect.ValueOf(token.SELECT) 851 | consts["STRUCT"] = reflect.ValueOf(token.STRUCT) 852 | consts["SWITCH"] = reflect.ValueOf(token.SWITCH) 853 | consts["TYPE"] = reflect.ValueOf(token.TYPE) 854 | consts["VAR"] = reflect.ValueOf(token.VAR) 855 | consts["LowestPrec"] = reflect.ValueOf(token.LowestPrec) 856 | consts["UnaryPrec"] = reflect.ValueOf(token.UnaryPrec) 857 | consts["HighestPrec"] = reflect.ValueOf(token.HighestPrec) 858 | 859 | funcs = make(map[string] reflect.Value) 860 | funcs["NewFileSet"] = reflect.ValueOf(token.NewFileSet) 861 | funcs["Lookup"] = reflect.ValueOf(token.Lookup) 862 | 863 | types = make(map[string] reflect.Type) 864 | types["Position"] = reflect.TypeOf(new(token.Position)).Elem() 865 | types["Pos"] = reflect.TypeOf(new(token.Pos)).Elem() 866 | types["File"] = reflect.TypeOf(new(token.File)).Elem() 867 | types["FileSet"] = reflect.TypeOf(new(token.FileSet)).Elem() 868 | types["Token"] = reflect.TypeOf(new(token.Token)).Elem() 869 | 870 | vars = make(map[string] reflect.Value) 871 | pkgs["token"] = &eval.SimpleEnv { 872 | Consts: consts, 873 | Funcs: funcs, 874 | Types: types, 875 | Vars: vars, 876 | Pkgs: pkgs, 877 | } 878 | consts = make(map[string] reflect.Value) 879 | 880 | funcs = make(map[string] reflect.Value) 881 | funcs["WriteString"] = reflect.ValueOf(io.WriteString) 882 | funcs["ReadAtLeast"] = reflect.ValueOf(io.ReadAtLeast) 883 | funcs["ReadFull"] = reflect.ValueOf(io.ReadFull) 884 | funcs["CopyN"] = reflect.ValueOf(io.CopyN) 885 | funcs["Copy"] = reflect.ValueOf(io.Copy) 886 | funcs["LimitReader"] = reflect.ValueOf(io.LimitReader) 887 | funcs["NewSectionReader"] = reflect.ValueOf(io.NewSectionReader) 888 | funcs["TeeReader"] = reflect.ValueOf(io.TeeReader) 889 | funcs["MultiReader"] = reflect.ValueOf(io.MultiReader) 890 | funcs["MultiWriter"] = reflect.ValueOf(io.MultiWriter) 891 | funcs["Pipe"] = reflect.ValueOf(io.Pipe) 892 | 893 | types = make(map[string] reflect.Type) 894 | types["Reader"] = reflect.TypeOf(new(io.Reader)).Elem() 895 | types["Writer"] = reflect.TypeOf(new(io.Writer)).Elem() 896 | types["Closer"] = reflect.TypeOf(new(io.Closer)).Elem() 897 | types["Seeker"] = reflect.TypeOf(new(io.Seeker)).Elem() 898 | types["ReadWriter"] = reflect.TypeOf(new(io.ReadWriter)).Elem() 899 | types["ReadCloser"] = reflect.TypeOf(new(io.ReadCloser)).Elem() 900 | types["WriteCloser"] = reflect.TypeOf(new(io.WriteCloser)).Elem() 901 | types["ReadWriteCloser"] = reflect.TypeOf(new(io.ReadWriteCloser)).Elem() 902 | types["ReadSeeker"] = reflect.TypeOf(new(io.ReadSeeker)).Elem() 903 | types["WriteSeeker"] = reflect.TypeOf(new(io.WriteSeeker)).Elem() 904 | types["ReadWriteSeeker"] = reflect.TypeOf(new(io.ReadWriteSeeker)).Elem() 905 | types["ReaderFrom"] = reflect.TypeOf(new(io.ReaderFrom)).Elem() 906 | types["WriterTo"] = reflect.TypeOf(new(io.WriterTo)).Elem() 907 | types["ReaderAt"] = reflect.TypeOf(new(io.ReaderAt)).Elem() 908 | types["WriterAt"] = reflect.TypeOf(new(io.WriterAt)).Elem() 909 | types["ByteReader"] = reflect.TypeOf(new(io.ByteReader)).Elem() 910 | types["ByteScanner"] = reflect.TypeOf(new(io.ByteScanner)).Elem() 911 | types["ByteWriter"] = reflect.TypeOf(new(io.ByteWriter)).Elem() 912 | types["RuneReader"] = reflect.TypeOf(new(io.RuneReader)).Elem() 913 | types["RuneScanner"] = reflect.TypeOf(new(io.RuneScanner)).Elem() 914 | types["LimitedReader"] = reflect.TypeOf(new(io.LimitedReader)).Elem() 915 | types["SectionReader"] = reflect.TypeOf(new(io.SectionReader)).Elem() 916 | types["PipeReader"] = reflect.TypeOf(new(io.PipeReader)).Elem() 917 | types["PipeWriter"] = reflect.TypeOf(new(io.PipeWriter)).Elem() 918 | 919 | vars = make(map[string] reflect.Value) 920 | vars["ErrShortWrite"] = reflect.ValueOf(&io.ErrShortWrite) 921 | vars["ErrShortBuffer"] = reflect.ValueOf(&io.ErrShortBuffer) 922 | vars["EOF"] = reflect.ValueOf(&io.EOF) 923 | vars["ErrUnexpectedEOF"] = reflect.ValueOf(&io.ErrUnexpectedEOF) 924 | vars["ErrNoProgress"] = reflect.ValueOf(&io.ErrNoProgress) 925 | vars["ErrClosedPipe"] = reflect.ValueOf(&io.ErrClosedPipe) 926 | pkgs["io"] = &eval.SimpleEnv { 927 | Consts: consts, 928 | Funcs: funcs, 929 | Types: types, 930 | Vars: vars, 931 | Pkgs: pkgs, 932 | } 933 | consts = make(map[string] reflect.Value) 934 | 935 | funcs = make(map[string] reflect.Value) 936 | funcs["ReadAll"] = reflect.ValueOf(ioutil.ReadAll) 937 | funcs["ReadFile"] = reflect.ValueOf(ioutil.ReadFile) 938 | funcs["WriteFile"] = reflect.ValueOf(ioutil.WriteFile) 939 | funcs["ReadDir"] = reflect.ValueOf(ioutil.ReadDir) 940 | funcs["NopCloser"] = reflect.ValueOf(ioutil.NopCloser) 941 | funcs["TempFile"] = reflect.ValueOf(ioutil.TempFile) 942 | funcs["TempDir"] = reflect.ValueOf(ioutil.TempDir) 943 | 944 | types = make(map[string] reflect.Type) 945 | 946 | vars = make(map[string] reflect.Value) 947 | vars["Discard"] = reflect.ValueOf(&ioutil.Discard) 948 | pkgs["ioutil"] = &eval.SimpleEnv { 949 | Consts: consts, 950 | Funcs: funcs, 951 | Types: types, 952 | Vars: vars, 953 | Pkgs: pkgs, 954 | } 955 | consts = make(map[string] reflect.Value) 956 | consts["Ldate"] = reflect.ValueOf(log.Ldate) 957 | consts["Ltime"] = reflect.ValueOf(log.Ltime) 958 | consts["Lmicroseconds"] = reflect.ValueOf(log.Lmicroseconds) 959 | consts["Llongfile"] = reflect.ValueOf(log.Llongfile) 960 | consts["Lshortfile"] = reflect.ValueOf(log.Lshortfile) 961 | consts["LstdFlags"] = reflect.ValueOf(log.LstdFlags) 962 | 963 | funcs = make(map[string] reflect.Value) 964 | funcs["New"] = reflect.ValueOf(log.New) 965 | funcs["SetOutput"] = reflect.ValueOf(log.SetOutput) 966 | funcs["Flags"] = reflect.ValueOf(log.Flags) 967 | funcs["SetFlags"] = reflect.ValueOf(log.SetFlags) 968 | funcs["Prefix"] = reflect.ValueOf(log.Prefix) 969 | funcs["SetPrefix"] = reflect.ValueOf(log.SetPrefix) 970 | funcs["Print"] = reflect.ValueOf(log.Print) 971 | funcs["Printf"] = reflect.ValueOf(log.Printf) 972 | funcs["Println"] = reflect.ValueOf(log.Println) 973 | funcs["Fatal"] = reflect.ValueOf(log.Fatal) 974 | funcs["Fatalf"] = reflect.ValueOf(log.Fatalf) 975 | funcs["Fatalln"] = reflect.ValueOf(log.Fatalln) 976 | funcs["Panic"] = reflect.ValueOf(log.Panic) 977 | funcs["Panicf"] = reflect.ValueOf(log.Panicf) 978 | funcs["Panicln"] = reflect.ValueOf(log.Panicln) 979 | 980 | types = make(map[string] reflect.Type) 981 | types["Logger"] = reflect.TypeOf(new(log.Logger)).Elem() 982 | 983 | vars = make(map[string] reflect.Value) 984 | pkgs["log"] = &eval.SimpleEnv { 985 | Consts: consts, 986 | Funcs: funcs, 987 | Types: types, 988 | Vars: vars, 989 | Pkgs: pkgs, 990 | } 991 | consts = make(map[string] reflect.Value) 992 | consts["E"] = reflect.ValueOf(math.E) 993 | consts["Pi"] = reflect.ValueOf(math.Pi) 994 | consts["Phi"] = reflect.ValueOf(math.Phi) 995 | consts["Sqrt2"] = reflect.ValueOf(math.Sqrt2) 996 | consts["SqrtE"] = reflect.ValueOf(math.SqrtE) 997 | consts["SqrtPi"] = reflect.ValueOf(math.SqrtPi) 998 | consts["SqrtPhi"] = reflect.ValueOf(math.SqrtPhi) 999 | consts["Ln2"] = reflect.ValueOf(math.Ln2) 1000 | consts["Log2E"] = reflect.ValueOf(math.Log2E) 1001 | consts["Ln10"] = reflect.ValueOf(math.Ln10) 1002 | consts["Log10E"] = reflect.ValueOf(math.Log10E) 1003 | consts["MaxFloat32"] = reflect.ValueOf(math.MaxFloat32) 1004 | consts["SmallestNonzeroFloat32"] = reflect.ValueOf(math.SmallestNonzeroFloat32) 1005 | consts["MaxFloat64"] = reflect.ValueOf(math.MaxFloat64) 1006 | consts["SmallestNonzeroFloat64"] = reflect.ValueOf(math.SmallestNonzeroFloat64) 1007 | consts["MaxInt8"] = reflect.ValueOf(math.MaxInt8) 1008 | consts["MinInt8"] = reflect.ValueOf(math.MinInt8) 1009 | consts["MaxInt16"] = reflect.ValueOf(math.MaxInt16) 1010 | consts["MinInt16"] = reflect.ValueOf(math.MinInt16) 1011 | consts["MaxInt32"] = reflect.ValueOf(math.MaxInt32) 1012 | consts["MinInt32"] = reflect.ValueOf(math.MinInt32) 1013 | consts["MaxInt64"] = reflect.ValueOf(int64(math.MaxInt64)) 1014 | consts["MinInt64"] = reflect.ValueOf(int64(math.MinInt64)) 1015 | consts["MaxUint8"] = reflect.ValueOf(uint8(math.MaxUint8)) 1016 | consts["MaxUint16"] = reflect.ValueOf(uint16(math.MaxUint16)) 1017 | consts["MaxUint32"] = reflect.ValueOf(uint32(math.MaxUint32)) 1018 | consts["MaxUint64"] = reflect.ValueOf(uint64(math.MaxUint64)) 1019 | 1020 | funcs = make(map[string] reflect.Value) 1021 | funcs["Abs"] = reflect.ValueOf(math.Abs) 1022 | funcs["Acosh"] = reflect.ValueOf(math.Acosh) 1023 | funcs["Asin"] = reflect.ValueOf(math.Asin) 1024 | funcs["Acos"] = reflect.ValueOf(math.Acos) 1025 | funcs["Asinh"] = reflect.ValueOf(math.Asinh) 1026 | funcs["Atan"] = reflect.ValueOf(math.Atan) 1027 | funcs["Atan2"] = reflect.ValueOf(math.Atan2) 1028 | funcs["Atanh"] = reflect.ValueOf(math.Atanh) 1029 | funcs["Inf"] = reflect.ValueOf(math.Inf) 1030 | funcs["NaN"] = reflect.ValueOf(math.NaN) 1031 | funcs["IsNaN"] = reflect.ValueOf(math.IsNaN) 1032 | funcs["IsInf"] = reflect.ValueOf(math.IsInf) 1033 | funcs["Cbrt"] = reflect.ValueOf(math.Cbrt) 1034 | funcs["Copysign"] = reflect.ValueOf(math.Copysign) 1035 | funcs["Dim"] = reflect.ValueOf(math.Dim) 1036 | funcs["Max"] = reflect.ValueOf(math.Max) 1037 | funcs["Min"] = reflect.ValueOf(math.Min) 1038 | funcs["Erf"] = reflect.ValueOf(math.Erf) 1039 | funcs["Erfc"] = reflect.ValueOf(math.Erfc) 1040 | funcs["Exp"] = reflect.ValueOf(math.Exp) 1041 | funcs["Exp2"] = reflect.ValueOf(math.Exp2) 1042 | funcs["Expm1"] = reflect.ValueOf(math.Expm1) 1043 | funcs["Floor"] = reflect.ValueOf(math.Floor) 1044 | funcs["Ceil"] = reflect.ValueOf(math.Ceil) 1045 | funcs["Trunc"] = reflect.ValueOf(math.Trunc) 1046 | funcs["Frexp"] = reflect.ValueOf(math.Frexp) 1047 | funcs["Gamma"] = reflect.ValueOf(math.Gamma) 1048 | funcs["Hypot"] = reflect.ValueOf(math.Hypot) 1049 | funcs["J0"] = reflect.ValueOf(math.J0) 1050 | funcs["Y0"] = reflect.ValueOf(math.Y0) 1051 | funcs["J1"] = reflect.ValueOf(math.J1) 1052 | funcs["Y1"] = reflect.ValueOf(math.Y1) 1053 | funcs["Jn"] = reflect.ValueOf(math.Jn) 1054 | funcs["Yn"] = reflect.ValueOf(math.Yn) 1055 | funcs["Ldexp"] = reflect.ValueOf(math.Ldexp) 1056 | funcs["Lgamma"] = reflect.ValueOf(math.Lgamma) 1057 | funcs["Log"] = reflect.ValueOf(math.Log) 1058 | funcs["Log10"] = reflect.ValueOf(math.Log10) 1059 | funcs["Log2"] = reflect.ValueOf(math.Log2) 1060 | funcs["Log1p"] = reflect.ValueOf(math.Log1p) 1061 | funcs["Logb"] = reflect.ValueOf(math.Logb) 1062 | funcs["Ilogb"] = reflect.ValueOf(math.Ilogb) 1063 | funcs["Mod"] = reflect.ValueOf(math.Mod) 1064 | funcs["Modf"] = reflect.ValueOf(math.Modf) 1065 | funcs["Nextafter32"] = reflect.ValueOf(math.Nextafter32) 1066 | funcs["Nextafter"] = reflect.ValueOf(math.Nextafter) 1067 | funcs["Pow"] = reflect.ValueOf(math.Pow) 1068 | funcs["Pow10"] = reflect.ValueOf(math.Pow10) 1069 | funcs["Remainder"] = reflect.ValueOf(math.Remainder) 1070 | funcs["Signbit"] = reflect.ValueOf(math.Signbit) 1071 | funcs["Cos"] = reflect.ValueOf(math.Cos) 1072 | funcs["Sin"] = reflect.ValueOf(math.Sin) 1073 | funcs["Sincos"] = reflect.ValueOf(math.Sincos) 1074 | funcs["Sinh"] = reflect.ValueOf(math.Sinh) 1075 | funcs["Cosh"] = reflect.ValueOf(math.Cosh) 1076 | funcs["Sqrt"] = reflect.ValueOf(math.Sqrt) 1077 | funcs["Tan"] = reflect.ValueOf(math.Tan) 1078 | funcs["Tanh"] = reflect.ValueOf(math.Tanh) 1079 | funcs["Float32bits"] = reflect.ValueOf(math.Float32bits) 1080 | funcs["Float32frombits"] = reflect.ValueOf(math.Float32frombits) 1081 | funcs["Float64bits"] = reflect.ValueOf(math.Float64bits) 1082 | funcs["Float64frombits"] = reflect.ValueOf(math.Float64frombits) 1083 | 1084 | types = make(map[string] reflect.Type) 1085 | 1086 | vars = make(map[string] reflect.Value) 1087 | pkgs["math"] = &eval.SimpleEnv { 1088 | Consts: consts, 1089 | Funcs: funcs, 1090 | Types: types, 1091 | Vars: vars, 1092 | Pkgs: pkgs, 1093 | } 1094 | consts = make(map[string] reflect.Value) 1095 | consts["MaxBase"] = reflect.ValueOf(big.MaxBase) 1096 | 1097 | funcs = make(map[string] reflect.Value) 1098 | funcs["NewInt"] = reflect.ValueOf(big.NewInt) 1099 | funcs["NewRat"] = reflect.ValueOf(big.NewRat) 1100 | 1101 | types = make(map[string] reflect.Type) 1102 | types["Word"] = reflect.TypeOf(new(big.Word)).Elem() 1103 | types["Int"] = reflect.TypeOf(new(big.Int)).Elem() 1104 | types["Rat"] = reflect.TypeOf(new(big.Rat)).Elem() 1105 | 1106 | vars = make(map[string] reflect.Value) 1107 | pkgs["big"] = &eval.SimpleEnv { 1108 | Consts: consts, 1109 | Funcs: funcs, 1110 | Types: types, 1111 | Vars: vars, 1112 | Pkgs: pkgs, 1113 | } 1114 | consts = make(map[string] reflect.Value) 1115 | 1116 | funcs = make(map[string] reflect.Value) 1117 | funcs["NewSource"] = reflect.ValueOf(rand.NewSource) 1118 | funcs["New"] = reflect.ValueOf(rand.New) 1119 | funcs["Seed"] = reflect.ValueOf(rand.Seed) 1120 | funcs["Int63"] = reflect.ValueOf(rand.Int63) 1121 | funcs["Uint32"] = reflect.ValueOf(rand.Uint32) 1122 | funcs["Int31"] = reflect.ValueOf(rand.Int31) 1123 | funcs["Int"] = reflect.ValueOf(rand.Int) 1124 | funcs["Int63n"] = reflect.ValueOf(rand.Int63n) 1125 | funcs["Int31n"] = reflect.ValueOf(rand.Int31n) 1126 | funcs["Intn"] = reflect.ValueOf(rand.Intn) 1127 | funcs["Float64"] = reflect.ValueOf(rand.Float64) 1128 | funcs["Float32"] = reflect.ValueOf(rand.Float32) 1129 | funcs["Perm"] = reflect.ValueOf(rand.Perm) 1130 | funcs["NormFloat64"] = reflect.ValueOf(rand.NormFloat64) 1131 | funcs["ExpFloat64"] = reflect.ValueOf(rand.ExpFloat64) 1132 | funcs["NewZipf"] = reflect.ValueOf(rand.NewZipf) 1133 | 1134 | types = make(map[string] reflect.Type) 1135 | types["Source"] = reflect.TypeOf(new(rand.Source)).Elem() 1136 | types["Rand"] = reflect.TypeOf(new(rand.Rand)).Elem() 1137 | types["Zipf"] = reflect.TypeOf(new(rand.Zipf)).Elem() 1138 | 1139 | vars = make(map[string] reflect.Value) 1140 | pkgs["rand"] = &eval.SimpleEnv { 1141 | Consts: consts, 1142 | Funcs: funcs, 1143 | Types: types, 1144 | Vars: vars, 1145 | Pkgs: pkgs, 1146 | } 1147 | consts = make(map[string] reflect.Value) 1148 | consts["O_RDONLY"] = reflect.ValueOf(os.O_RDONLY) 1149 | consts["O_WRONLY"] = reflect.ValueOf(os.O_WRONLY) 1150 | consts["O_RDWR"] = reflect.ValueOf(os.O_RDWR) 1151 | consts["O_APPEND"] = reflect.ValueOf(os.O_APPEND) 1152 | consts["O_CREATE"] = reflect.ValueOf(os.O_CREATE) 1153 | consts["O_EXCL"] = reflect.ValueOf(os.O_EXCL) 1154 | consts["O_SYNC"] = reflect.ValueOf(os.O_SYNC) 1155 | consts["O_TRUNC"] = reflect.ValueOf(os.O_TRUNC) 1156 | consts["SEEK_SET"] = reflect.ValueOf(os.SEEK_SET) 1157 | consts["SEEK_CUR"] = reflect.ValueOf(os.SEEK_CUR) 1158 | consts["SEEK_END"] = reflect.ValueOf(os.SEEK_END) 1159 | consts["DevNull"] = reflect.ValueOf(os.DevNull) 1160 | consts["PathSeparator"] = reflect.ValueOf(os.PathSeparator) 1161 | consts["PathListSeparator"] = reflect.ValueOf(os.PathListSeparator) 1162 | consts["ModeDir"] = reflect.ValueOf(os.ModeDir) 1163 | consts["ModeAppend"] = reflect.ValueOf(os.ModeAppend) 1164 | consts["ModeExclusive"] = reflect.ValueOf(os.ModeExclusive) 1165 | consts["ModeTemporary"] = reflect.ValueOf(os.ModeTemporary) 1166 | consts["ModeSymlink"] = reflect.ValueOf(os.ModeSymlink) 1167 | consts["ModeDevice"] = reflect.ValueOf(os.ModeDevice) 1168 | consts["ModeNamedPipe"] = reflect.ValueOf(os.ModeNamedPipe) 1169 | consts["ModeSocket"] = reflect.ValueOf(os.ModeSocket) 1170 | consts["ModeSetuid"] = reflect.ValueOf(os.ModeSetuid) 1171 | consts["ModeSetgid"] = reflect.ValueOf(os.ModeSetgid) 1172 | consts["ModeCharDevice"] = reflect.ValueOf(os.ModeCharDevice) 1173 | consts["ModeSticky"] = reflect.ValueOf(os.ModeSticky) 1174 | consts["ModeType"] = reflect.ValueOf(os.ModeType) 1175 | consts["ModePerm"] = reflect.ValueOf(os.ModePerm) 1176 | 1177 | funcs = make(map[string] reflect.Value) 1178 | funcs["FindProcess"] = reflect.ValueOf(os.FindProcess) 1179 | funcs["StartProcess"] = reflect.ValueOf(os.StartProcess) 1180 | funcs["Hostname"] = reflect.ValueOf(os.Hostname) 1181 | funcs["Expand"] = reflect.ValueOf(os.Expand) 1182 | funcs["ExpandEnv"] = reflect.ValueOf(os.ExpandEnv) 1183 | funcs["Getenv"] = reflect.ValueOf(os.Getenv) 1184 | funcs["Setenv"] = reflect.ValueOf(os.Setenv) 1185 | funcs["Unsetenv"] = reflect.ValueOf(os.Unsetenv) 1186 | funcs["Clearenv"] = reflect.ValueOf(os.Clearenv) 1187 | funcs["Environ"] = reflect.ValueOf(os.Environ) 1188 | funcs["NewSyscallError"] = reflect.ValueOf(os.NewSyscallError) 1189 | funcs["IsExist"] = reflect.ValueOf(os.IsExist) 1190 | funcs["IsNotExist"] = reflect.ValueOf(os.IsNotExist) 1191 | funcs["IsPermission"] = reflect.ValueOf(os.IsPermission) 1192 | funcs["Getpid"] = reflect.ValueOf(os.Getpid) 1193 | funcs["Getppid"] = reflect.ValueOf(os.Getppid) 1194 | funcs["Mkdir"] = reflect.ValueOf(os.Mkdir) 1195 | funcs["Chdir"] = reflect.ValueOf(os.Chdir) 1196 | funcs["Open"] = reflect.ValueOf(os.Open) 1197 | funcs["Create"] = reflect.ValueOf(os.Create) 1198 | funcs["Rename"] = reflect.ValueOf(os.Rename) 1199 | funcs["Readlink"] = reflect.ValueOf(os.Readlink) 1200 | funcs["Chmod"] = reflect.ValueOf(os.Chmod) 1201 | funcs["Chown"] = reflect.ValueOf(os.Chown) 1202 | funcs["Lchown"] = reflect.ValueOf(os.Lchown) 1203 | funcs["Chtimes"] = reflect.ValueOf(os.Chtimes) 1204 | funcs["NewFile"] = reflect.ValueOf(os.NewFile) 1205 | funcs["OpenFile"] = reflect.ValueOf(os.OpenFile) 1206 | funcs["Stat"] = reflect.ValueOf(os.Stat) 1207 | funcs["Lstat"] = reflect.ValueOf(os.Lstat) 1208 | funcs["Truncate"] = reflect.ValueOf(os.Truncate) 1209 | funcs["Remove"] = reflect.ValueOf(os.Remove) 1210 | funcs["TempDir"] = reflect.ValueOf(os.TempDir) 1211 | funcs["Link"] = reflect.ValueOf(os.Link) 1212 | funcs["Symlink"] = reflect.ValueOf(os.Symlink) 1213 | funcs["Getwd"] = reflect.ValueOf(os.Getwd) 1214 | funcs["MkdirAll"] = reflect.ValueOf(os.MkdirAll) 1215 | funcs["RemoveAll"] = reflect.ValueOf(os.RemoveAll) 1216 | funcs["IsPathSeparator"] = reflect.ValueOf(os.IsPathSeparator) 1217 | funcs["Pipe"] = reflect.ValueOf(os.Pipe) 1218 | funcs["Getuid"] = reflect.ValueOf(os.Getuid) 1219 | funcs["Geteuid"] = reflect.ValueOf(os.Geteuid) 1220 | funcs["Getgid"] = reflect.ValueOf(os.Getgid) 1221 | funcs["Getegid"] = reflect.ValueOf(os.Getegid) 1222 | funcs["Getgroups"] = reflect.ValueOf(os.Getgroups) 1223 | funcs["Exit"] = reflect.ValueOf(os.Exit) 1224 | funcs["Getpagesize"] = reflect.ValueOf(os.Getpagesize) 1225 | funcs["SameFile"] = reflect.ValueOf(os.SameFile) 1226 | 1227 | types = make(map[string] reflect.Type) 1228 | types["PathError"] = reflect.TypeOf(new(os.PathError)).Elem() 1229 | types["SyscallError"] = reflect.TypeOf(new(os.SyscallError)).Elem() 1230 | types["Process"] = reflect.TypeOf(new(os.Process)).Elem() 1231 | types["ProcAttr"] = reflect.TypeOf(new(os.ProcAttr)).Elem() 1232 | types["Signal"] = reflect.TypeOf(new(os.Signal)).Elem() 1233 | types["ProcessState"] = reflect.TypeOf(new(os.ProcessState)).Elem() 1234 | types["LinkError"] = reflect.TypeOf(new(os.LinkError)).Elem() 1235 | types["File"] = reflect.TypeOf(new(os.File)).Elem() 1236 | types["FileInfo"] = reflect.TypeOf(new(os.FileInfo)).Elem() 1237 | types["FileMode"] = reflect.TypeOf(new(os.FileMode)).Elem() 1238 | 1239 | vars = make(map[string] reflect.Value) 1240 | vars["ErrInvalid"] = reflect.ValueOf(&os.ErrInvalid) 1241 | vars["ErrPermission"] = reflect.ValueOf(&os.ErrPermission) 1242 | vars["ErrExist"] = reflect.ValueOf(&os.ErrExist) 1243 | vars["ErrNotExist"] = reflect.ValueOf(&os.ErrNotExist) 1244 | vars["Interrupt"] = reflect.ValueOf(&os.Interrupt) 1245 | vars["Kill"] = reflect.ValueOf(&os.Kill) 1246 | vars["Stdin"] = reflect.ValueOf(&os.Stdin) 1247 | vars["Stdout"] = reflect.ValueOf(&os.Stdout) 1248 | vars["Stderr"] = reflect.ValueOf(&os.Stderr) 1249 | vars["Args"] = reflect.ValueOf(&os.Args) 1250 | pkgs["os"] = &eval.SimpleEnv { 1251 | Consts: consts, 1252 | Funcs: funcs, 1253 | Types: types, 1254 | Vars: vars, 1255 | Pkgs: pkgs, 1256 | } 1257 | consts = make(map[string] reflect.Value) 1258 | 1259 | funcs = make(map[string] reflect.Value) 1260 | funcs["Command"] = reflect.ValueOf(exec.Command) 1261 | funcs["LookPath"] = reflect.ValueOf(exec.LookPath) 1262 | 1263 | types = make(map[string] reflect.Type) 1264 | types["Error"] = reflect.TypeOf(new(exec.Error)).Elem() 1265 | types["Cmd"] = reflect.TypeOf(new(exec.Cmd)).Elem() 1266 | types["ExitError"] = reflect.TypeOf(new(exec.ExitError)).Elem() 1267 | 1268 | vars = make(map[string] reflect.Value) 1269 | vars["ErrNotFound"] = reflect.ValueOf(&exec.ErrNotFound) 1270 | pkgs["exec"] = &eval.SimpleEnv { 1271 | Consts: consts, 1272 | Funcs: funcs, 1273 | Types: types, 1274 | Vars: vars, 1275 | Pkgs: pkgs, 1276 | } 1277 | consts = make(map[string] reflect.Value) 1278 | consts["Separator"] = reflect.ValueOf(filepath.Separator) 1279 | consts["ListSeparator"] = reflect.ValueOf(filepath.ListSeparator) 1280 | 1281 | funcs = make(map[string] reflect.Value) 1282 | funcs["Match"] = reflect.ValueOf(filepath.Match) 1283 | funcs["Glob"] = reflect.ValueOf(filepath.Glob) 1284 | funcs["Clean"] = reflect.ValueOf(filepath.Clean) 1285 | funcs["ToSlash"] = reflect.ValueOf(filepath.ToSlash) 1286 | funcs["FromSlash"] = reflect.ValueOf(filepath.FromSlash) 1287 | funcs["SplitList"] = reflect.ValueOf(filepath.SplitList) 1288 | funcs["Split"] = reflect.ValueOf(filepath.Split) 1289 | funcs["Join"] = reflect.ValueOf(filepath.Join) 1290 | funcs["Ext"] = reflect.ValueOf(filepath.Ext) 1291 | funcs["EvalSymlinks"] = reflect.ValueOf(filepath.EvalSymlinks) 1292 | funcs["Abs"] = reflect.ValueOf(filepath.Abs) 1293 | funcs["Rel"] = reflect.ValueOf(filepath.Rel) 1294 | funcs["Walk"] = reflect.ValueOf(filepath.Walk) 1295 | funcs["Base"] = reflect.ValueOf(filepath.Base) 1296 | funcs["Dir"] = reflect.ValueOf(filepath.Dir) 1297 | funcs["VolumeName"] = reflect.ValueOf(filepath.VolumeName) 1298 | funcs["IsAbs"] = reflect.ValueOf(filepath.IsAbs) 1299 | funcs["HasPrefix"] = reflect.ValueOf(filepath.HasPrefix) 1300 | 1301 | types = make(map[string] reflect.Type) 1302 | types["WalkFunc"] = reflect.TypeOf(new(filepath.WalkFunc)).Elem() 1303 | 1304 | vars = make(map[string] reflect.Value) 1305 | vars["ErrBadPattern"] = reflect.ValueOf(&filepath.ErrBadPattern) 1306 | vars["SkipDir"] = reflect.ValueOf(&filepath.SkipDir) 1307 | pkgs["filepath"] = &eval.SimpleEnv { 1308 | Consts: consts, 1309 | Funcs: funcs, 1310 | Types: types, 1311 | Vars: vars, 1312 | Pkgs: pkgs, 1313 | } 1314 | consts = make(map[string] reflect.Value) 1315 | consts["Invalid"] = reflect.ValueOf(reflect.Invalid) 1316 | consts["Bool"] = reflect.ValueOf(reflect.Bool) 1317 | consts["Int"] = reflect.ValueOf(reflect.Int) 1318 | consts["Int8"] = reflect.ValueOf(reflect.Int8) 1319 | consts["Int16"] = reflect.ValueOf(reflect.Int16) 1320 | consts["Int32"] = reflect.ValueOf(reflect.Int32) 1321 | consts["Int64"] = reflect.ValueOf(reflect.Int64) 1322 | consts["Uint"] = reflect.ValueOf(reflect.Uint) 1323 | consts["Uint8"] = reflect.ValueOf(reflect.Uint8) 1324 | consts["Uint16"] = reflect.ValueOf(reflect.Uint16) 1325 | consts["Uint32"] = reflect.ValueOf(reflect.Uint32) 1326 | consts["Uint64"] = reflect.ValueOf(reflect.Uint64) 1327 | consts["Uintptr"] = reflect.ValueOf(reflect.Uintptr) 1328 | consts["Float32"] = reflect.ValueOf(reflect.Float32) 1329 | consts["Float64"] = reflect.ValueOf(reflect.Float64) 1330 | consts["Complex64"] = reflect.ValueOf(reflect.Complex64) 1331 | consts["Complex128"] = reflect.ValueOf(reflect.Complex128) 1332 | consts["Array"] = reflect.ValueOf(reflect.Array) 1333 | consts["Chan"] = reflect.ValueOf(reflect.Chan) 1334 | consts["Func"] = reflect.ValueOf(reflect.Func) 1335 | consts["Interface"] = reflect.ValueOf(reflect.Interface) 1336 | consts["Map"] = reflect.ValueOf(reflect.Map) 1337 | consts["Ptr"] = reflect.ValueOf(reflect.Ptr) 1338 | consts["Slice"] = reflect.ValueOf(reflect.Slice) 1339 | consts["String"] = reflect.ValueOf(reflect.String) 1340 | consts["Struct"] = reflect.ValueOf(reflect.Struct) 1341 | consts["UnsafePointer"] = reflect.ValueOf(reflect.UnsafePointer) 1342 | consts["RecvDir"] = reflect.ValueOf(reflect.RecvDir) 1343 | consts["SendDir"] = reflect.ValueOf(reflect.SendDir) 1344 | consts["BothDir"] = reflect.ValueOf(reflect.BothDir) 1345 | consts["SelectSend"] = reflect.ValueOf(reflect.SelectSend) 1346 | consts["SelectRecv"] = reflect.ValueOf(reflect.SelectRecv) 1347 | consts["SelectDefault"] = reflect.ValueOf(reflect.SelectDefault) 1348 | 1349 | funcs = make(map[string] reflect.Value) 1350 | funcs["DeepEqual"] = reflect.ValueOf(reflect.DeepEqual) 1351 | funcs["MakeFunc"] = reflect.ValueOf(reflect.MakeFunc) 1352 | funcs["TypeOf"] = reflect.ValueOf(reflect.TypeOf) 1353 | funcs["PtrTo"] = reflect.ValueOf(reflect.PtrTo) 1354 | funcs["ChanOf"] = reflect.ValueOf(reflect.ChanOf) 1355 | funcs["MapOf"] = reflect.ValueOf(reflect.MapOf) 1356 | funcs["SliceOf"] = reflect.ValueOf(reflect.SliceOf) 1357 | funcs["Append"] = reflect.ValueOf(reflect.Append) 1358 | funcs["AppendSlice"] = reflect.ValueOf(reflect.AppendSlice) 1359 | funcs["Copy"] = reflect.ValueOf(reflect.Copy) 1360 | funcs["Select"] = reflect.ValueOf(reflect.Select) 1361 | funcs["MakeSlice"] = reflect.ValueOf(reflect.MakeSlice) 1362 | funcs["MakeChan"] = reflect.ValueOf(reflect.MakeChan) 1363 | funcs["MakeMap"] = reflect.ValueOf(reflect.MakeMap) 1364 | funcs["Indirect"] = reflect.ValueOf(reflect.Indirect) 1365 | funcs["ValueOf"] = reflect.ValueOf(reflect.ValueOf) 1366 | funcs["Zero"] = reflect.ValueOf(reflect.Zero) 1367 | funcs["New"] = reflect.ValueOf(reflect.New) 1368 | funcs["NewAt"] = reflect.ValueOf(reflect.NewAt) 1369 | 1370 | types = make(map[string] reflect.Type) 1371 | types["Type"] = reflect.TypeOf(new(reflect.Type)).Elem() 1372 | types["Kind"] = reflect.TypeOf(new(reflect.Kind)).Elem() 1373 | types["ChanDir"] = reflect.TypeOf(new(reflect.ChanDir)).Elem() 1374 | types["Method"] = reflect.TypeOf(new(reflect.Method)).Elem() 1375 | types["StructField"] = reflect.TypeOf(new(reflect.StructField)).Elem() 1376 | types["StructTag"] = reflect.TypeOf(new(reflect.StructTag)).Elem() 1377 | types["Value"] = reflect.TypeOf(new(reflect.Value)).Elem() 1378 | types["ValueError"] = reflect.TypeOf(new(reflect.ValueError)).Elem() 1379 | types["StringHeader"] = reflect.TypeOf(new(reflect.StringHeader)).Elem() 1380 | types["SliceHeader"] = reflect.TypeOf(new(reflect.SliceHeader)).Elem() 1381 | types["SelectDir"] = reflect.TypeOf(new(reflect.SelectDir)).Elem() 1382 | types["SelectCase"] = reflect.TypeOf(new(reflect.SelectCase)).Elem() 1383 | 1384 | vars = make(map[string] reflect.Value) 1385 | pkgs["reflect"] = &eval.SimpleEnv { 1386 | Consts: consts, 1387 | Funcs: funcs, 1388 | Types: types, 1389 | Vars: vars, 1390 | Pkgs: pkgs, 1391 | } 1392 | consts = make(map[string] reflect.Value) 1393 | 1394 | funcs = make(map[string] reflect.Value) 1395 | funcs["Compile"] = reflect.ValueOf(regexp.Compile) 1396 | funcs["CompilePOSIX"] = reflect.ValueOf(regexp.CompilePOSIX) 1397 | funcs["MustCompile"] = reflect.ValueOf(regexp.MustCompile) 1398 | funcs["MustCompilePOSIX"] = reflect.ValueOf(regexp.MustCompilePOSIX) 1399 | funcs["MatchReader"] = reflect.ValueOf(regexp.MatchReader) 1400 | funcs["MatchString"] = reflect.ValueOf(regexp.MatchString) 1401 | funcs["Match"] = reflect.ValueOf(regexp.Match) 1402 | funcs["QuoteMeta"] = reflect.ValueOf(regexp.QuoteMeta) 1403 | 1404 | types = make(map[string] reflect.Type) 1405 | types["Regexp"] = reflect.TypeOf(new(regexp.Regexp)).Elem() 1406 | 1407 | vars = make(map[string] reflect.Value) 1408 | pkgs["regexp"] = &eval.SimpleEnv { 1409 | Consts: consts, 1410 | Funcs: funcs, 1411 | Types: types, 1412 | Vars: vars, 1413 | Pkgs: pkgs, 1414 | } 1415 | consts = make(map[string] reflect.Value) 1416 | consts["ErrInternalError"] = reflect.ValueOf(syntax.ErrInternalError) 1417 | consts["ErrInvalidCharClass"] = reflect.ValueOf(syntax.ErrInvalidCharClass) 1418 | consts["ErrInvalidCharRange"] = reflect.ValueOf(syntax.ErrInvalidCharRange) 1419 | consts["ErrInvalidEscape"] = reflect.ValueOf(syntax.ErrInvalidEscape) 1420 | consts["ErrInvalidNamedCapture"] = reflect.ValueOf(syntax.ErrInvalidNamedCapture) 1421 | consts["ErrInvalidPerlOp"] = reflect.ValueOf(syntax.ErrInvalidPerlOp) 1422 | consts["ErrInvalidRepeatOp"] = reflect.ValueOf(syntax.ErrInvalidRepeatOp) 1423 | consts["ErrInvalidRepeatSize"] = reflect.ValueOf(syntax.ErrInvalidRepeatSize) 1424 | consts["ErrInvalidUTF8"] = reflect.ValueOf(syntax.ErrInvalidUTF8) 1425 | consts["ErrMissingBracket"] = reflect.ValueOf(syntax.ErrMissingBracket) 1426 | consts["ErrMissingParen"] = reflect.ValueOf(syntax.ErrMissingParen) 1427 | consts["ErrMissingRepeatArgument"] = reflect.ValueOf(syntax.ErrMissingRepeatArgument) 1428 | consts["ErrTrailingBackslash"] = reflect.ValueOf(syntax.ErrTrailingBackslash) 1429 | consts["ErrUnexpectedParen"] = reflect.ValueOf(syntax.ErrUnexpectedParen) 1430 | consts["FoldCase"] = reflect.ValueOf(syntax.FoldCase) 1431 | consts["Literal"] = reflect.ValueOf(syntax.Literal) 1432 | consts["ClassNL"] = reflect.ValueOf(syntax.ClassNL) 1433 | consts["DotNL"] = reflect.ValueOf(syntax.DotNL) 1434 | consts["OneLine"] = reflect.ValueOf(syntax.OneLine) 1435 | consts["NonGreedy"] = reflect.ValueOf(syntax.NonGreedy) 1436 | consts["PerlX"] = reflect.ValueOf(syntax.PerlX) 1437 | consts["UnicodeGroups"] = reflect.ValueOf(syntax.UnicodeGroups) 1438 | consts["WasDollar"] = reflect.ValueOf(syntax.WasDollar) 1439 | consts["Simple"] = reflect.ValueOf(syntax.Simple) 1440 | consts["MatchNL"] = reflect.ValueOf(syntax.MatchNL) 1441 | consts["Perl"] = reflect.ValueOf(syntax.Perl) 1442 | consts["POSIX"] = reflect.ValueOf(syntax.POSIX) 1443 | consts["InstAlt"] = reflect.ValueOf(syntax.InstAlt) 1444 | consts["InstAltMatch"] = reflect.ValueOf(syntax.InstAltMatch) 1445 | consts["InstCapture"] = reflect.ValueOf(syntax.InstCapture) 1446 | consts["InstEmptyWidth"] = reflect.ValueOf(syntax.InstEmptyWidth) 1447 | consts["InstMatch"] = reflect.ValueOf(syntax.InstMatch) 1448 | consts["InstFail"] = reflect.ValueOf(syntax.InstFail) 1449 | consts["InstNop"] = reflect.ValueOf(syntax.InstNop) 1450 | consts["InstRune"] = reflect.ValueOf(syntax.InstRune) 1451 | consts["InstRune1"] = reflect.ValueOf(syntax.InstRune1) 1452 | consts["InstRuneAny"] = reflect.ValueOf(syntax.InstRuneAny) 1453 | consts["InstRuneAnyNotNL"] = reflect.ValueOf(syntax.InstRuneAnyNotNL) 1454 | consts["EmptyBeginLine"] = reflect.ValueOf(syntax.EmptyBeginLine) 1455 | consts["EmptyEndLine"] = reflect.ValueOf(syntax.EmptyEndLine) 1456 | consts["EmptyBeginText"] = reflect.ValueOf(syntax.EmptyBeginText) 1457 | consts["EmptyEndText"] = reflect.ValueOf(syntax.EmptyEndText) 1458 | consts["EmptyWordBoundary"] = reflect.ValueOf(syntax.EmptyWordBoundary) 1459 | consts["EmptyNoWordBoundary"] = reflect.ValueOf(syntax.EmptyNoWordBoundary) 1460 | consts["OpNoMatch"] = reflect.ValueOf(syntax.OpNoMatch) 1461 | consts["OpEmptyMatch"] = reflect.ValueOf(syntax.OpEmptyMatch) 1462 | consts["OpLiteral"] = reflect.ValueOf(syntax.OpLiteral) 1463 | consts["OpCharClass"] = reflect.ValueOf(syntax.OpCharClass) 1464 | consts["OpAnyCharNotNL"] = reflect.ValueOf(syntax.OpAnyCharNotNL) 1465 | consts["OpAnyChar"] = reflect.ValueOf(syntax.OpAnyChar) 1466 | consts["OpBeginLine"] = reflect.ValueOf(syntax.OpBeginLine) 1467 | consts["OpEndLine"] = reflect.ValueOf(syntax.OpEndLine) 1468 | consts["OpBeginText"] = reflect.ValueOf(syntax.OpBeginText) 1469 | consts["OpEndText"] = reflect.ValueOf(syntax.OpEndText) 1470 | consts["OpWordBoundary"] = reflect.ValueOf(syntax.OpWordBoundary) 1471 | consts["OpNoWordBoundary"] = reflect.ValueOf(syntax.OpNoWordBoundary) 1472 | consts["OpCapture"] = reflect.ValueOf(syntax.OpCapture) 1473 | consts["OpStar"] = reflect.ValueOf(syntax.OpStar) 1474 | consts["OpPlus"] = reflect.ValueOf(syntax.OpPlus) 1475 | consts["OpQuest"] = reflect.ValueOf(syntax.OpQuest) 1476 | consts["OpRepeat"] = reflect.ValueOf(syntax.OpRepeat) 1477 | consts["OpConcat"] = reflect.ValueOf(syntax.OpConcat) 1478 | consts["OpAlternate"] = reflect.ValueOf(syntax.OpAlternate) 1479 | 1480 | funcs = make(map[string] reflect.Value) 1481 | funcs["Compile"] = reflect.ValueOf(syntax.Compile) 1482 | funcs["Parse"] = reflect.ValueOf(syntax.Parse) 1483 | funcs["EmptyOpContext"] = reflect.ValueOf(syntax.EmptyOpContext) 1484 | funcs["IsWordChar"] = reflect.ValueOf(syntax.IsWordChar) 1485 | 1486 | types = make(map[string] reflect.Type) 1487 | types["Error"] = reflect.TypeOf(new(syntax.Error)).Elem() 1488 | types["ErrorCode"] = reflect.TypeOf(new(syntax.ErrorCode)).Elem() 1489 | types["Flags"] = reflect.TypeOf(new(syntax.Flags)).Elem() 1490 | types["Prog"] = reflect.TypeOf(new(syntax.Prog)).Elem() 1491 | types["InstOp"] = reflect.TypeOf(new(syntax.InstOp)).Elem() 1492 | types["EmptyOp"] = reflect.TypeOf(new(syntax.EmptyOp)).Elem() 1493 | types["Inst"] = reflect.TypeOf(new(syntax.Inst)).Elem() 1494 | types["Regexp"] = reflect.TypeOf(new(syntax.Regexp)).Elem() 1495 | types["Op"] = reflect.TypeOf(new(syntax.Op)).Elem() 1496 | 1497 | vars = make(map[string] reflect.Value) 1498 | pkgs["syntax"] = &eval.SimpleEnv { 1499 | Consts: consts, 1500 | Funcs: funcs, 1501 | Types: types, 1502 | Vars: vars, 1503 | Pkgs: pkgs, 1504 | } 1505 | consts = make(map[string] reflect.Value) 1506 | consts["Compiler"] = reflect.ValueOf(runtime.Compiler) 1507 | consts["GOOS"] = reflect.ValueOf(runtime.GOOS) 1508 | consts["GOARCH"] = reflect.ValueOf(runtime.GOARCH) 1509 | 1510 | funcs = make(map[string] reflect.Value) 1511 | funcs["SetCPUProfileRate"] = reflect.ValueOf(runtime.SetCPUProfileRate) 1512 | funcs["CPUProfile"] = reflect.ValueOf(runtime.CPUProfile) 1513 | funcs["Breakpoint"] = reflect.ValueOf(runtime.Breakpoint) 1514 | funcs["LockOSThread"] = reflect.ValueOf(runtime.LockOSThread) 1515 | funcs["UnlockOSThread"] = reflect.ValueOf(runtime.UnlockOSThread) 1516 | funcs["GOMAXPROCS"] = reflect.ValueOf(runtime.GOMAXPROCS) 1517 | funcs["NumCPU"] = reflect.ValueOf(runtime.NumCPU) 1518 | funcs["NumCgoCall"] = reflect.ValueOf(runtime.NumCgoCall) 1519 | funcs["NumGoroutine"] = reflect.ValueOf(runtime.NumGoroutine) 1520 | funcs["Caller"] = reflect.ValueOf(runtime.Caller) 1521 | funcs["Callers"] = reflect.ValueOf(runtime.Callers) 1522 | funcs["GOROOT"] = reflect.ValueOf(runtime.GOROOT) 1523 | funcs["Version"] = reflect.ValueOf(runtime.Version) 1524 | funcs["GC"] = reflect.ValueOf(runtime.GC) 1525 | funcs["SetFinalizer"] = reflect.ValueOf(runtime.SetFinalizer) 1526 | funcs["ReadMemStats"] = reflect.ValueOf(runtime.ReadMemStats) 1527 | funcs["SetBlockProfileRate"] = reflect.ValueOf(runtime.SetBlockProfileRate) 1528 | funcs["MemProfile"] = reflect.ValueOf(runtime.MemProfile) 1529 | funcs["BlockProfile"] = reflect.ValueOf(runtime.BlockProfile) 1530 | funcs["ThreadCreateProfile"] = reflect.ValueOf(runtime.ThreadCreateProfile) 1531 | funcs["GoroutineProfile"] = reflect.ValueOf(runtime.GoroutineProfile) 1532 | funcs["Stack"] = reflect.ValueOf(runtime.Stack) 1533 | funcs["Goexit"] = reflect.ValueOf(runtime.Goexit) 1534 | funcs["Gosched"] = reflect.ValueOf(runtime.Gosched) 1535 | funcs["FuncForPC"] = reflect.ValueOf(runtime.FuncForPC) 1536 | 1537 | types = make(map[string] reflect.Type) 1538 | types["Error"] = reflect.TypeOf(new(runtime.Error)).Elem() 1539 | types["TypeAssertionError"] = reflect.TypeOf(new(runtime.TypeAssertionError)).Elem() 1540 | types["MemStats"] = reflect.TypeOf(new(runtime.MemStats)).Elem() 1541 | types["StackRecord"] = reflect.TypeOf(new(runtime.StackRecord)).Elem() 1542 | types["MemProfileRecord"] = reflect.TypeOf(new(runtime.MemProfileRecord)).Elem() 1543 | types["BlockProfileRecord"] = reflect.TypeOf(new(runtime.BlockProfileRecord)).Elem() 1544 | types["Func"] = reflect.TypeOf(new(runtime.Func)).Elem() 1545 | 1546 | vars = make(map[string] reflect.Value) 1547 | vars["MemProfileRate"] = reflect.ValueOf(&runtime.MemProfileRate) 1548 | pkgs["runtime"] = &eval.SimpleEnv { 1549 | Consts: consts, 1550 | Funcs: funcs, 1551 | Types: types, 1552 | Vars: vars, 1553 | Pkgs: pkgs, 1554 | } 1555 | consts = make(map[string] reflect.Value) 1556 | 1557 | funcs = make(map[string] reflect.Value) 1558 | funcs["NewProfile"] = reflect.ValueOf(pprof.NewProfile) 1559 | funcs["Lookup"] = reflect.ValueOf(pprof.Lookup) 1560 | funcs["Profiles"] = reflect.ValueOf(pprof.Profiles) 1561 | funcs["WriteHeapProfile"] = reflect.ValueOf(pprof.WriteHeapProfile) 1562 | funcs["StartCPUProfile"] = reflect.ValueOf(pprof.StartCPUProfile) 1563 | funcs["StopCPUProfile"] = reflect.ValueOf(pprof.StopCPUProfile) 1564 | 1565 | types = make(map[string] reflect.Type) 1566 | types["Profile"] = reflect.TypeOf(new(pprof.Profile)).Elem() 1567 | 1568 | vars = make(map[string] reflect.Value) 1569 | pkgs["pprof"] = &eval.SimpleEnv { 1570 | Consts: consts, 1571 | Funcs: funcs, 1572 | Types: types, 1573 | Vars: vars, 1574 | Pkgs: pkgs, 1575 | } 1576 | consts = make(map[string] reflect.Value) 1577 | 1578 | funcs = make(map[string] reflect.Value) 1579 | funcs["Search"] = reflect.ValueOf(sort.Search) 1580 | funcs["SearchInts"] = reflect.ValueOf(sort.SearchInts) 1581 | funcs["SearchFloat64s"] = reflect.ValueOf(sort.SearchFloat64s) 1582 | funcs["SearchStrings"] = reflect.ValueOf(sort.SearchStrings) 1583 | funcs["Sort"] = reflect.ValueOf(sort.Sort) 1584 | funcs["Reverse"] = reflect.ValueOf(sort.Reverse) 1585 | funcs["IsSorted"] = reflect.ValueOf(sort.IsSorted) 1586 | funcs["Ints"] = reflect.ValueOf(sort.Ints) 1587 | funcs["Float64s"] = reflect.ValueOf(sort.Float64s) 1588 | funcs["Strings"] = reflect.ValueOf(sort.Strings) 1589 | funcs["IntsAreSorted"] = reflect.ValueOf(sort.IntsAreSorted) 1590 | funcs["Float64sAreSorted"] = reflect.ValueOf(sort.Float64sAreSorted) 1591 | funcs["StringsAreSorted"] = reflect.ValueOf(sort.StringsAreSorted) 1592 | funcs["Stable"] = reflect.ValueOf(sort.Stable) 1593 | 1594 | types = make(map[string] reflect.Type) 1595 | types["Interface"] = reflect.TypeOf(new(sort.Interface)).Elem() 1596 | types["IntSlice"] = reflect.TypeOf(new(sort.IntSlice)).Elem() 1597 | types["Float64Slice"] = reflect.TypeOf(new(sort.Float64Slice)).Elem() 1598 | types["StringSlice"] = reflect.TypeOf(new(sort.StringSlice)).Elem() 1599 | 1600 | vars = make(map[string] reflect.Value) 1601 | pkgs["sort"] = &eval.SimpleEnv { 1602 | Consts: consts, 1603 | Funcs: funcs, 1604 | Types: types, 1605 | Vars: vars, 1606 | Pkgs: pkgs, 1607 | } 1608 | consts = make(map[string] reflect.Value) 1609 | consts["IntSize"] = reflect.ValueOf(strconv.IntSize) 1610 | 1611 | funcs = make(map[string] reflect.Value) 1612 | funcs["ParseBool"] = reflect.ValueOf(strconv.ParseBool) 1613 | funcs["FormatBool"] = reflect.ValueOf(strconv.FormatBool) 1614 | funcs["AppendBool"] = reflect.ValueOf(strconv.AppendBool) 1615 | funcs["ParseFloat"] = reflect.ValueOf(strconv.ParseFloat) 1616 | funcs["ParseUint"] = reflect.ValueOf(strconv.ParseUint) 1617 | funcs["ParseInt"] = reflect.ValueOf(strconv.ParseInt) 1618 | funcs["Atoi"] = reflect.ValueOf(strconv.Atoi) 1619 | funcs["FormatFloat"] = reflect.ValueOf(strconv.FormatFloat) 1620 | funcs["AppendFloat"] = reflect.ValueOf(strconv.AppendFloat) 1621 | funcs["FormatUint"] = reflect.ValueOf(strconv.FormatUint) 1622 | funcs["FormatInt"] = reflect.ValueOf(strconv.FormatInt) 1623 | funcs["Itoa"] = reflect.ValueOf(strconv.Itoa) 1624 | funcs["AppendInt"] = reflect.ValueOf(strconv.AppendInt) 1625 | funcs["AppendUint"] = reflect.ValueOf(strconv.AppendUint) 1626 | funcs["Quote"] = reflect.ValueOf(strconv.Quote) 1627 | funcs["AppendQuote"] = reflect.ValueOf(strconv.AppendQuote) 1628 | funcs["QuoteToASCII"] = reflect.ValueOf(strconv.QuoteToASCII) 1629 | funcs["AppendQuoteToASCII"] = reflect.ValueOf(strconv.AppendQuoteToASCII) 1630 | funcs["QuoteRune"] = reflect.ValueOf(strconv.QuoteRune) 1631 | funcs["AppendQuoteRune"] = reflect.ValueOf(strconv.AppendQuoteRune) 1632 | funcs["QuoteRuneToASCII"] = reflect.ValueOf(strconv.QuoteRuneToASCII) 1633 | funcs["AppendQuoteRuneToASCII"] = reflect.ValueOf(strconv.AppendQuoteRuneToASCII) 1634 | funcs["CanBackquote"] = reflect.ValueOf(strconv.CanBackquote) 1635 | funcs["UnquoteChar"] = reflect.ValueOf(strconv.UnquoteChar) 1636 | funcs["Unquote"] = reflect.ValueOf(strconv.Unquote) 1637 | funcs["IsPrint"] = reflect.ValueOf(strconv.IsPrint) 1638 | 1639 | types = make(map[string] reflect.Type) 1640 | types["NumError"] = reflect.TypeOf(new(strconv.NumError)).Elem() 1641 | 1642 | vars = make(map[string] reflect.Value) 1643 | vars["ErrRange"] = reflect.ValueOf(&strconv.ErrRange) 1644 | vars["ErrSyntax"] = reflect.ValueOf(&strconv.ErrSyntax) 1645 | pkgs["strconv"] = &eval.SimpleEnv { 1646 | Consts: consts, 1647 | Funcs: funcs, 1648 | Types: types, 1649 | Vars: vars, 1650 | Pkgs: pkgs, 1651 | } 1652 | consts = make(map[string] reflect.Value) 1653 | 1654 | funcs = make(map[string] reflect.Value) 1655 | funcs["NewReader"] = reflect.ValueOf(strings.NewReader) 1656 | funcs["NewReplacer"] = reflect.ValueOf(strings.NewReplacer) 1657 | funcs["Count"] = reflect.ValueOf(strings.Count) 1658 | funcs["Contains"] = reflect.ValueOf(strings.Contains) 1659 | funcs["ContainsAny"] = reflect.ValueOf(strings.ContainsAny) 1660 | funcs["ContainsRune"] = reflect.ValueOf(strings.ContainsRune) 1661 | funcs["Index"] = reflect.ValueOf(strings.Index) 1662 | funcs["LastIndex"] = reflect.ValueOf(strings.LastIndex) 1663 | funcs["IndexRune"] = reflect.ValueOf(strings.IndexRune) 1664 | funcs["IndexAny"] = reflect.ValueOf(strings.IndexAny) 1665 | funcs["LastIndexAny"] = reflect.ValueOf(strings.LastIndexAny) 1666 | funcs["SplitN"] = reflect.ValueOf(strings.SplitN) 1667 | funcs["SplitAfterN"] = reflect.ValueOf(strings.SplitAfterN) 1668 | funcs["Split"] = reflect.ValueOf(strings.Split) 1669 | funcs["SplitAfter"] = reflect.ValueOf(strings.SplitAfter) 1670 | funcs["Fields"] = reflect.ValueOf(strings.Fields) 1671 | funcs["FieldsFunc"] = reflect.ValueOf(strings.FieldsFunc) 1672 | funcs["Join"] = reflect.ValueOf(strings.Join) 1673 | funcs["HasPrefix"] = reflect.ValueOf(strings.HasPrefix) 1674 | funcs["HasSuffix"] = reflect.ValueOf(strings.HasSuffix) 1675 | funcs["Map"] = reflect.ValueOf(strings.Map) 1676 | funcs["Repeat"] = reflect.ValueOf(strings.Repeat) 1677 | funcs["ToUpper"] = reflect.ValueOf(strings.ToUpper) 1678 | funcs["ToLower"] = reflect.ValueOf(strings.ToLower) 1679 | funcs["ToTitle"] = reflect.ValueOf(strings.ToTitle) 1680 | funcs["ToUpperSpecial"] = reflect.ValueOf(strings.ToUpperSpecial) 1681 | funcs["ToLowerSpecial"] = reflect.ValueOf(strings.ToLowerSpecial) 1682 | funcs["ToTitleSpecial"] = reflect.ValueOf(strings.ToTitleSpecial) 1683 | funcs["Title"] = reflect.ValueOf(strings.Title) 1684 | funcs["TrimLeftFunc"] = reflect.ValueOf(strings.TrimLeftFunc) 1685 | funcs["TrimRightFunc"] = reflect.ValueOf(strings.TrimRightFunc) 1686 | funcs["TrimFunc"] = reflect.ValueOf(strings.TrimFunc) 1687 | funcs["IndexFunc"] = reflect.ValueOf(strings.IndexFunc) 1688 | funcs["LastIndexFunc"] = reflect.ValueOf(strings.LastIndexFunc) 1689 | funcs["Trim"] = reflect.ValueOf(strings.Trim) 1690 | funcs["TrimLeft"] = reflect.ValueOf(strings.TrimLeft) 1691 | funcs["TrimRight"] = reflect.ValueOf(strings.TrimRight) 1692 | funcs["TrimSpace"] = reflect.ValueOf(strings.TrimSpace) 1693 | funcs["TrimPrefix"] = reflect.ValueOf(strings.TrimPrefix) 1694 | funcs["TrimSuffix"] = reflect.ValueOf(strings.TrimSuffix) 1695 | funcs["Replace"] = reflect.ValueOf(strings.Replace) 1696 | funcs["EqualFold"] = reflect.ValueOf(strings.EqualFold) 1697 | funcs["IndexByte"] = reflect.ValueOf(strings.IndexByte) 1698 | 1699 | types = make(map[string] reflect.Type) 1700 | types["Reader"] = reflect.TypeOf(new(strings.Reader)).Elem() 1701 | types["Replacer"] = reflect.TypeOf(new(strings.Replacer)).Elem() 1702 | 1703 | vars = make(map[string] reflect.Value) 1704 | pkgs["strings"] = &eval.SimpleEnv { 1705 | Consts: consts, 1706 | Funcs: funcs, 1707 | Types: types, 1708 | Vars: vars, 1709 | Pkgs: pkgs, 1710 | } 1711 | consts = make(map[string] reflect.Value) 1712 | 1713 | funcs = make(map[string] reflect.Value) 1714 | funcs["NewCond"] = reflect.ValueOf(sync.NewCond) 1715 | 1716 | types = make(map[string] reflect.Type) 1717 | types["Cond"] = reflect.TypeOf(new(sync.Cond)).Elem() 1718 | types["Mutex"] = reflect.TypeOf(new(sync.Mutex)).Elem() 1719 | types["Locker"] = reflect.TypeOf(new(sync.Locker)).Elem() 1720 | types["Once"] = reflect.TypeOf(new(sync.Once)).Elem() 1721 | types["Pool"] = reflect.TypeOf(new(sync.Pool)).Elem() 1722 | types["RWMutex"] = reflect.TypeOf(new(sync.RWMutex)).Elem() 1723 | types["WaitGroup"] = reflect.TypeOf(new(sync.WaitGroup)).Elem() 1724 | 1725 | vars = make(map[string] reflect.Value) 1726 | pkgs["sync"] = &eval.SimpleEnv { 1727 | Consts: consts, 1728 | Funcs: funcs, 1729 | Types: types, 1730 | Vars: vars, 1731 | Pkgs: pkgs, 1732 | } 1733 | consts = make(map[string] reflect.Value) 1734 | 1735 | funcs = make(map[string] reflect.Value) 1736 | funcs["SwapInt32"] = reflect.ValueOf(atomic.SwapInt32) 1737 | funcs["SwapInt64"] = reflect.ValueOf(atomic.SwapInt64) 1738 | funcs["SwapUint32"] = reflect.ValueOf(atomic.SwapUint32) 1739 | funcs["SwapUint64"] = reflect.ValueOf(atomic.SwapUint64) 1740 | funcs["SwapUintptr"] = reflect.ValueOf(atomic.SwapUintptr) 1741 | funcs["SwapPointer"] = reflect.ValueOf(atomic.SwapPointer) 1742 | funcs["CompareAndSwapInt32"] = reflect.ValueOf(atomic.CompareAndSwapInt32) 1743 | funcs["CompareAndSwapInt64"] = reflect.ValueOf(atomic.CompareAndSwapInt64) 1744 | funcs["CompareAndSwapUint32"] = reflect.ValueOf(atomic.CompareAndSwapUint32) 1745 | funcs["CompareAndSwapUint64"] = reflect.ValueOf(atomic.CompareAndSwapUint64) 1746 | funcs["CompareAndSwapUintptr"] = reflect.ValueOf(atomic.CompareAndSwapUintptr) 1747 | funcs["CompareAndSwapPointer"] = reflect.ValueOf(atomic.CompareAndSwapPointer) 1748 | funcs["AddInt32"] = reflect.ValueOf(atomic.AddInt32) 1749 | funcs["AddUint32"] = reflect.ValueOf(atomic.AddUint32) 1750 | funcs["AddInt64"] = reflect.ValueOf(atomic.AddInt64) 1751 | funcs["AddUint64"] = reflect.ValueOf(atomic.AddUint64) 1752 | funcs["AddUintptr"] = reflect.ValueOf(atomic.AddUintptr) 1753 | funcs["LoadInt32"] = reflect.ValueOf(atomic.LoadInt32) 1754 | funcs["LoadInt64"] = reflect.ValueOf(atomic.LoadInt64) 1755 | funcs["LoadUint32"] = reflect.ValueOf(atomic.LoadUint32) 1756 | funcs["LoadUint64"] = reflect.ValueOf(atomic.LoadUint64) 1757 | funcs["LoadUintptr"] = reflect.ValueOf(atomic.LoadUintptr) 1758 | funcs["LoadPointer"] = reflect.ValueOf(atomic.LoadPointer) 1759 | funcs["StoreInt32"] = reflect.ValueOf(atomic.StoreInt32) 1760 | funcs["StoreInt64"] = reflect.ValueOf(atomic.StoreInt64) 1761 | funcs["StoreUint32"] = reflect.ValueOf(atomic.StoreUint32) 1762 | funcs["StoreUint64"] = reflect.ValueOf(atomic.StoreUint64) 1763 | funcs["StoreUintptr"] = reflect.ValueOf(atomic.StoreUintptr) 1764 | funcs["StorePointer"] = reflect.ValueOf(atomic.StorePointer) 1765 | 1766 | types = make(map[string] reflect.Type) 1767 | types["Value"] = reflect.TypeOf(new(atomic.Value)).Elem() 1768 | 1769 | vars = make(map[string] reflect.Value) 1770 | pkgs["atomic"] = &eval.SimpleEnv { 1771 | Consts: consts, 1772 | Funcs: funcs, 1773 | Types: types, 1774 | Vars: vars, 1775 | Pkgs: pkgs, 1776 | } 1777 | consts = make(map[string] reflect.Value) 1778 | //syscall constants excluded 1779 | 1780 | funcs = make(map[string] reflect.Value) 1781 | funcs["Unsetenv"] = reflect.ValueOf(syscall.Unsetenv) 1782 | funcs["Getenv"] = reflect.ValueOf(syscall.Getenv) 1783 | funcs["Setenv"] = reflect.ValueOf(syscall.Setenv) 1784 | funcs["Clearenv"] = reflect.ValueOf(syscall.Clearenv) 1785 | funcs["Environ"] = reflect.ValueOf(syscall.Environ) 1786 | funcs["StringSlicePtr"] = reflect.ValueOf(syscall.StringSlicePtr) 1787 | funcs["SlicePtrFromStrings"] = reflect.ValueOf(syscall.SlicePtrFromStrings) 1788 | funcs["CloseOnExec"] = reflect.ValueOf(syscall.CloseOnExec) 1789 | funcs["SetNonblock"] = reflect.ValueOf(syscall.SetNonblock) 1790 | funcs["ForkExec"] = reflect.ValueOf(syscall.ForkExec) 1791 | funcs["StartProcess"] = reflect.ValueOf(syscall.StartProcess) 1792 | funcs["Exec"] = reflect.ValueOf(syscall.Exec) 1793 | funcs["FcntlFlock"] = reflect.ValueOf(syscall.FcntlFlock) 1794 | funcs["LsfStmt"] = reflect.ValueOf(syscall.LsfStmt) 1795 | funcs["LsfJump"] = reflect.ValueOf(syscall.LsfJump) 1796 | funcs["LsfSocket"] = reflect.ValueOf(syscall.LsfSocket) 1797 | funcs["SetLsfPromisc"] = reflect.ValueOf(syscall.SetLsfPromisc) 1798 | funcs["AttachLsf"] = reflect.ValueOf(syscall.AttachLsf) 1799 | funcs["DetachLsf"] = reflect.ValueOf(syscall.DetachLsf) 1800 | funcs["NetlinkRIB"] = reflect.ValueOf(syscall.NetlinkRIB) 1801 | funcs["ParseNetlinkMessage"] = reflect.ValueOf(syscall.ParseNetlinkMessage) 1802 | funcs["ParseNetlinkRouteAttr"] = reflect.ValueOf(syscall.ParseNetlinkRouteAttr) 1803 | funcs["UnixCredentials"] = reflect.ValueOf(syscall.UnixCredentials) 1804 | funcs["ParseUnixCredentials"] = reflect.ValueOf(syscall.ParseUnixCredentials) 1805 | funcs["CmsgLen"] = reflect.ValueOf(syscall.CmsgLen) 1806 | funcs["CmsgSpace"] = reflect.ValueOf(syscall.CmsgSpace) 1807 | funcs["ParseSocketControlMessage"] = reflect.ValueOf(syscall.ParseSocketControlMessage) 1808 | funcs["UnixRights"] = reflect.ValueOf(syscall.UnixRights) 1809 | funcs["ParseUnixRights"] = reflect.ValueOf(syscall.ParseUnixRights) 1810 | funcs["StringByteSlice"] = reflect.ValueOf(syscall.StringByteSlice) 1811 | funcs["ByteSliceFromString"] = reflect.ValueOf(syscall.ByteSliceFromString) 1812 | funcs["StringBytePtr"] = reflect.ValueOf(syscall.StringBytePtr) 1813 | funcs["BytePtrFromString"] = reflect.ValueOf(syscall.BytePtrFromString) 1814 | funcs["Open"] = reflect.ValueOf(syscall.Open) 1815 | funcs["Openat"] = reflect.ValueOf(syscall.Openat) 1816 | funcs["Pipe"] = reflect.ValueOf(syscall.Pipe) 1817 | funcs["Pipe2"] = reflect.ValueOf(syscall.Pipe2) 1818 | funcs["Utimes"] = reflect.ValueOf(syscall.Utimes) 1819 | funcs["UtimesNano"] = reflect.ValueOf(syscall.UtimesNano) 1820 | funcs["Futimesat"] = reflect.ValueOf(syscall.Futimesat) 1821 | funcs["Futimes"] = reflect.ValueOf(syscall.Futimes) 1822 | funcs["Getwd"] = reflect.ValueOf(syscall.Getwd) 1823 | funcs["Getgroups"] = reflect.ValueOf(syscall.Getgroups) 1824 | funcs["Setgroups"] = reflect.ValueOf(syscall.Setgroups) 1825 | funcs["Wait4"] = reflect.ValueOf(syscall.Wait4) 1826 | funcs["Mkfifo"] = reflect.ValueOf(syscall.Mkfifo) 1827 | funcs["Accept"] = reflect.ValueOf(syscall.Accept) 1828 | funcs["Accept4"] = reflect.ValueOf(syscall.Accept4) 1829 | funcs["Getsockname"] = reflect.ValueOf(syscall.Getsockname) 1830 | funcs["GetsockoptInet4Addr"] = reflect.ValueOf(syscall.GetsockoptInet4Addr) 1831 | funcs["GetsockoptIPMreq"] = reflect.ValueOf(syscall.GetsockoptIPMreq) 1832 | funcs["GetsockoptIPMreqn"] = reflect.ValueOf(syscall.GetsockoptIPMreqn) 1833 | funcs["GetsockoptIPv6Mreq"] = reflect.ValueOf(syscall.GetsockoptIPv6Mreq) 1834 | funcs["GetsockoptIPv6MTUInfo"] = reflect.ValueOf(syscall.GetsockoptIPv6MTUInfo) 1835 | funcs["GetsockoptICMPv6Filter"] = reflect.ValueOf(syscall.GetsockoptICMPv6Filter) 1836 | funcs["GetsockoptUcred"] = reflect.ValueOf(syscall.GetsockoptUcred) 1837 | funcs["SetsockoptIPMreqn"] = reflect.ValueOf(syscall.SetsockoptIPMreqn) 1838 | funcs["Recvmsg"] = reflect.ValueOf(syscall.Recvmsg) 1839 | funcs["Sendmsg"] = reflect.ValueOf(syscall.Sendmsg) 1840 | funcs["SendmsgN"] = reflect.ValueOf(syscall.SendmsgN) 1841 | funcs["BindToDevice"] = reflect.ValueOf(syscall.BindToDevice) 1842 | funcs["PtracePeekText"] = reflect.ValueOf(syscall.PtracePeekText) 1843 | funcs["PtracePeekData"] = reflect.ValueOf(syscall.PtracePeekData) 1844 | funcs["PtracePokeText"] = reflect.ValueOf(syscall.PtracePokeText) 1845 | funcs["PtracePokeData"] = reflect.ValueOf(syscall.PtracePokeData) 1846 | funcs["PtraceGetRegs"] = reflect.ValueOf(syscall.PtraceGetRegs) 1847 | funcs["PtraceSetRegs"] = reflect.ValueOf(syscall.PtraceSetRegs) 1848 | funcs["PtraceSetOptions"] = reflect.ValueOf(syscall.PtraceSetOptions) 1849 | funcs["PtraceGetEventMsg"] = reflect.ValueOf(syscall.PtraceGetEventMsg) 1850 | funcs["PtraceCont"] = reflect.ValueOf(syscall.PtraceCont) 1851 | funcs["PtraceSyscall"] = reflect.ValueOf(syscall.PtraceSyscall) 1852 | funcs["PtraceSingleStep"] = reflect.ValueOf(syscall.PtraceSingleStep) 1853 | funcs["PtraceAttach"] = reflect.ValueOf(syscall.PtraceAttach) 1854 | funcs["PtraceDetach"] = reflect.ValueOf(syscall.PtraceDetach) 1855 | funcs["Reboot"] = reflect.ValueOf(syscall.Reboot) 1856 | funcs["ReadDirent"] = reflect.ValueOf(syscall.ReadDirent) 1857 | funcs["ParseDirent"] = reflect.ValueOf(syscall.ParseDirent) 1858 | funcs["Mount"] = reflect.ValueOf(syscall.Mount) 1859 | funcs["Setuid"] = reflect.ValueOf(syscall.Setuid) 1860 | funcs["Setgid"] = reflect.ValueOf(syscall.Setgid) 1861 | funcs["Mmap"] = reflect.ValueOf(syscall.Mmap) 1862 | funcs["Munmap"] = reflect.ValueOf(syscall.Munmap) 1863 | funcs["Getpagesize"] = reflect.ValueOf(syscall.Getpagesize) 1864 | funcs["Gettimeofday"] = reflect.ValueOf(syscall.Gettimeofday) 1865 | funcs["Time"] = reflect.ValueOf(syscall.Time) 1866 | funcs["TimespecToNsec"] = reflect.ValueOf(syscall.TimespecToNsec) 1867 | funcs["NsecToTimespec"] = reflect.ValueOf(syscall.NsecToTimespec) 1868 | funcs["TimevalToNsec"] = reflect.ValueOf(syscall.TimevalToNsec) 1869 | funcs["NsecToTimeval"] = reflect.ValueOf(syscall.NsecToTimeval) 1870 | funcs["Syscall"] = reflect.ValueOf(syscall.Syscall) 1871 | funcs["Syscall6"] = reflect.ValueOf(syscall.Syscall6) 1872 | funcs["RawSyscall"] = reflect.ValueOf(syscall.RawSyscall) 1873 | funcs["RawSyscall6"] = reflect.ValueOf(syscall.RawSyscall6) 1874 | funcs["Read"] = reflect.ValueOf(syscall.Read) 1875 | funcs["Write"] = reflect.ValueOf(syscall.Write) 1876 | funcs["Bind"] = reflect.ValueOf(syscall.Bind) 1877 | funcs["Connect"] = reflect.ValueOf(syscall.Connect) 1878 | funcs["Getpeername"] = reflect.ValueOf(syscall.Getpeername) 1879 | funcs["GetsockoptInt"] = reflect.ValueOf(syscall.GetsockoptInt) 1880 | funcs["Recvfrom"] = reflect.ValueOf(syscall.Recvfrom) 1881 | funcs["Sendto"] = reflect.ValueOf(syscall.Sendto) 1882 | funcs["SetsockoptByte"] = reflect.ValueOf(syscall.SetsockoptByte) 1883 | funcs["SetsockoptInt"] = reflect.ValueOf(syscall.SetsockoptInt) 1884 | funcs["SetsockoptInet4Addr"] = reflect.ValueOf(syscall.SetsockoptInet4Addr) 1885 | funcs["SetsockoptIPMreq"] = reflect.ValueOf(syscall.SetsockoptIPMreq) 1886 | funcs["SetsockoptIPv6Mreq"] = reflect.ValueOf(syscall.SetsockoptIPv6Mreq) 1887 | funcs["SetsockoptICMPv6Filter"] = reflect.ValueOf(syscall.SetsockoptICMPv6Filter) 1888 | funcs["SetsockoptLinger"] = reflect.ValueOf(syscall.SetsockoptLinger) 1889 | funcs["SetsockoptString"] = reflect.ValueOf(syscall.SetsockoptString) 1890 | funcs["SetsockoptTimeval"] = reflect.ValueOf(syscall.SetsockoptTimeval) 1891 | funcs["Socket"] = reflect.ValueOf(syscall.Socket) 1892 | funcs["Socketpair"] = reflect.ValueOf(syscall.Socketpair) 1893 | funcs["Sendfile"] = reflect.ValueOf(syscall.Sendfile) 1894 | funcs["Getcwd"] = reflect.ValueOf(syscall.Getcwd) 1895 | funcs["Access"] = reflect.ValueOf(syscall.Access) 1896 | funcs["Acct"] = reflect.ValueOf(syscall.Acct) 1897 | funcs["Adjtimex"] = reflect.ValueOf(syscall.Adjtimex) 1898 | funcs["Chdir"] = reflect.ValueOf(syscall.Chdir) 1899 | funcs["Chmod"] = reflect.ValueOf(syscall.Chmod) 1900 | funcs["Chroot"] = reflect.ValueOf(syscall.Chroot) 1901 | funcs["Close"] = reflect.ValueOf(syscall.Close) 1902 | funcs["Creat"] = reflect.ValueOf(syscall.Creat) 1903 | funcs["Dup"] = reflect.ValueOf(syscall.Dup) 1904 | funcs["Dup2"] = reflect.ValueOf(syscall.Dup2) 1905 | funcs["Dup3"] = reflect.ValueOf(syscall.Dup3) 1906 | funcs["EpollCreate"] = reflect.ValueOf(syscall.EpollCreate) 1907 | funcs["EpollCreate1"] = reflect.ValueOf(syscall.EpollCreate1) 1908 | funcs["EpollCtl"] = reflect.ValueOf(syscall.EpollCtl) 1909 | funcs["EpollWait"] = reflect.ValueOf(syscall.EpollWait) 1910 | funcs["Exit"] = reflect.ValueOf(syscall.Exit) 1911 | funcs["Faccessat"] = reflect.ValueOf(syscall.Faccessat) 1912 | funcs["Fallocate"] = reflect.ValueOf(syscall.Fallocate) 1913 | funcs["Fchdir"] = reflect.ValueOf(syscall.Fchdir) 1914 | funcs["Fchmod"] = reflect.ValueOf(syscall.Fchmod) 1915 | funcs["Fchmodat"] = reflect.ValueOf(syscall.Fchmodat) 1916 | funcs["Fchownat"] = reflect.ValueOf(syscall.Fchownat) 1917 | funcs["Fdatasync"] = reflect.ValueOf(syscall.Fdatasync) 1918 | funcs["Flock"] = reflect.ValueOf(syscall.Flock) 1919 | funcs["Fsync"] = reflect.ValueOf(syscall.Fsync) 1920 | funcs["Getdents"] = reflect.ValueOf(syscall.Getdents) 1921 | funcs["Getpgid"] = reflect.ValueOf(syscall.Getpgid) 1922 | funcs["Getpgrp"] = reflect.ValueOf(syscall.Getpgrp) 1923 | funcs["Getpid"] = reflect.ValueOf(syscall.Getpid) 1924 | funcs["Getppid"] = reflect.ValueOf(syscall.Getppid) 1925 | funcs["Getpriority"] = reflect.ValueOf(syscall.Getpriority) 1926 | funcs["Getrusage"] = reflect.ValueOf(syscall.Getrusage) 1927 | funcs["Gettid"] = reflect.ValueOf(syscall.Gettid) 1928 | funcs["Getxattr"] = reflect.ValueOf(syscall.Getxattr) 1929 | funcs["InotifyAddWatch"] = reflect.ValueOf(syscall.InotifyAddWatch) 1930 | funcs["InotifyInit"] = reflect.ValueOf(syscall.InotifyInit) 1931 | funcs["InotifyInit1"] = reflect.ValueOf(syscall.InotifyInit1) 1932 | funcs["InotifyRmWatch"] = reflect.ValueOf(syscall.InotifyRmWatch) 1933 | funcs["Kill"] = reflect.ValueOf(syscall.Kill) 1934 | funcs["Klogctl"] = reflect.ValueOf(syscall.Klogctl) 1935 | funcs["Link"] = reflect.ValueOf(syscall.Link) 1936 | funcs["Listxattr"] = reflect.ValueOf(syscall.Listxattr) 1937 | funcs["Mkdir"] = reflect.ValueOf(syscall.Mkdir) 1938 | funcs["Mkdirat"] = reflect.ValueOf(syscall.Mkdirat) 1939 | funcs["Mknod"] = reflect.ValueOf(syscall.Mknod) 1940 | funcs["Mknodat"] = reflect.ValueOf(syscall.Mknodat) 1941 | funcs["Nanosleep"] = reflect.ValueOf(syscall.Nanosleep) 1942 | funcs["Pause"] = reflect.ValueOf(syscall.Pause) 1943 | funcs["PivotRoot"] = reflect.ValueOf(syscall.PivotRoot) 1944 | funcs["Readlink"] = reflect.ValueOf(syscall.Readlink) 1945 | funcs["Removexattr"] = reflect.ValueOf(syscall.Removexattr) 1946 | funcs["Rename"] = reflect.ValueOf(syscall.Rename) 1947 | funcs["Renameat"] = reflect.ValueOf(syscall.Renameat) 1948 | funcs["Rmdir"] = reflect.ValueOf(syscall.Rmdir) 1949 | funcs["Setdomainname"] = reflect.ValueOf(syscall.Setdomainname) 1950 | funcs["Sethostname"] = reflect.ValueOf(syscall.Sethostname) 1951 | funcs["Setpgid"] = reflect.ValueOf(syscall.Setpgid) 1952 | funcs["Setsid"] = reflect.ValueOf(syscall.Setsid) 1953 | funcs["Settimeofday"] = reflect.ValueOf(syscall.Settimeofday) 1954 | funcs["Setpriority"] = reflect.ValueOf(syscall.Setpriority) 1955 | funcs["Setxattr"] = reflect.ValueOf(syscall.Setxattr) 1956 | funcs["Symlink"] = reflect.ValueOf(syscall.Symlink) 1957 | funcs["Sync"] = reflect.ValueOf(syscall.Sync) 1958 | funcs["Sysinfo"] = reflect.ValueOf(syscall.Sysinfo) 1959 | funcs["Tee"] = reflect.ValueOf(syscall.Tee) 1960 | funcs["Tgkill"] = reflect.ValueOf(syscall.Tgkill) 1961 | funcs["Times"] = reflect.ValueOf(syscall.Times) 1962 | funcs["Umask"] = reflect.ValueOf(syscall.Umask) 1963 | funcs["Uname"] = reflect.ValueOf(syscall.Uname) 1964 | funcs["Unlink"] = reflect.ValueOf(syscall.Unlink) 1965 | funcs["Unlinkat"] = reflect.ValueOf(syscall.Unlinkat) 1966 | funcs["Unmount"] = reflect.ValueOf(syscall.Unmount) 1967 | funcs["Unshare"] = reflect.ValueOf(syscall.Unshare) 1968 | funcs["Ustat"] = reflect.ValueOf(syscall.Ustat) 1969 | funcs["Utime"] = reflect.ValueOf(syscall.Utime) 1970 | funcs["Madvise"] = reflect.ValueOf(syscall.Madvise) 1971 | funcs["Mprotect"] = reflect.ValueOf(syscall.Mprotect) 1972 | funcs["Mlock"] = reflect.ValueOf(syscall.Mlock) 1973 | funcs["Munlock"] = reflect.ValueOf(syscall.Munlock) 1974 | funcs["Mlockall"] = reflect.ValueOf(syscall.Mlockall) 1975 | funcs["Munlockall"] = reflect.ValueOf(syscall.Munlockall) 1976 | funcs["Chown"] = reflect.ValueOf(syscall.Chown) 1977 | funcs["Fchown"] = reflect.ValueOf(syscall.Fchown) 1978 | funcs["Fstat"] = reflect.ValueOf(syscall.Fstat) 1979 | funcs["Fstatfs"] = reflect.ValueOf(syscall.Fstatfs) 1980 | funcs["Ftruncate"] = reflect.ValueOf(syscall.Ftruncate) 1981 | funcs["Getegid"] = reflect.ValueOf(syscall.Getegid) 1982 | funcs["Geteuid"] = reflect.ValueOf(syscall.Geteuid) 1983 | funcs["Getgid"] = reflect.ValueOf(syscall.Getgid) 1984 | funcs["Getrlimit"] = reflect.ValueOf(syscall.Getrlimit) 1985 | funcs["Getuid"] = reflect.ValueOf(syscall.Getuid) 1986 | funcs["Ioperm"] = reflect.ValueOf(syscall.Ioperm) 1987 | funcs["Iopl"] = reflect.ValueOf(syscall.Iopl) 1988 | funcs["Lchown"] = reflect.ValueOf(syscall.Lchown) 1989 | funcs["Listen"] = reflect.ValueOf(syscall.Listen) 1990 | funcs["Lstat"] = reflect.ValueOf(syscall.Lstat) 1991 | funcs["Pread"] = reflect.ValueOf(syscall.Pread) 1992 | funcs["Pwrite"] = reflect.ValueOf(syscall.Pwrite) 1993 | funcs["Seek"] = reflect.ValueOf(syscall.Seek) 1994 | funcs["Select"] = reflect.ValueOf(syscall.Select) 1995 | funcs["Setfsgid"] = reflect.ValueOf(syscall.Setfsgid) 1996 | funcs["Setfsuid"] = reflect.ValueOf(syscall.Setfsuid) 1997 | funcs["Setregid"] = reflect.ValueOf(syscall.Setregid) 1998 | funcs["Setresgid"] = reflect.ValueOf(syscall.Setresgid) 1999 | funcs["Setresuid"] = reflect.ValueOf(syscall.Setresuid) 2000 | funcs["Setrlimit"] = reflect.ValueOf(syscall.Setrlimit) 2001 | funcs["Setreuid"] = reflect.ValueOf(syscall.Setreuid) 2002 | funcs["Shutdown"] = reflect.ValueOf(syscall.Shutdown) 2003 | funcs["Splice"] = reflect.ValueOf(syscall.Splice) 2004 | funcs["Stat"] = reflect.ValueOf(syscall.Stat) 2005 | funcs["Statfs"] = reflect.ValueOf(syscall.Statfs) 2006 | funcs["SyncFileRange"] = reflect.ValueOf(syscall.SyncFileRange) 2007 | funcs["Truncate"] = reflect.ValueOf(syscall.Truncate) 2008 | 2009 | types = make(map[string] reflect.Type) 2010 | types["SysProcIDMap"] = reflect.TypeOf(new(syscall.SysProcIDMap)).Elem() 2011 | types["SysProcAttr"] = reflect.TypeOf(new(syscall.SysProcAttr)).Elem() 2012 | types["Credential"] = reflect.TypeOf(new(syscall.Credential)).Elem() 2013 | types["ProcAttr"] = reflect.TypeOf(new(syscall.ProcAttr)).Elem() 2014 | types["NetlinkRouteRequest"] = reflect.TypeOf(new(syscall.NetlinkRouteRequest)).Elem() 2015 | types["NetlinkMessage"] = reflect.TypeOf(new(syscall.NetlinkMessage)).Elem() 2016 | types["NetlinkRouteAttr"] = reflect.TypeOf(new(syscall.NetlinkRouteAttr)).Elem() 2017 | types["SocketControlMessage"] = reflect.TypeOf(new(syscall.SocketControlMessage)).Elem() 2018 | types["WaitStatus"] = reflect.TypeOf(new(syscall.WaitStatus)).Elem() 2019 | types["SockaddrLinklayer"] = reflect.TypeOf(new(syscall.SockaddrLinklayer)).Elem() 2020 | types["SockaddrNetlink"] = reflect.TypeOf(new(syscall.SockaddrNetlink)).Elem() 2021 | types["Errno"] = reflect.TypeOf(new(syscall.Errno)).Elem() 2022 | types["Signal"] = reflect.TypeOf(new(syscall.Signal)).Elem() 2023 | types["Sockaddr"] = reflect.TypeOf(new(syscall.Sockaddr)).Elem() 2024 | types["SockaddrInet4"] = reflect.TypeOf(new(syscall.SockaddrInet4)).Elem() 2025 | types["SockaddrInet6"] = reflect.TypeOf(new(syscall.SockaddrInet6)).Elem() 2026 | types["SockaddrUnix"] = reflect.TypeOf(new(syscall.SockaddrUnix)).Elem() 2027 | types["Timespec"] = reflect.TypeOf(new(syscall.Timespec)).Elem() 2028 | types["Timeval"] = reflect.TypeOf(new(syscall.Timeval)).Elem() 2029 | types["Timex"] = reflect.TypeOf(new(syscall.Timex)).Elem() 2030 | types["Time_t"] = reflect.TypeOf(new(syscall.Time_t)).Elem() 2031 | types["Tms"] = reflect.TypeOf(new(syscall.Tms)).Elem() 2032 | types["Utimbuf"] = reflect.TypeOf(new(syscall.Utimbuf)).Elem() 2033 | types["Rusage"] = reflect.TypeOf(new(syscall.Rusage)).Elem() 2034 | types["Rlimit"] = reflect.TypeOf(new(syscall.Rlimit)).Elem() 2035 | types["Stat_t"] = reflect.TypeOf(new(syscall.Stat_t)).Elem() 2036 | types["Statfs_t"] = reflect.TypeOf(new(syscall.Statfs_t)).Elem() 2037 | types["Dirent"] = reflect.TypeOf(new(syscall.Dirent)).Elem() 2038 | types["Fsid"] = reflect.TypeOf(new(syscall.Fsid)).Elem() 2039 | types["Flock_t"] = reflect.TypeOf(new(syscall.Flock_t)).Elem() 2040 | types["RawSockaddrInet4"] = reflect.TypeOf(new(syscall.RawSockaddrInet4)).Elem() 2041 | types["RawSockaddrInet6"] = reflect.TypeOf(new(syscall.RawSockaddrInet6)).Elem() 2042 | types["RawSockaddrUnix"] = reflect.TypeOf(new(syscall.RawSockaddrUnix)).Elem() 2043 | types["RawSockaddrLinklayer"] = reflect.TypeOf(new(syscall.RawSockaddrLinklayer)).Elem() 2044 | types["RawSockaddrNetlink"] = reflect.TypeOf(new(syscall.RawSockaddrNetlink)).Elem() 2045 | types["RawSockaddr"] = reflect.TypeOf(new(syscall.RawSockaddr)).Elem() 2046 | types["RawSockaddrAny"] = reflect.TypeOf(new(syscall.RawSockaddrAny)).Elem() 2047 | types["Linger"] = reflect.TypeOf(new(syscall.Linger)).Elem() 2048 | types["Iovec"] = reflect.TypeOf(new(syscall.Iovec)).Elem() 2049 | types["IPMreq"] = reflect.TypeOf(new(syscall.IPMreq)).Elem() 2050 | types["IPMreqn"] = reflect.TypeOf(new(syscall.IPMreqn)).Elem() 2051 | types["IPv6Mreq"] = reflect.TypeOf(new(syscall.IPv6Mreq)).Elem() 2052 | types["Msghdr"] = reflect.TypeOf(new(syscall.Msghdr)).Elem() 2053 | types["Cmsghdr"] = reflect.TypeOf(new(syscall.Cmsghdr)).Elem() 2054 | types["Inet4Pktinfo"] = reflect.TypeOf(new(syscall.Inet4Pktinfo)).Elem() 2055 | types["Inet6Pktinfo"] = reflect.TypeOf(new(syscall.Inet6Pktinfo)).Elem() 2056 | types["IPv6MTUInfo"] = reflect.TypeOf(new(syscall.IPv6MTUInfo)).Elem() 2057 | types["ICMPv6Filter"] = reflect.TypeOf(new(syscall.ICMPv6Filter)).Elem() 2058 | types["Ucred"] = reflect.TypeOf(new(syscall.Ucred)).Elem() 2059 | types["TCPInfo"] = reflect.TypeOf(new(syscall.TCPInfo)).Elem() 2060 | types["NlMsghdr"] = reflect.TypeOf(new(syscall.NlMsghdr)).Elem() 2061 | types["NlMsgerr"] = reflect.TypeOf(new(syscall.NlMsgerr)).Elem() 2062 | types["RtGenmsg"] = reflect.TypeOf(new(syscall.RtGenmsg)).Elem() 2063 | types["NlAttr"] = reflect.TypeOf(new(syscall.NlAttr)).Elem() 2064 | types["RtAttr"] = reflect.TypeOf(new(syscall.RtAttr)).Elem() 2065 | types["IfInfomsg"] = reflect.TypeOf(new(syscall.IfInfomsg)).Elem() 2066 | types["IfAddrmsg"] = reflect.TypeOf(new(syscall.IfAddrmsg)).Elem() 2067 | types["RtMsg"] = reflect.TypeOf(new(syscall.RtMsg)).Elem() 2068 | types["RtNexthop"] = reflect.TypeOf(new(syscall.RtNexthop)).Elem() 2069 | types["SockFilter"] = reflect.TypeOf(new(syscall.SockFilter)).Elem() 2070 | types["SockFprog"] = reflect.TypeOf(new(syscall.SockFprog)).Elem() 2071 | types["InotifyEvent"] = reflect.TypeOf(new(syscall.InotifyEvent)).Elem() 2072 | types["PtraceRegs"] = reflect.TypeOf(new(syscall.PtraceRegs)).Elem() 2073 | types["FdSet"] = reflect.TypeOf(new(syscall.FdSet)).Elem() 2074 | types["Sysinfo_t"] = reflect.TypeOf(new(syscall.Sysinfo_t)).Elem() 2075 | types["Utsname"] = reflect.TypeOf(new(syscall.Utsname)).Elem() 2076 | types["Ustat_t"] = reflect.TypeOf(new(syscall.Ustat_t)).Elem() 2077 | types["EpollEvent"] = reflect.TypeOf(new(syscall.EpollEvent)).Elem() 2078 | types["Termios"] = reflect.TypeOf(new(syscall.Termios)).Elem() 2079 | 2080 | vars = make(map[string] reflect.Value) 2081 | vars["ForkLock"] = reflect.ValueOf(&syscall.ForkLock) 2082 | vars["Stdin"] = reflect.ValueOf(&syscall.Stdin) 2083 | vars["Stdout"] = reflect.ValueOf(&syscall.Stdout) 2084 | vars["Stderr"] = reflect.ValueOf(&syscall.Stderr) 2085 | vars["SocketDisableIPv6"] = reflect.ValueOf(&syscall.SocketDisableIPv6) 2086 | pkgs["syscall"] = &eval.SimpleEnv { 2087 | Consts: consts, 2088 | Funcs: funcs, 2089 | Types: types, 2090 | Vars: vars, 2091 | Pkgs: pkgs, 2092 | } 2093 | consts = make(map[string] reflect.Value) 2094 | 2095 | funcs = make(map[string] reflect.Value) 2096 | funcs["AllocsPerRun"] = reflect.ValueOf(testing.AllocsPerRun) 2097 | funcs["RunBenchmarks"] = reflect.ValueOf(testing.RunBenchmarks) 2098 | funcs["Benchmark"] = reflect.ValueOf(testing.Benchmark) 2099 | funcs["Coverage"] = reflect.ValueOf(testing.Coverage) 2100 | funcs["RegisterCover"] = reflect.ValueOf(testing.RegisterCover) 2101 | funcs["RunExamples"] = reflect.ValueOf(testing.RunExamples) 2102 | funcs["Short"] = reflect.ValueOf(testing.Short) 2103 | funcs["Verbose"] = reflect.ValueOf(testing.Verbose) 2104 | funcs["Main"] = reflect.ValueOf(testing.Main) 2105 | funcs["MainStart"] = reflect.ValueOf(testing.MainStart) 2106 | funcs["RunTests"] = reflect.ValueOf(testing.RunTests) 2107 | 2108 | types = make(map[string] reflect.Type) 2109 | types["InternalBenchmark"] = reflect.TypeOf(new(testing.InternalBenchmark)).Elem() 2110 | types["B"] = reflect.TypeOf(new(testing.B)).Elem() 2111 | types["BenchmarkResult"] = reflect.TypeOf(new(testing.BenchmarkResult)).Elem() 2112 | types["PB"] = reflect.TypeOf(new(testing.PB)).Elem() 2113 | types["CoverBlock"] = reflect.TypeOf(new(testing.CoverBlock)).Elem() 2114 | types["Cover"] = reflect.TypeOf(new(testing.Cover)).Elem() 2115 | types["InternalExample"] = reflect.TypeOf(new(testing.InternalExample)).Elem() 2116 | types["TB"] = reflect.TypeOf(new(testing.TB)).Elem() 2117 | types["T"] = reflect.TypeOf(new(testing.T)).Elem() 2118 | types["InternalTest"] = reflect.TypeOf(new(testing.InternalTest)).Elem() 2119 | types["M"] = reflect.TypeOf(new(testing.M)).Elem() 2120 | 2121 | vars = make(map[string] reflect.Value) 2122 | pkgs["testing"] = &eval.SimpleEnv { 2123 | Consts: consts, 2124 | Funcs: funcs, 2125 | Types: types, 2126 | Vars: vars, 2127 | Pkgs: pkgs, 2128 | } 2129 | consts = make(map[string] reflect.Value) 2130 | consts["FilterHTML"] = reflect.ValueOf(tabwriter.FilterHTML) 2131 | consts["StripEscape"] = reflect.ValueOf(tabwriter.StripEscape) 2132 | consts["AlignRight"] = reflect.ValueOf(tabwriter.AlignRight) 2133 | consts["DiscardEmptyColumns"] = reflect.ValueOf(tabwriter.DiscardEmptyColumns) 2134 | consts["TabIndent"] = reflect.ValueOf(tabwriter.TabIndent) 2135 | consts["Debug"] = reflect.ValueOf(tabwriter.Debug) 2136 | consts["Escape"] = reflect.ValueOf(tabwriter.Escape) 2137 | 2138 | funcs = make(map[string] reflect.Value) 2139 | funcs["NewWriter"] = reflect.ValueOf(tabwriter.NewWriter) 2140 | 2141 | types = make(map[string] reflect.Type) 2142 | types["Writer"] = reflect.TypeOf(new(tabwriter.Writer)).Elem() 2143 | 2144 | vars = make(map[string] reflect.Value) 2145 | pkgs["tabwriter"] = &eval.SimpleEnv { 2146 | Consts: consts, 2147 | Funcs: funcs, 2148 | Types: types, 2149 | Vars: vars, 2150 | Pkgs: pkgs, 2151 | } 2152 | consts = make(map[string] reflect.Value) 2153 | consts["ANSIC"] = reflect.ValueOf(time.ANSIC) 2154 | consts["UnixDate"] = reflect.ValueOf(time.UnixDate) 2155 | consts["RubyDate"] = reflect.ValueOf(time.RubyDate) 2156 | consts["RFC822"] = reflect.ValueOf(time.RFC822) 2157 | consts["RFC822Z"] = reflect.ValueOf(time.RFC822Z) 2158 | consts["RFC850"] = reflect.ValueOf(time.RFC850) 2159 | consts["RFC1123"] = reflect.ValueOf(time.RFC1123) 2160 | consts["RFC1123Z"] = reflect.ValueOf(time.RFC1123Z) 2161 | consts["RFC3339"] = reflect.ValueOf(time.RFC3339) 2162 | consts["RFC3339Nano"] = reflect.ValueOf(time.RFC3339Nano) 2163 | consts["Kitchen"] = reflect.ValueOf(time.Kitchen) 2164 | consts["Stamp"] = reflect.ValueOf(time.Stamp) 2165 | consts["StampMilli"] = reflect.ValueOf(time.StampMilli) 2166 | consts["StampMicro"] = reflect.ValueOf(time.StampMicro) 2167 | consts["StampNano"] = reflect.ValueOf(time.StampNano) 2168 | consts["January"] = reflect.ValueOf(time.January) 2169 | consts["February"] = reflect.ValueOf(time.February) 2170 | consts["March"] = reflect.ValueOf(time.March) 2171 | consts["April"] = reflect.ValueOf(time.April) 2172 | consts["May"] = reflect.ValueOf(time.May) 2173 | consts["June"] = reflect.ValueOf(time.June) 2174 | consts["July"] = reflect.ValueOf(time.July) 2175 | consts["August"] = reflect.ValueOf(time.August) 2176 | consts["September"] = reflect.ValueOf(time.September) 2177 | consts["October"] = reflect.ValueOf(time.October) 2178 | consts["November"] = reflect.ValueOf(time.November) 2179 | consts["December"] = reflect.ValueOf(time.December) 2180 | consts["Sunday"] = reflect.ValueOf(time.Sunday) 2181 | consts["Monday"] = reflect.ValueOf(time.Monday) 2182 | consts["Tuesday"] = reflect.ValueOf(time.Tuesday) 2183 | consts["Wednesday"] = reflect.ValueOf(time.Wednesday) 2184 | consts["Thursday"] = reflect.ValueOf(time.Thursday) 2185 | consts["Friday"] = reflect.ValueOf(time.Friday) 2186 | consts["Saturday"] = reflect.ValueOf(time.Saturday) 2187 | consts["Nanosecond"] = reflect.ValueOf(time.Nanosecond) 2188 | consts["Microsecond"] = reflect.ValueOf(time.Microsecond) 2189 | consts["Millisecond"] = reflect.ValueOf(time.Millisecond) 2190 | consts["Second"] = reflect.ValueOf(time.Second) 2191 | consts["Minute"] = reflect.ValueOf(time.Minute) 2192 | consts["Hour"] = reflect.ValueOf(time.Hour) 2193 | 2194 | funcs = make(map[string] reflect.Value) 2195 | funcs["Parse"] = reflect.ValueOf(time.Parse) 2196 | funcs["ParseInLocation"] = reflect.ValueOf(time.ParseInLocation) 2197 | funcs["ParseDuration"] = reflect.ValueOf(time.ParseDuration) 2198 | funcs["Sleep"] = reflect.ValueOf(time.Sleep) 2199 | funcs["NewTimer"] = reflect.ValueOf(time.NewTimer) 2200 | funcs["After"] = reflect.ValueOf(time.After) 2201 | funcs["AfterFunc"] = reflect.ValueOf(time.AfterFunc) 2202 | funcs["NewTicker"] = reflect.ValueOf(time.NewTicker) 2203 | funcs["Tick"] = reflect.ValueOf(time.Tick) 2204 | funcs["Since"] = reflect.ValueOf(time.Since) 2205 | funcs["Now"] = reflect.ValueOf(time.Now) 2206 | funcs["Unix"] = reflect.ValueOf(time.Unix) 2207 | funcs["Date"] = reflect.ValueOf(time.Date) 2208 | funcs["FixedZone"] = reflect.ValueOf(time.FixedZone) 2209 | funcs["LoadLocation"] = reflect.ValueOf(time.LoadLocation) 2210 | 2211 | types = make(map[string] reflect.Type) 2212 | types["ParseError"] = reflect.TypeOf(new(time.ParseError)).Elem() 2213 | types["Timer"] = reflect.TypeOf(new(time.Timer)).Elem() 2214 | types["Ticker"] = reflect.TypeOf(new(time.Ticker)).Elem() 2215 | types["Time"] = reflect.TypeOf(new(time.Time)).Elem() 2216 | types["Month"] = reflect.TypeOf(new(time.Month)).Elem() 2217 | types["Weekday"] = reflect.TypeOf(new(time.Weekday)).Elem() 2218 | types["Duration"] = reflect.TypeOf(new(time.Duration)).Elem() 2219 | types["Location"] = reflect.TypeOf(new(time.Location)).Elem() 2220 | 2221 | vars = make(map[string] reflect.Value) 2222 | vars["UTC"] = reflect.ValueOf(&time.UTC) 2223 | vars["Local"] = reflect.ValueOf(&time.Local) 2224 | pkgs["time"] = &eval.SimpleEnv { 2225 | Consts: consts, 2226 | Funcs: funcs, 2227 | Types: types, 2228 | Vars: vars, 2229 | Pkgs: pkgs, 2230 | } 2231 | consts = make(map[string] reflect.Value) 2232 | consts["MaxRune"] = reflect.ValueOf(unicode.MaxRune) 2233 | consts["ReplacementChar"] = reflect.ValueOf(unicode.ReplacementChar) 2234 | consts["MaxASCII"] = reflect.ValueOf(unicode.MaxASCII) 2235 | consts["MaxLatin1"] = reflect.ValueOf(unicode.MaxLatin1) 2236 | consts["UpperCase"] = reflect.ValueOf(unicode.UpperCase) 2237 | consts["LowerCase"] = reflect.ValueOf(unicode.LowerCase) 2238 | consts["TitleCase"] = reflect.ValueOf(unicode.TitleCase) 2239 | consts["MaxCase"] = reflect.ValueOf(unicode.MaxCase) 2240 | consts["UpperLower"] = reflect.ValueOf(unicode.UpperLower) 2241 | consts["Version"] = reflect.ValueOf(unicode.Version) 2242 | 2243 | funcs = make(map[string] reflect.Value) 2244 | funcs["IsDigit"] = reflect.ValueOf(unicode.IsDigit) 2245 | funcs["IsGraphic"] = reflect.ValueOf(unicode.IsGraphic) 2246 | funcs["IsPrint"] = reflect.ValueOf(unicode.IsPrint) 2247 | funcs["IsOneOf"] = reflect.ValueOf(unicode.IsOneOf) 2248 | funcs["In"] = reflect.ValueOf(unicode.In) 2249 | funcs["IsControl"] = reflect.ValueOf(unicode.IsControl) 2250 | funcs["IsLetter"] = reflect.ValueOf(unicode.IsLetter) 2251 | funcs["IsMark"] = reflect.ValueOf(unicode.IsMark) 2252 | funcs["IsNumber"] = reflect.ValueOf(unicode.IsNumber) 2253 | funcs["IsPunct"] = reflect.ValueOf(unicode.IsPunct) 2254 | funcs["IsSpace"] = reflect.ValueOf(unicode.IsSpace) 2255 | funcs["IsSymbol"] = reflect.ValueOf(unicode.IsSymbol) 2256 | funcs["Is"] = reflect.ValueOf(unicode.Is) 2257 | funcs["IsUpper"] = reflect.ValueOf(unicode.IsUpper) 2258 | funcs["IsLower"] = reflect.ValueOf(unicode.IsLower) 2259 | funcs["IsTitle"] = reflect.ValueOf(unicode.IsTitle) 2260 | funcs["To"] = reflect.ValueOf(unicode.To) 2261 | funcs["ToUpper"] = reflect.ValueOf(unicode.ToUpper) 2262 | funcs["ToLower"] = reflect.ValueOf(unicode.ToLower) 2263 | funcs["ToTitle"] = reflect.ValueOf(unicode.ToTitle) 2264 | funcs["SimpleFold"] = reflect.ValueOf(unicode.SimpleFold) 2265 | 2266 | types = make(map[string] reflect.Type) 2267 | types["RangeTable"] = reflect.TypeOf(new(unicode.RangeTable)).Elem() 2268 | types["Range16"] = reflect.TypeOf(new(unicode.Range16)).Elem() 2269 | types["Range32"] = reflect.TypeOf(new(unicode.Range32)).Elem() 2270 | types["CaseRange"] = reflect.TypeOf(new(unicode.CaseRange)).Elem() 2271 | types["SpecialCase"] = reflect.TypeOf(new(unicode.SpecialCase)).Elem() 2272 | 2273 | vars = make(map[string] reflect.Value) 2274 | vars["TurkishCase"] = reflect.ValueOf(&unicode.TurkishCase) 2275 | vars["AzeriCase"] = reflect.ValueOf(&unicode.AzeriCase) 2276 | vars["GraphicRanges"] = reflect.ValueOf(&unicode.GraphicRanges) 2277 | vars["PrintRanges"] = reflect.ValueOf(&unicode.PrintRanges) 2278 | vars["Categories"] = reflect.ValueOf(&unicode.Categories) 2279 | vars["Cc"] = reflect.ValueOf(&unicode.Cc) 2280 | vars["Cf"] = reflect.ValueOf(&unicode.Cf) 2281 | vars["Co"] = reflect.ValueOf(&unicode.Co) 2282 | vars["Cs"] = reflect.ValueOf(&unicode.Cs) 2283 | vars["Digit"] = reflect.ValueOf(&unicode.Digit) 2284 | vars["Nd"] = reflect.ValueOf(&unicode.Nd) 2285 | vars["Letter"] = reflect.ValueOf(&unicode.Letter) 2286 | vars["L"] = reflect.ValueOf(&unicode.L) 2287 | vars["Lm"] = reflect.ValueOf(&unicode.Lm) 2288 | vars["Lo"] = reflect.ValueOf(&unicode.Lo) 2289 | vars["Lower"] = reflect.ValueOf(&unicode.Lower) 2290 | vars["Ll"] = reflect.ValueOf(&unicode.Ll) 2291 | vars["Mark"] = reflect.ValueOf(&unicode.Mark) 2292 | vars["M"] = reflect.ValueOf(&unicode.M) 2293 | vars["Mc"] = reflect.ValueOf(&unicode.Mc) 2294 | vars["Me"] = reflect.ValueOf(&unicode.Me) 2295 | vars["Mn"] = reflect.ValueOf(&unicode.Mn) 2296 | vars["Nl"] = reflect.ValueOf(&unicode.Nl) 2297 | vars["No"] = reflect.ValueOf(&unicode.No) 2298 | vars["Number"] = reflect.ValueOf(&unicode.Number) 2299 | vars["N"] = reflect.ValueOf(&unicode.N) 2300 | vars["Other"] = reflect.ValueOf(&unicode.Other) 2301 | vars["C"] = reflect.ValueOf(&unicode.C) 2302 | vars["Pc"] = reflect.ValueOf(&unicode.Pc) 2303 | vars["Pd"] = reflect.ValueOf(&unicode.Pd) 2304 | vars["Pe"] = reflect.ValueOf(&unicode.Pe) 2305 | vars["Pf"] = reflect.ValueOf(&unicode.Pf) 2306 | vars["Pi"] = reflect.ValueOf(&unicode.Pi) 2307 | vars["Po"] = reflect.ValueOf(&unicode.Po) 2308 | vars["Ps"] = reflect.ValueOf(&unicode.Ps) 2309 | vars["Punct"] = reflect.ValueOf(&unicode.Punct) 2310 | vars["P"] = reflect.ValueOf(&unicode.P) 2311 | vars["Sc"] = reflect.ValueOf(&unicode.Sc) 2312 | vars["Sk"] = reflect.ValueOf(&unicode.Sk) 2313 | vars["Sm"] = reflect.ValueOf(&unicode.Sm) 2314 | vars["So"] = reflect.ValueOf(&unicode.So) 2315 | vars["Space"] = reflect.ValueOf(&unicode.Space) 2316 | vars["Z"] = reflect.ValueOf(&unicode.Z) 2317 | vars["Symbol"] = reflect.ValueOf(&unicode.Symbol) 2318 | vars["S"] = reflect.ValueOf(&unicode.S) 2319 | vars["Title"] = reflect.ValueOf(&unicode.Title) 2320 | vars["Lt"] = reflect.ValueOf(&unicode.Lt) 2321 | vars["Upper"] = reflect.ValueOf(&unicode.Upper) 2322 | vars["Lu"] = reflect.ValueOf(&unicode.Lu) 2323 | vars["Zl"] = reflect.ValueOf(&unicode.Zl) 2324 | vars["Zp"] = reflect.ValueOf(&unicode.Zp) 2325 | vars["Zs"] = reflect.ValueOf(&unicode.Zs) 2326 | vars["Scripts"] = reflect.ValueOf(&unicode.Scripts) 2327 | vars["Arabic"] = reflect.ValueOf(&unicode.Arabic) 2328 | vars["Armenian"] = reflect.ValueOf(&unicode.Armenian) 2329 | vars["Avestan"] = reflect.ValueOf(&unicode.Avestan) 2330 | vars["Balinese"] = reflect.ValueOf(&unicode.Balinese) 2331 | vars["Bamum"] = reflect.ValueOf(&unicode.Bamum) 2332 | vars["Bassa_Vah"] = reflect.ValueOf(&unicode.Bassa_Vah) 2333 | vars["Batak"] = reflect.ValueOf(&unicode.Batak) 2334 | vars["Bengali"] = reflect.ValueOf(&unicode.Bengali) 2335 | vars["Bopomofo"] = reflect.ValueOf(&unicode.Bopomofo) 2336 | vars["Brahmi"] = reflect.ValueOf(&unicode.Brahmi) 2337 | vars["Braille"] = reflect.ValueOf(&unicode.Braille) 2338 | vars["Buginese"] = reflect.ValueOf(&unicode.Buginese) 2339 | vars["Buhid"] = reflect.ValueOf(&unicode.Buhid) 2340 | vars["Canadian_Aboriginal"] = reflect.ValueOf(&unicode.Canadian_Aboriginal) 2341 | vars["Carian"] = reflect.ValueOf(&unicode.Carian) 2342 | vars["Caucasian_Albanian"] = reflect.ValueOf(&unicode.Caucasian_Albanian) 2343 | vars["Chakma"] = reflect.ValueOf(&unicode.Chakma) 2344 | vars["Cham"] = reflect.ValueOf(&unicode.Cham) 2345 | vars["Cherokee"] = reflect.ValueOf(&unicode.Cherokee) 2346 | vars["Common"] = reflect.ValueOf(&unicode.Common) 2347 | vars["Coptic"] = reflect.ValueOf(&unicode.Coptic) 2348 | vars["Cuneiform"] = reflect.ValueOf(&unicode.Cuneiform) 2349 | vars["Cypriot"] = reflect.ValueOf(&unicode.Cypriot) 2350 | vars["Cyrillic"] = reflect.ValueOf(&unicode.Cyrillic) 2351 | vars["Deseret"] = reflect.ValueOf(&unicode.Deseret) 2352 | vars["Devanagari"] = reflect.ValueOf(&unicode.Devanagari) 2353 | vars["Duployan"] = reflect.ValueOf(&unicode.Duployan) 2354 | vars["Egyptian_Hieroglyphs"] = reflect.ValueOf(&unicode.Egyptian_Hieroglyphs) 2355 | vars["Elbasan"] = reflect.ValueOf(&unicode.Elbasan) 2356 | vars["Ethiopic"] = reflect.ValueOf(&unicode.Ethiopic) 2357 | vars["Georgian"] = reflect.ValueOf(&unicode.Georgian) 2358 | vars["Glagolitic"] = reflect.ValueOf(&unicode.Glagolitic) 2359 | vars["Gothic"] = reflect.ValueOf(&unicode.Gothic) 2360 | vars["Grantha"] = reflect.ValueOf(&unicode.Grantha) 2361 | vars["Greek"] = reflect.ValueOf(&unicode.Greek) 2362 | vars["Gujarati"] = reflect.ValueOf(&unicode.Gujarati) 2363 | vars["Gurmukhi"] = reflect.ValueOf(&unicode.Gurmukhi) 2364 | vars["Han"] = reflect.ValueOf(&unicode.Han) 2365 | vars["Hangul"] = reflect.ValueOf(&unicode.Hangul) 2366 | vars["Hanunoo"] = reflect.ValueOf(&unicode.Hanunoo) 2367 | vars["Hebrew"] = reflect.ValueOf(&unicode.Hebrew) 2368 | vars["Hiragana"] = reflect.ValueOf(&unicode.Hiragana) 2369 | vars["Imperial_Aramaic"] = reflect.ValueOf(&unicode.Imperial_Aramaic) 2370 | vars["Inherited"] = reflect.ValueOf(&unicode.Inherited) 2371 | vars["Inscriptional_Pahlavi"] = reflect.ValueOf(&unicode.Inscriptional_Pahlavi) 2372 | vars["Inscriptional_Parthian"] = reflect.ValueOf(&unicode.Inscriptional_Parthian) 2373 | vars["Javanese"] = reflect.ValueOf(&unicode.Javanese) 2374 | vars["Kaithi"] = reflect.ValueOf(&unicode.Kaithi) 2375 | vars["Kannada"] = reflect.ValueOf(&unicode.Kannada) 2376 | vars["Katakana"] = reflect.ValueOf(&unicode.Katakana) 2377 | vars["Kayah_Li"] = reflect.ValueOf(&unicode.Kayah_Li) 2378 | vars["Kharoshthi"] = reflect.ValueOf(&unicode.Kharoshthi) 2379 | vars["Khmer"] = reflect.ValueOf(&unicode.Khmer) 2380 | vars["Khojki"] = reflect.ValueOf(&unicode.Khojki) 2381 | vars["Khudawadi"] = reflect.ValueOf(&unicode.Khudawadi) 2382 | vars["Lao"] = reflect.ValueOf(&unicode.Lao) 2383 | vars["Latin"] = reflect.ValueOf(&unicode.Latin) 2384 | vars["Lepcha"] = reflect.ValueOf(&unicode.Lepcha) 2385 | vars["Limbu"] = reflect.ValueOf(&unicode.Limbu) 2386 | vars["Linear_A"] = reflect.ValueOf(&unicode.Linear_A) 2387 | vars["Linear_B"] = reflect.ValueOf(&unicode.Linear_B) 2388 | vars["Lisu"] = reflect.ValueOf(&unicode.Lisu) 2389 | vars["Lycian"] = reflect.ValueOf(&unicode.Lycian) 2390 | vars["Lydian"] = reflect.ValueOf(&unicode.Lydian) 2391 | vars["Mahajani"] = reflect.ValueOf(&unicode.Mahajani) 2392 | vars["Malayalam"] = reflect.ValueOf(&unicode.Malayalam) 2393 | vars["Mandaic"] = reflect.ValueOf(&unicode.Mandaic) 2394 | vars["Manichaean"] = reflect.ValueOf(&unicode.Manichaean) 2395 | vars["Meetei_Mayek"] = reflect.ValueOf(&unicode.Meetei_Mayek) 2396 | vars["Mende_Kikakui"] = reflect.ValueOf(&unicode.Mende_Kikakui) 2397 | vars["Meroitic_Cursive"] = reflect.ValueOf(&unicode.Meroitic_Cursive) 2398 | vars["Meroitic_Hieroglyphs"] = reflect.ValueOf(&unicode.Meroitic_Hieroglyphs) 2399 | vars["Miao"] = reflect.ValueOf(&unicode.Miao) 2400 | vars["Modi"] = reflect.ValueOf(&unicode.Modi) 2401 | vars["Mongolian"] = reflect.ValueOf(&unicode.Mongolian) 2402 | vars["Mro"] = reflect.ValueOf(&unicode.Mro) 2403 | vars["Myanmar"] = reflect.ValueOf(&unicode.Myanmar) 2404 | vars["Nabataean"] = reflect.ValueOf(&unicode.Nabataean) 2405 | vars["New_Tai_Lue"] = reflect.ValueOf(&unicode.New_Tai_Lue) 2406 | vars["Nko"] = reflect.ValueOf(&unicode.Nko) 2407 | vars["Ogham"] = reflect.ValueOf(&unicode.Ogham) 2408 | vars["Ol_Chiki"] = reflect.ValueOf(&unicode.Ol_Chiki) 2409 | vars["Old_Italic"] = reflect.ValueOf(&unicode.Old_Italic) 2410 | vars["Old_North_Arabian"] = reflect.ValueOf(&unicode.Old_North_Arabian) 2411 | vars["Old_Permic"] = reflect.ValueOf(&unicode.Old_Permic) 2412 | vars["Old_Persian"] = reflect.ValueOf(&unicode.Old_Persian) 2413 | vars["Old_South_Arabian"] = reflect.ValueOf(&unicode.Old_South_Arabian) 2414 | vars["Old_Turkic"] = reflect.ValueOf(&unicode.Old_Turkic) 2415 | vars["Oriya"] = reflect.ValueOf(&unicode.Oriya) 2416 | vars["Osmanya"] = reflect.ValueOf(&unicode.Osmanya) 2417 | vars["Pahawh_Hmong"] = reflect.ValueOf(&unicode.Pahawh_Hmong) 2418 | vars["Palmyrene"] = reflect.ValueOf(&unicode.Palmyrene) 2419 | vars["Pau_Cin_Hau"] = reflect.ValueOf(&unicode.Pau_Cin_Hau) 2420 | vars["Phags_Pa"] = reflect.ValueOf(&unicode.Phags_Pa) 2421 | vars["Phoenician"] = reflect.ValueOf(&unicode.Phoenician) 2422 | vars["Psalter_Pahlavi"] = reflect.ValueOf(&unicode.Psalter_Pahlavi) 2423 | vars["Rejang"] = reflect.ValueOf(&unicode.Rejang) 2424 | vars["Runic"] = reflect.ValueOf(&unicode.Runic) 2425 | vars["Samaritan"] = reflect.ValueOf(&unicode.Samaritan) 2426 | vars["Saurashtra"] = reflect.ValueOf(&unicode.Saurashtra) 2427 | vars["Sharada"] = reflect.ValueOf(&unicode.Sharada) 2428 | vars["Shavian"] = reflect.ValueOf(&unicode.Shavian) 2429 | vars["Siddham"] = reflect.ValueOf(&unicode.Siddham) 2430 | vars["Sinhala"] = reflect.ValueOf(&unicode.Sinhala) 2431 | vars["Sora_Sompeng"] = reflect.ValueOf(&unicode.Sora_Sompeng) 2432 | vars["Sundanese"] = reflect.ValueOf(&unicode.Sundanese) 2433 | vars["Syloti_Nagri"] = reflect.ValueOf(&unicode.Syloti_Nagri) 2434 | vars["Syriac"] = reflect.ValueOf(&unicode.Syriac) 2435 | vars["Tagalog"] = reflect.ValueOf(&unicode.Tagalog) 2436 | vars["Tagbanwa"] = reflect.ValueOf(&unicode.Tagbanwa) 2437 | vars["Tai_Le"] = reflect.ValueOf(&unicode.Tai_Le) 2438 | vars["Tai_Tham"] = reflect.ValueOf(&unicode.Tai_Tham) 2439 | vars["Tai_Viet"] = reflect.ValueOf(&unicode.Tai_Viet) 2440 | vars["Takri"] = reflect.ValueOf(&unicode.Takri) 2441 | vars["Tamil"] = reflect.ValueOf(&unicode.Tamil) 2442 | vars["Telugu"] = reflect.ValueOf(&unicode.Telugu) 2443 | vars["Thaana"] = reflect.ValueOf(&unicode.Thaana) 2444 | vars["Thai"] = reflect.ValueOf(&unicode.Thai) 2445 | vars["Tibetan"] = reflect.ValueOf(&unicode.Tibetan) 2446 | vars["Tifinagh"] = reflect.ValueOf(&unicode.Tifinagh) 2447 | vars["Tirhuta"] = reflect.ValueOf(&unicode.Tirhuta) 2448 | vars["Ugaritic"] = reflect.ValueOf(&unicode.Ugaritic) 2449 | vars["Vai"] = reflect.ValueOf(&unicode.Vai) 2450 | vars["Warang_Citi"] = reflect.ValueOf(&unicode.Warang_Citi) 2451 | vars["Yi"] = reflect.ValueOf(&unicode.Yi) 2452 | vars["Properties"] = reflect.ValueOf(&unicode.Properties) 2453 | vars["ASCII_Hex_Digit"] = reflect.ValueOf(&unicode.ASCII_Hex_Digit) 2454 | vars["Bidi_Control"] = reflect.ValueOf(&unicode.Bidi_Control) 2455 | vars["Dash"] = reflect.ValueOf(&unicode.Dash) 2456 | vars["Deprecated"] = reflect.ValueOf(&unicode.Deprecated) 2457 | vars["Diacritic"] = reflect.ValueOf(&unicode.Diacritic) 2458 | vars["Extender"] = reflect.ValueOf(&unicode.Extender) 2459 | vars["Hex_Digit"] = reflect.ValueOf(&unicode.Hex_Digit) 2460 | vars["Hyphen"] = reflect.ValueOf(&unicode.Hyphen) 2461 | vars["IDS_Binary_Operator"] = reflect.ValueOf(&unicode.IDS_Binary_Operator) 2462 | vars["IDS_Trinary_Operator"] = reflect.ValueOf(&unicode.IDS_Trinary_Operator) 2463 | vars["Ideographic"] = reflect.ValueOf(&unicode.Ideographic) 2464 | vars["Join_Control"] = reflect.ValueOf(&unicode.Join_Control) 2465 | vars["Logical_Order_Exception"] = reflect.ValueOf(&unicode.Logical_Order_Exception) 2466 | vars["Noncharacter_Code_Point"] = reflect.ValueOf(&unicode.Noncharacter_Code_Point) 2467 | vars["Other_Alphabetic"] = reflect.ValueOf(&unicode.Other_Alphabetic) 2468 | vars["Other_Default_Ignorable_Code_Point"] = reflect.ValueOf(&unicode.Other_Default_Ignorable_Code_Point) 2469 | vars["Other_Grapheme_Extend"] = reflect.ValueOf(&unicode.Other_Grapheme_Extend) 2470 | vars["Other_ID_Continue"] = reflect.ValueOf(&unicode.Other_ID_Continue) 2471 | vars["Other_ID_Start"] = reflect.ValueOf(&unicode.Other_ID_Start) 2472 | vars["Other_Lowercase"] = reflect.ValueOf(&unicode.Other_Lowercase) 2473 | vars["Other_Math"] = reflect.ValueOf(&unicode.Other_Math) 2474 | vars["Other_Uppercase"] = reflect.ValueOf(&unicode.Other_Uppercase) 2475 | vars["Pattern_Syntax"] = reflect.ValueOf(&unicode.Pattern_Syntax) 2476 | vars["Pattern_White_Space"] = reflect.ValueOf(&unicode.Pattern_White_Space) 2477 | vars["Quotation_Mark"] = reflect.ValueOf(&unicode.Quotation_Mark) 2478 | vars["Radical"] = reflect.ValueOf(&unicode.Radical) 2479 | vars["STerm"] = reflect.ValueOf(&unicode.STerm) 2480 | vars["Soft_Dotted"] = reflect.ValueOf(&unicode.Soft_Dotted) 2481 | vars["Terminal_Punctuation"] = reflect.ValueOf(&unicode.Terminal_Punctuation) 2482 | vars["Unified_Ideograph"] = reflect.ValueOf(&unicode.Unified_Ideograph) 2483 | vars["Variation_Selector"] = reflect.ValueOf(&unicode.Variation_Selector) 2484 | vars["White_Space"] = reflect.ValueOf(&unicode.White_Space) 2485 | vars["CaseRanges"] = reflect.ValueOf(&unicode.CaseRanges) 2486 | vars["FoldCategory"] = reflect.ValueOf(&unicode.FoldCategory) 2487 | vars["FoldScript"] = reflect.ValueOf(&unicode.FoldScript) 2488 | pkgs["unicode"] = &eval.SimpleEnv { 2489 | Consts: consts, 2490 | Funcs: funcs, 2491 | Types: types, 2492 | Vars: vars, 2493 | Pkgs: pkgs, 2494 | } 2495 | consts = make(map[string] reflect.Value) 2496 | consts["RuneError"] = reflect.ValueOf(utf8.RuneError) 2497 | consts["RuneSelf"] = reflect.ValueOf(utf8.RuneSelf) 2498 | consts["MaxRune"] = reflect.ValueOf(utf8.MaxRune) 2499 | consts["UTFMax"] = reflect.ValueOf(utf8.UTFMax) 2500 | 2501 | funcs = make(map[string] reflect.Value) 2502 | funcs["FullRune"] = reflect.ValueOf(utf8.FullRune) 2503 | funcs["FullRuneInString"] = reflect.ValueOf(utf8.FullRuneInString) 2504 | funcs["DecodeRune"] = reflect.ValueOf(utf8.DecodeRune) 2505 | funcs["DecodeRuneInString"] = reflect.ValueOf(utf8.DecodeRuneInString) 2506 | funcs["DecodeLastRune"] = reflect.ValueOf(utf8.DecodeLastRune) 2507 | funcs["DecodeLastRuneInString"] = reflect.ValueOf(utf8.DecodeLastRuneInString) 2508 | funcs["RuneLen"] = reflect.ValueOf(utf8.RuneLen) 2509 | funcs["EncodeRune"] = reflect.ValueOf(utf8.EncodeRune) 2510 | funcs["RuneCount"] = reflect.ValueOf(utf8.RuneCount) 2511 | funcs["RuneCountInString"] = reflect.ValueOf(utf8.RuneCountInString) 2512 | funcs["RuneStart"] = reflect.ValueOf(utf8.RuneStart) 2513 | funcs["Valid"] = reflect.ValueOf(utf8.Valid) 2514 | funcs["ValidString"] = reflect.ValueOf(utf8.ValidString) 2515 | funcs["ValidRune"] = reflect.ValueOf(utf8.ValidRune) 2516 | 2517 | types = make(map[string] reflect.Type) 2518 | 2519 | vars = make(map[string] reflect.Value) 2520 | pkgs["utf8"] = &eval.SimpleEnv { 2521 | Consts: consts, 2522 | Funcs: funcs, 2523 | Types: types, 2524 | Vars: vars, 2525 | Pkgs: pkgs, 2526 | } 2527 | 2528 | mainEnv := eval.MakeSimpleEnv() 2529 | mainEnv.Pkgs = pkgs 2530 | return mainEnv 2531 | } -------------------------------------------------------------------------------- /subcmds.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // REPL subcommands 5 | 6 | package repl 7 | 8 | import ( 9 | "sort" 10 | "strings" 11 | "code.google.com/p/go-columnize" 12 | ) 13 | 14 | type SubcmdFunc func([]string) 15 | 16 | type SubcmdInfo struct { 17 | Help string 18 | Short_help string 19 | Min_args int 20 | Max_args int 21 | Fn SubcmdFunc 22 | Name string 23 | } 24 | 25 | type SubcmdMap map[string]*SubcmdInfo 26 | 27 | // SubcmdMgr contains the name of a debugger command that has 28 | // subcommands, "info", and "set" are examples of such commmands,and 29 | // information about each of the subcommands. 30 | type SubcmdMgr struct { 31 | Name string 32 | Subcmds SubcmdMap 33 | } 34 | 35 | // Subcmds is a map of a debugger subcommand name to information about 36 | // that subcommand. For example, the "info" command has subcommands 37 | // "break", "program", "line" and so on. 38 | var Subcmds map[string]*SubcmdInfo = make(map[string]*SubcmdInfo) 39 | 40 | // AddSubCommand adds to the subcommand manager mgrName, subcommand 41 | // subcmdInfo. 42 | func AddSubCommand(mgrName string, subcmdInfo *SubcmdInfo) { 43 | Subcmds[mgrName] = subcmdInfo 44 | mgr := Cmds[mgrName] 45 | if mgr != nil { 46 | mgr.SubcmdMgr.Subcmds[subcmdInfo.Name] = subcmdInfo 47 | } else { 48 | Errmsg("Internal error: can't find command '%s' to add to", subcmdInfo.Name) 49 | } 50 | } 51 | 52 | func ListSubCommandArgs(mgr *SubcmdMgr) { 53 | Section("List of " + mgr.Name + " commands") 54 | subcmds := mgr.Subcmds 55 | 56 | names := make([]string, len(subcmds)) 57 | i := 0 58 | for name, _ := range subcmds { 59 | names[i] = name 60 | i++ 61 | } 62 | sort.Strings(names) 63 | 64 | for _, name := range names { 65 | Msg("%-10s -- %s", name, subcmds[name].Short_help) 66 | } 67 | } 68 | 69 | func HelpSubCommand(subcmdMgr *SubcmdMgr, args []string) { 70 | if len(args) == 2 { 71 | Msg(Cmds[subcmdMgr.Name].Help) 72 | } else { 73 | what := args[2] 74 | if what == "*" { 75 | var names []string 76 | for name, _ := range subcmdMgr.Subcmds { 77 | names = append(names, name) 78 | } 79 | Section("All %s subcommand names:", subcmdMgr.Name) 80 | sort.Strings(names) 81 | opts := columnize.DefaultOptions() 82 | opts.DisplayWidth = Maxwidth 83 | mems := strings.TrimRight(columnize.Columnize(names, opts), 84 | "\n") 85 | Msg(mems) 86 | } else if info := subcmdMgr.Subcmds[what]; info != nil { 87 | Msg(info.Help) 88 | } else { 89 | Errmsg("Can't find help for subcommand '%s' in %s", what, subcmdMgr.Name) 90 | } 91 | } 92 | } 93 | 94 | func UnknownSubCommand(cmdName, subcmdName string) { 95 | Errmsg("Unknown \"%st\" subcommand \"%s\".", cmdName, subcmdName) 96 | Errmsg("Try \"help %s *\".", cmdName) 97 | } 98 | 99 | func SubcmdMgrCommand(args []string) { 100 | cmdName := args[0] 101 | if len(args) == 1 { 102 | ListSubCommandArgs(Cmds[cmdName].SubcmdMgr) 103 | return 104 | } 105 | 106 | subcmd_name := args[1] 107 | subcmds := Cmds[cmdName].SubcmdMgr.Subcmds 108 | subcmd_info := subcmds[subcmd_name] 109 | 110 | if subcmd_info != nil { 111 | if ArgCountOK(subcmd_info.Min_args+1, subcmd_info.Max_args+1, args) { 112 | subcmds[subcmd_name].Fn(args) 113 | } 114 | return 115 | } 116 | 117 | Errmsg("Unknown \"%s\" subcommand \"%s\"", cmdName, subcmd_name) 118 | } 119 | -------------------------------------------------------------------------------- /testdata/.gitignore: -------------------------------------------------------------------------------- 1 | /string_imports.got 2 | -------------------------------------------------------------------------------- /testdata/string_imports.go: -------------------------------------------------------------------------------- 1 | // starting import: "strings" 2 | package repl 3 | 4 | import ( 5 | "errors" 6 | "io" 7 | "runtime" 8 | "strings" 9 | "sync" 10 | "sync/atomic" 11 | "unicode" 12 | "unicode/utf8" 13 | ) 14 | 15 | // EvalEnvironment adds to eval.Env those packages included 16 | // with import "strings". 17 | 18 | func EvalEnvironment() *eval.SimpleEnv { 19 | var consts map[string] reflect.Value 20 | var vars map[string] reflect.Value 21 | var types map[string] reflect.Type 22 | var funcs map[string] reflect.Value 23 | var pkgs map[string] eval.Env = make(map[string] eval.Env) 24 | 25 | consts = make(map[string] reflect.Value) 26 | 27 | funcs = make(map[string] reflect.Value) 28 | funcs["New"] = reflect.ValueOf(errors.New) 29 | 30 | types = make(map[string] reflect.Type) 31 | 32 | vars = make(map[string] reflect.Value) 33 | pkgs["errors"] = &eval.SimpleEnv { 34 | Consts: consts, 35 | Funcs: funcs, 36 | Types: types, 37 | Vars: vars, 38 | Pkgs: pkgs, 39 | } 40 | consts = make(map[string] reflect.Value) 41 | 42 | funcs = make(map[string] reflect.Value) 43 | funcs["WriteString"] = reflect.ValueOf(io.WriteString) 44 | funcs["ReadAtLeast"] = reflect.ValueOf(io.ReadAtLeast) 45 | funcs["ReadFull"] = reflect.ValueOf(io.ReadFull) 46 | funcs["CopyN"] = reflect.ValueOf(io.CopyN) 47 | funcs["Copy"] = reflect.ValueOf(io.Copy) 48 | funcs["LimitReader"] = reflect.ValueOf(io.LimitReader) 49 | funcs["NewSectionReader"] = reflect.ValueOf(io.NewSectionReader) 50 | funcs["TeeReader"] = reflect.ValueOf(io.TeeReader) 51 | funcs["MultiReader"] = reflect.ValueOf(io.MultiReader) 52 | funcs["MultiWriter"] = reflect.ValueOf(io.MultiWriter) 53 | funcs["Pipe"] = reflect.ValueOf(io.Pipe) 54 | 55 | types = make(map[string] reflect.Type) 56 | types["Reader"] = reflect.TypeOf(new(io.Reader)).Elem() 57 | types["Writer"] = reflect.TypeOf(new(io.Writer)).Elem() 58 | types["Closer"] = reflect.TypeOf(new(io.Closer)).Elem() 59 | types["Seeker"] = reflect.TypeOf(new(io.Seeker)).Elem() 60 | types["ReadWriter"] = reflect.TypeOf(new(io.ReadWriter)).Elem() 61 | types["ReadCloser"] = reflect.TypeOf(new(io.ReadCloser)).Elem() 62 | types["WriteCloser"] = reflect.TypeOf(new(io.WriteCloser)).Elem() 63 | types["ReadWriteCloser"] = reflect.TypeOf(new(io.ReadWriteCloser)).Elem() 64 | types["ReadSeeker"] = reflect.TypeOf(new(io.ReadSeeker)).Elem() 65 | types["WriteSeeker"] = reflect.TypeOf(new(io.WriteSeeker)).Elem() 66 | types["ReadWriteSeeker"] = reflect.TypeOf(new(io.ReadWriteSeeker)).Elem() 67 | types["ReaderFrom"] = reflect.TypeOf(new(io.ReaderFrom)).Elem() 68 | types["WriterTo"] = reflect.TypeOf(new(io.WriterTo)).Elem() 69 | types["ReaderAt"] = reflect.TypeOf(new(io.ReaderAt)).Elem() 70 | types["WriterAt"] = reflect.TypeOf(new(io.WriterAt)).Elem() 71 | types["ByteReader"] = reflect.TypeOf(new(io.ByteReader)).Elem() 72 | types["ByteScanner"] = reflect.TypeOf(new(io.ByteScanner)).Elem() 73 | types["ByteWriter"] = reflect.TypeOf(new(io.ByteWriter)).Elem() 74 | types["RuneReader"] = reflect.TypeOf(new(io.RuneReader)).Elem() 75 | types["RuneScanner"] = reflect.TypeOf(new(io.RuneScanner)).Elem() 76 | types["LimitedReader"] = reflect.TypeOf(new(io.LimitedReader)).Elem() 77 | types["SectionReader"] = reflect.TypeOf(new(io.SectionReader)).Elem() 78 | types["PipeReader"] = reflect.TypeOf(new(io.PipeReader)).Elem() 79 | types["PipeWriter"] = reflect.TypeOf(new(io.PipeWriter)).Elem() 80 | 81 | vars = make(map[string] reflect.Value) 82 | vars["ErrShortWrite"] = reflect.ValueOf(&io.ErrShortWrite) 83 | vars["ErrShortBuffer"] = reflect.ValueOf(&io.ErrShortBuffer) 84 | vars["EOF"] = reflect.ValueOf(&io.EOF) 85 | vars["ErrUnexpectedEOF"] = reflect.ValueOf(&io.ErrUnexpectedEOF) 86 | vars["ErrNoProgress"] = reflect.ValueOf(&io.ErrNoProgress) 87 | vars["ErrClosedPipe"] = reflect.ValueOf(&io.ErrClosedPipe) 88 | pkgs["io"] = &eval.SimpleEnv { 89 | Consts: consts, 90 | Funcs: funcs, 91 | Types: types, 92 | Vars: vars, 93 | Pkgs: pkgs, 94 | } 95 | consts = make(map[string] reflect.Value) 96 | consts["Compiler"] = reflect.ValueOf(runtime.Compiler) 97 | consts["GOOS"] = reflect.ValueOf(runtime.GOOS) 98 | consts["GOARCH"] = reflect.ValueOf(runtime.GOARCH) 99 | 100 | funcs = make(map[string] reflect.Value) 101 | funcs["SetCPUProfileRate"] = reflect.ValueOf(runtime.SetCPUProfileRate) 102 | funcs["CPUProfile"] = reflect.ValueOf(runtime.CPUProfile) 103 | funcs["Breakpoint"] = reflect.ValueOf(runtime.Breakpoint) 104 | funcs["LockOSThread"] = reflect.ValueOf(runtime.LockOSThread) 105 | funcs["UnlockOSThread"] = reflect.ValueOf(runtime.UnlockOSThread) 106 | funcs["GOMAXPROCS"] = reflect.ValueOf(runtime.GOMAXPROCS) 107 | funcs["NumCPU"] = reflect.ValueOf(runtime.NumCPU) 108 | funcs["NumCgoCall"] = reflect.ValueOf(runtime.NumCgoCall) 109 | funcs["NumGoroutine"] = reflect.ValueOf(runtime.NumGoroutine) 110 | funcs["Caller"] = reflect.ValueOf(runtime.Caller) 111 | funcs["Callers"] = reflect.ValueOf(runtime.Callers) 112 | funcs["GOROOT"] = reflect.ValueOf(runtime.GOROOT) 113 | funcs["Version"] = reflect.ValueOf(runtime.Version) 114 | funcs["GC"] = reflect.ValueOf(runtime.GC) 115 | funcs["SetFinalizer"] = reflect.ValueOf(runtime.SetFinalizer) 116 | funcs["ReadMemStats"] = reflect.ValueOf(runtime.ReadMemStats) 117 | funcs["SetBlockProfileRate"] = reflect.ValueOf(runtime.SetBlockProfileRate) 118 | funcs["MemProfile"] = reflect.ValueOf(runtime.MemProfile) 119 | funcs["BlockProfile"] = reflect.ValueOf(runtime.BlockProfile) 120 | funcs["ThreadCreateProfile"] = reflect.ValueOf(runtime.ThreadCreateProfile) 121 | funcs["GoroutineProfile"] = reflect.ValueOf(runtime.GoroutineProfile) 122 | funcs["Stack"] = reflect.ValueOf(runtime.Stack) 123 | funcs["Goexit"] = reflect.ValueOf(runtime.Goexit) 124 | funcs["Gosched"] = reflect.ValueOf(runtime.Gosched) 125 | funcs["FuncForPC"] = reflect.ValueOf(runtime.FuncForPC) 126 | 127 | types = make(map[string] reflect.Type) 128 | types["Error"] = reflect.TypeOf(new(runtime.Error)).Elem() 129 | types["TypeAssertionError"] = reflect.TypeOf(new(runtime.TypeAssertionError)).Elem() 130 | types["MemStats"] = reflect.TypeOf(new(runtime.MemStats)).Elem() 131 | types["StackRecord"] = reflect.TypeOf(new(runtime.StackRecord)).Elem() 132 | types["MemProfileRecord"] = reflect.TypeOf(new(runtime.MemProfileRecord)).Elem() 133 | types["BlockProfileRecord"] = reflect.TypeOf(new(runtime.BlockProfileRecord)).Elem() 134 | types["Func"] = reflect.TypeOf(new(runtime.Func)).Elem() 135 | 136 | vars = make(map[string] reflect.Value) 137 | vars["MemProfileRate"] = reflect.ValueOf(&runtime.MemProfileRate) 138 | pkgs["runtime"] = &eval.SimpleEnv { 139 | Consts: consts, 140 | Funcs: funcs, 141 | Types: types, 142 | Vars: vars, 143 | Pkgs: pkgs, 144 | } 145 | consts = make(map[string] reflect.Value) 146 | 147 | funcs = make(map[string] reflect.Value) 148 | funcs["NewReader"] = reflect.ValueOf(strings.NewReader) 149 | funcs["NewReplacer"] = reflect.ValueOf(strings.NewReplacer) 150 | funcs["Count"] = reflect.ValueOf(strings.Count) 151 | funcs["Contains"] = reflect.ValueOf(strings.Contains) 152 | funcs["ContainsAny"] = reflect.ValueOf(strings.ContainsAny) 153 | funcs["ContainsRune"] = reflect.ValueOf(strings.ContainsRune) 154 | funcs["Index"] = reflect.ValueOf(strings.Index) 155 | funcs["LastIndex"] = reflect.ValueOf(strings.LastIndex) 156 | funcs["IndexRune"] = reflect.ValueOf(strings.IndexRune) 157 | funcs["IndexAny"] = reflect.ValueOf(strings.IndexAny) 158 | funcs["LastIndexAny"] = reflect.ValueOf(strings.LastIndexAny) 159 | funcs["SplitN"] = reflect.ValueOf(strings.SplitN) 160 | funcs["SplitAfterN"] = reflect.ValueOf(strings.SplitAfterN) 161 | funcs["Split"] = reflect.ValueOf(strings.Split) 162 | funcs["SplitAfter"] = reflect.ValueOf(strings.SplitAfter) 163 | funcs["Fields"] = reflect.ValueOf(strings.Fields) 164 | funcs["FieldsFunc"] = reflect.ValueOf(strings.FieldsFunc) 165 | funcs["Join"] = reflect.ValueOf(strings.Join) 166 | funcs["HasPrefix"] = reflect.ValueOf(strings.HasPrefix) 167 | funcs["HasSuffix"] = reflect.ValueOf(strings.HasSuffix) 168 | funcs["Map"] = reflect.ValueOf(strings.Map) 169 | funcs["Repeat"] = reflect.ValueOf(strings.Repeat) 170 | funcs["ToUpper"] = reflect.ValueOf(strings.ToUpper) 171 | funcs["ToLower"] = reflect.ValueOf(strings.ToLower) 172 | funcs["ToTitle"] = reflect.ValueOf(strings.ToTitle) 173 | funcs["ToUpperSpecial"] = reflect.ValueOf(strings.ToUpperSpecial) 174 | funcs["ToLowerSpecial"] = reflect.ValueOf(strings.ToLowerSpecial) 175 | funcs["ToTitleSpecial"] = reflect.ValueOf(strings.ToTitleSpecial) 176 | funcs["Title"] = reflect.ValueOf(strings.Title) 177 | funcs["TrimLeftFunc"] = reflect.ValueOf(strings.TrimLeftFunc) 178 | funcs["TrimRightFunc"] = reflect.ValueOf(strings.TrimRightFunc) 179 | funcs["TrimFunc"] = reflect.ValueOf(strings.TrimFunc) 180 | funcs["IndexFunc"] = reflect.ValueOf(strings.IndexFunc) 181 | funcs["LastIndexFunc"] = reflect.ValueOf(strings.LastIndexFunc) 182 | funcs["Trim"] = reflect.ValueOf(strings.Trim) 183 | funcs["TrimLeft"] = reflect.ValueOf(strings.TrimLeft) 184 | funcs["TrimRight"] = reflect.ValueOf(strings.TrimRight) 185 | funcs["TrimSpace"] = reflect.ValueOf(strings.TrimSpace) 186 | funcs["TrimPrefix"] = reflect.ValueOf(strings.TrimPrefix) 187 | funcs["TrimSuffix"] = reflect.ValueOf(strings.TrimSuffix) 188 | funcs["Replace"] = reflect.ValueOf(strings.Replace) 189 | funcs["EqualFold"] = reflect.ValueOf(strings.EqualFold) 190 | funcs["IndexByte"] = reflect.ValueOf(strings.IndexByte) 191 | 192 | types = make(map[string] reflect.Type) 193 | types["Reader"] = reflect.TypeOf(new(strings.Reader)).Elem() 194 | types["Replacer"] = reflect.TypeOf(new(strings.Replacer)).Elem() 195 | 196 | vars = make(map[string] reflect.Value) 197 | pkgs["strings"] = &eval.SimpleEnv { 198 | Consts: consts, 199 | Funcs: funcs, 200 | Types: types, 201 | Vars: vars, 202 | Pkgs: pkgs, 203 | } 204 | consts = make(map[string] reflect.Value) 205 | 206 | funcs = make(map[string] reflect.Value) 207 | funcs["NewCond"] = reflect.ValueOf(sync.NewCond) 208 | 209 | types = make(map[string] reflect.Type) 210 | types["Cond"] = reflect.TypeOf(new(sync.Cond)).Elem() 211 | types["Mutex"] = reflect.TypeOf(new(sync.Mutex)).Elem() 212 | types["Locker"] = reflect.TypeOf(new(sync.Locker)).Elem() 213 | types["Once"] = reflect.TypeOf(new(sync.Once)).Elem() 214 | types["Pool"] = reflect.TypeOf(new(sync.Pool)).Elem() 215 | types["RWMutex"] = reflect.TypeOf(new(sync.RWMutex)).Elem() 216 | types["WaitGroup"] = reflect.TypeOf(new(sync.WaitGroup)).Elem() 217 | 218 | vars = make(map[string] reflect.Value) 219 | pkgs["sync"] = &eval.SimpleEnv { 220 | Consts: consts, 221 | Funcs: funcs, 222 | Types: types, 223 | Vars: vars, 224 | Pkgs: pkgs, 225 | } 226 | consts = make(map[string] reflect.Value) 227 | 228 | funcs = make(map[string] reflect.Value) 229 | funcs["SwapInt32"] = reflect.ValueOf(atomic.SwapInt32) 230 | funcs["SwapInt64"] = reflect.ValueOf(atomic.SwapInt64) 231 | funcs["SwapUint32"] = reflect.ValueOf(atomic.SwapUint32) 232 | funcs["SwapUint64"] = reflect.ValueOf(atomic.SwapUint64) 233 | funcs["SwapUintptr"] = reflect.ValueOf(atomic.SwapUintptr) 234 | funcs["SwapPointer"] = reflect.ValueOf(atomic.SwapPointer) 235 | funcs["CompareAndSwapInt32"] = reflect.ValueOf(atomic.CompareAndSwapInt32) 236 | funcs["CompareAndSwapInt64"] = reflect.ValueOf(atomic.CompareAndSwapInt64) 237 | funcs["CompareAndSwapUint32"] = reflect.ValueOf(atomic.CompareAndSwapUint32) 238 | funcs["CompareAndSwapUint64"] = reflect.ValueOf(atomic.CompareAndSwapUint64) 239 | funcs["CompareAndSwapUintptr"] = reflect.ValueOf(atomic.CompareAndSwapUintptr) 240 | funcs["CompareAndSwapPointer"] = reflect.ValueOf(atomic.CompareAndSwapPointer) 241 | funcs["AddInt32"] = reflect.ValueOf(atomic.AddInt32) 242 | funcs["AddUint32"] = reflect.ValueOf(atomic.AddUint32) 243 | funcs["AddInt64"] = reflect.ValueOf(atomic.AddInt64) 244 | funcs["AddUint64"] = reflect.ValueOf(atomic.AddUint64) 245 | funcs["AddUintptr"] = reflect.ValueOf(atomic.AddUintptr) 246 | funcs["LoadInt32"] = reflect.ValueOf(atomic.LoadInt32) 247 | funcs["LoadInt64"] = reflect.ValueOf(atomic.LoadInt64) 248 | funcs["LoadUint32"] = reflect.ValueOf(atomic.LoadUint32) 249 | funcs["LoadUint64"] = reflect.ValueOf(atomic.LoadUint64) 250 | funcs["LoadUintptr"] = reflect.ValueOf(atomic.LoadUintptr) 251 | funcs["LoadPointer"] = reflect.ValueOf(atomic.LoadPointer) 252 | funcs["StoreInt32"] = reflect.ValueOf(atomic.StoreInt32) 253 | funcs["StoreInt64"] = reflect.ValueOf(atomic.StoreInt64) 254 | funcs["StoreUint32"] = reflect.ValueOf(atomic.StoreUint32) 255 | funcs["StoreUint64"] = reflect.ValueOf(atomic.StoreUint64) 256 | funcs["StoreUintptr"] = reflect.ValueOf(atomic.StoreUintptr) 257 | funcs["StorePointer"] = reflect.ValueOf(atomic.StorePointer) 258 | 259 | types = make(map[string] reflect.Type) 260 | types["Value"] = reflect.TypeOf(new(atomic.Value)).Elem() 261 | 262 | vars = make(map[string] reflect.Value) 263 | pkgs["atomic"] = &eval.SimpleEnv { 264 | Consts: consts, 265 | Funcs: funcs, 266 | Types: types, 267 | Vars: vars, 268 | Pkgs: pkgs, 269 | } 270 | consts = make(map[string] reflect.Value) 271 | consts["MaxRune"] = reflect.ValueOf(unicode.MaxRune) 272 | consts["ReplacementChar"] = reflect.ValueOf(unicode.ReplacementChar) 273 | consts["MaxASCII"] = reflect.ValueOf(unicode.MaxASCII) 274 | consts["MaxLatin1"] = reflect.ValueOf(unicode.MaxLatin1) 275 | consts["UpperCase"] = reflect.ValueOf(unicode.UpperCase) 276 | consts["LowerCase"] = reflect.ValueOf(unicode.LowerCase) 277 | consts["TitleCase"] = reflect.ValueOf(unicode.TitleCase) 278 | consts["MaxCase"] = reflect.ValueOf(unicode.MaxCase) 279 | consts["UpperLower"] = reflect.ValueOf(unicode.UpperLower) 280 | consts["Version"] = reflect.ValueOf(unicode.Version) 281 | 282 | funcs = make(map[string] reflect.Value) 283 | funcs["IsDigit"] = reflect.ValueOf(unicode.IsDigit) 284 | funcs["IsGraphic"] = reflect.ValueOf(unicode.IsGraphic) 285 | funcs["IsPrint"] = reflect.ValueOf(unicode.IsPrint) 286 | funcs["IsOneOf"] = reflect.ValueOf(unicode.IsOneOf) 287 | funcs["In"] = reflect.ValueOf(unicode.In) 288 | funcs["IsControl"] = reflect.ValueOf(unicode.IsControl) 289 | funcs["IsLetter"] = reflect.ValueOf(unicode.IsLetter) 290 | funcs["IsMark"] = reflect.ValueOf(unicode.IsMark) 291 | funcs["IsNumber"] = reflect.ValueOf(unicode.IsNumber) 292 | funcs["IsPunct"] = reflect.ValueOf(unicode.IsPunct) 293 | funcs["IsSpace"] = reflect.ValueOf(unicode.IsSpace) 294 | funcs["IsSymbol"] = reflect.ValueOf(unicode.IsSymbol) 295 | funcs["Is"] = reflect.ValueOf(unicode.Is) 296 | funcs["IsUpper"] = reflect.ValueOf(unicode.IsUpper) 297 | funcs["IsLower"] = reflect.ValueOf(unicode.IsLower) 298 | funcs["IsTitle"] = reflect.ValueOf(unicode.IsTitle) 299 | funcs["To"] = reflect.ValueOf(unicode.To) 300 | funcs["ToUpper"] = reflect.ValueOf(unicode.ToUpper) 301 | funcs["ToLower"] = reflect.ValueOf(unicode.ToLower) 302 | funcs["ToTitle"] = reflect.ValueOf(unicode.ToTitle) 303 | funcs["SimpleFold"] = reflect.ValueOf(unicode.SimpleFold) 304 | 305 | types = make(map[string] reflect.Type) 306 | types["RangeTable"] = reflect.TypeOf(new(unicode.RangeTable)).Elem() 307 | types["Range16"] = reflect.TypeOf(new(unicode.Range16)).Elem() 308 | types["Range32"] = reflect.TypeOf(new(unicode.Range32)).Elem() 309 | types["CaseRange"] = reflect.TypeOf(new(unicode.CaseRange)).Elem() 310 | types["SpecialCase"] = reflect.TypeOf(new(unicode.SpecialCase)).Elem() 311 | 312 | vars = make(map[string] reflect.Value) 313 | vars["TurkishCase"] = reflect.ValueOf(&unicode.TurkishCase) 314 | vars["AzeriCase"] = reflect.ValueOf(&unicode.AzeriCase) 315 | vars["GraphicRanges"] = reflect.ValueOf(&unicode.GraphicRanges) 316 | vars["PrintRanges"] = reflect.ValueOf(&unicode.PrintRanges) 317 | vars["Categories"] = reflect.ValueOf(&unicode.Categories) 318 | vars["Cc"] = reflect.ValueOf(&unicode.Cc) 319 | vars["Cf"] = reflect.ValueOf(&unicode.Cf) 320 | vars["Co"] = reflect.ValueOf(&unicode.Co) 321 | vars["Cs"] = reflect.ValueOf(&unicode.Cs) 322 | vars["Digit"] = reflect.ValueOf(&unicode.Digit) 323 | vars["Nd"] = reflect.ValueOf(&unicode.Nd) 324 | vars["Letter"] = reflect.ValueOf(&unicode.Letter) 325 | vars["L"] = reflect.ValueOf(&unicode.L) 326 | vars["Lm"] = reflect.ValueOf(&unicode.Lm) 327 | vars["Lo"] = reflect.ValueOf(&unicode.Lo) 328 | vars["Lower"] = reflect.ValueOf(&unicode.Lower) 329 | vars["Ll"] = reflect.ValueOf(&unicode.Ll) 330 | vars["Mark"] = reflect.ValueOf(&unicode.Mark) 331 | vars["M"] = reflect.ValueOf(&unicode.M) 332 | vars["Mc"] = reflect.ValueOf(&unicode.Mc) 333 | vars["Me"] = reflect.ValueOf(&unicode.Me) 334 | vars["Mn"] = reflect.ValueOf(&unicode.Mn) 335 | vars["Nl"] = reflect.ValueOf(&unicode.Nl) 336 | vars["No"] = reflect.ValueOf(&unicode.No) 337 | vars["Number"] = reflect.ValueOf(&unicode.Number) 338 | vars["N"] = reflect.ValueOf(&unicode.N) 339 | vars["Other"] = reflect.ValueOf(&unicode.Other) 340 | vars["C"] = reflect.ValueOf(&unicode.C) 341 | vars["Pc"] = reflect.ValueOf(&unicode.Pc) 342 | vars["Pd"] = reflect.ValueOf(&unicode.Pd) 343 | vars["Pe"] = reflect.ValueOf(&unicode.Pe) 344 | vars["Pf"] = reflect.ValueOf(&unicode.Pf) 345 | vars["Pi"] = reflect.ValueOf(&unicode.Pi) 346 | vars["Po"] = reflect.ValueOf(&unicode.Po) 347 | vars["Ps"] = reflect.ValueOf(&unicode.Ps) 348 | vars["Punct"] = reflect.ValueOf(&unicode.Punct) 349 | vars["P"] = reflect.ValueOf(&unicode.P) 350 | vars["Sc"] = reflect.ValueOf(&unicode.Sc) 351 | vars["Sk"] = reflect.ValueOf(&unicode.Sk) 352 | vars["Sm"] = reflect.ValueOf(&unicode.Sm) 353 | vars["So"] = reflect.ValueOf(&unicode.So) 354 | vars["Space"] = reflect.ValueOf(&unicode.Space) 355 | vars["Z"] = reflect.ValueOf(&unicode.Z) 356 | vars["Symbol"] = reflect.ValueOf(&unicode.Symbol) 357 | vars["S"] = reflect.ValueOf(&unicode.S) 358 | vars["Title"] = reflect.ValueOf(&unicode.Title) 359 | vars["Lt"] = reflect.ValueOf(&unicode.Lt) 360 | vars["Upper"] = reflect.ValueOf(&unicode.Upper) 361 | vars["Lu"] = reflect.ValueOf(&unicode.Lu) 362 | vars["Zl"] = reflect.ValueOf(&unicode.Zl) 363 | vars["Zp"] = reflect.ValueOf(&unicode.Zp) 364 | vars["Zs"] = reflect.ValueOf(&unicode.Zs) 365 | vars["Scripts"] = reflect.ValueOf(&unicode.Scripts) 366 | vars["Arabic"] = reflect.ValueOf(&unicode.Arabic) 367 | vars["Armenian"] = reflect.ValueOf(&unicode.Armenian) 368 | vars["Avestan"] = reflect.ValueOf(&unicode.Avestan) 369 | vars["Balinese"] = reflect.ValueOf(&unicode.Balinese) 370 | vars["Bamum"] = reflect.ValueOf(&unicode.Bamum) 371 | vars["Bassa_Vah"] = reflect.ValueOf(&unicode.Bassa_Vah) 372 | vars["Batak"] = reflect.ValueOf(&unicode.Batak) 373 | vars["Bengali"] = reflect.ValueOf(&unicode.Bengali) 374 | vars["Bopomofo"] = reflect.ValueOf(&unicode.Bopomofo) 375 | vars["Brahmi"] = reflect.ValueOf(&unicode.Brahmi) 376 | vars["Braille"] = reflect.ValueOf(&unicode.Braille) 377 | vars["Buginese"] = reflect.ValueOf(&unicode.Buginese) 378 | vars["Buhid"] = reflect.ValueOf(&unicode.Buhid) 379 | vars["Canadian_Aboriginal"] = reflect.ValueOf(&unicode.Canadian_Aboriginal) 380 | vars["Carian"] = reflect.ValueOf(&unicode.Carian) 381 | vars["Caucasian_Albanian"] = reflect.ValueOf(&unicode.Caucasian_Albanian) 382 | vars["Chakma"] = reflect.ValueOf(&unicode.Chakma) 383 | vars["Cham"] = reflect.ValueOf(&unicode.Cham) 384 | vars["Cherokee"] = reflect.ValueOf(&unicode.Cherokee) 385 | vars["Common"] = reflect.ValueOf(&unicode.Common) 386 | vars["Coptic"] = reflect.ValueOf(&unicode.Coptic) 387 | vars["Cuneiform"] = reflect.ValueOf(&unicode.Cuneiform) 388 | vars["Cypriot"] = reflect.ValueOf(&unicode.Cypriot) 389 | vars["Cyrillic"] = reflect.ValueOf(&unicode.Cyrillic) 390 | vars["Deseret"] = reflect.ValueOf(&unicode.Deseret) 391 | vars["Devanagari"] = reflect.ValueOf(&unicode.Devanagari) 392 | vars["Duployan"] = reflect.ValueOf(&unicode.Duployan) 393 | vars["Egyptian_Hieroglyphs"] = reflect.ValueOf(&unicode.Egyptian_Hieroglyphs) 394 | vars["Elbasan"] = reflect.ValueOf(&unicode.Elbasan) 395 | vars["Ethiopic"] = reflect.ValueOf(&unicode.Ethiopic) 396 | vars["Georgian"] = reflect.ValueOf(&unicode.Georgian) 397 | vars["Glagolitic"] = reflect.ValueOf(&unicode.Glagolitic) 398 | vars["Gothic"] = reflect.ValueOf(&unicode.Gothic) 399 | vars["Grantha"] = reflect.ValueOf(&unicode.Grantha) 400 | vars["Greek"] = reflect.ValueOf(&unicode.Greek) 401 | vars["Gujarati"] = reflect.ValueOf(&unicode.Gujarati) 402 | vars["Gurmukhi"] = reflect.ValueOf(&unicode.Gurmukhi) 403 | vars["Han"] = reflect.ValueOf(&unicode.Han) 404 | vars["Hangul"] = reflect.ValueOf(&unicode.Hangul) 405 | vars["Hanunoo"] = reflect.ValueOf(&unicode.Hanunoo) 406 | vars["Hebrew"] = reflect.ValueOf(&unicode.Hebrew) 407 | vars["Hiragana"] = reflect.ValueOf(&unicode.Hiragana) 408 | vars["Imperial_Aramaic"] = reflect.ValueOf(&unicode.Imperial_Aramaic) 409 | vars["Inherited"] = reflect.ValueOf(&unicode.Inherited) 410 | vars["Inscriptional_Pahlavi"] = reflect.ValueOf(&unicode.Inscriptional_Pahlavi) 411 | vars["Inscriptional_Parthian"] = reflect.ValueOf(&unicode.Inscriptional_Parthian) 412 | vars["Javanese"] = reflect.ValueOf(&unicode.Javanese) 413 | vars["Kaithi"] = reflect.ValueOf(&unicode.Kaithi) 414 | vars["Kannada"] = reflect.ValueOf(&unicode.Kannada) 415 | vars["Katakana"] = reflect.ValueOf(&unicode.Katakana) 416 | vars["Kayah_Li"] = reflect.ValueOf(&unicode.Kayah_Li) 417 | vars["Kharoshthi"] = reflect.ValueOf(&unicode.Kharoshthi) 418 | vars["Khmer"] = reflect.ValueOf(&unicode.Khmer) 419 | vars["Khojki"] = reflect.ValueOf(&unicode.Khojki) 420 | vars["Khudawadi"] = reflect.ValueOf(&unicode.Khudawadi) 421 | vars["Lao"] = reflect.ValueOf(&unicode.Lao) 422 | vars["Latin"] = reflect.ValueOf(&unicode.Latin) 423 | vars["Lepcha"] = reflect.ValueOf(&unicode.Lepcha) 424 | vars["Limbu"] = reflect.ValueOf(&unicode.Limbu) 425 | vars["Linear_A"] = reflect.ValueOf(&unicode.Linear_A) 426 | vars["Linear_B"] = reflect.ValueOf(&unicode.Linear_B) 427 | vars["Lisu"] = reflect.ValueOf(&unicode.Lisu) 428 | vars["Lycian"] = reflect.ValueOf(&unicode.Lycian) 429 | vars["Lydian"] = reflect.ValueOf(&unicode.Lydian) 430 | vars["Mahajani"] = reflect.ValueOf(&unicode.Mahajani) 431 | vars["Malayalam"] = reflect.ValueOf(&unicode.Malayalam) 432 | vars["Mandaic"] = reflect.ValueOf(&unicode.Mandaic) 433 | vars["Manichaean"] = reflect.ValueOf(&unicode.Manichaean) 434 | vars["Meetei_Mayek"] = reflect.ValueOf(&unicode.Meetei_Mayek) 435 | vars["Mende_Kikakui"] = reflect.ValueOf(&unicode.Mende_Kikakui) 436 | vars["Meroitic_Cursive"] = reflect.ValueOf(&unicode.Meroitic_Cursive) 437 | vars["Meroitic_Hieroglyphs"] = reflect.ValueOf(&unicode.Meroitic_Hieroglyphs) 438 | vars["Miao"] = reflect.ValueOf(&unicode.Miao) 439 | vars["Modi"] = reflect.ValueOf(&unicode.Modi) 440 | vars["Mongolian"] = reflect.ValueOf(&unicode.Mongolian) 441 | vars["Mro"] = reflect.ValueOf(&unicode.Mro) 442 | vars["Myanmar"] = reflect.ValueOf(&unicode.Myanmar) 443 | vars["Nabataean"] = reflect.ValueOf(&unicode.Nabataean) 444 | vars["New_Tai_Lue"] = reflect.ValueOf(&unicode.New_Tai_Lue) 445 | vars["Nko"] = reflect.ValueOf(&unicode.Nko) 446 | vars["Ogham"] = reflect.ValueOf(&unicode.Ogham) 447 | vars["Ol_Chiki"] = reflect.ValueOf(&unicode.Ol_Chiki) 448 | vars["Old_Italic"] = reflect.ValueOf(&unicode.Old_Italic) 449 | vars["Old_North_Arabian"] = reflect.ValueOf(&unicode.Old_North_Arabian) 450 | vars["Old_Permic"] = reflect.ValueOf(&unicode.Old_Permic) 451 | vars["Old_Persian"] = reflect.ValueOf(&unicode.Old_Persian) 452 | vars["Old_South_Arabian"] = reflect.ValueOf(&unicode.Old_South_Arabian) 453 | vars["Old_Turkic"] = reflect.ValueOf(&unicode.Old_Turkic) 454 | vars["Oriya"] = reflect.ValueOf(&unicode.Oriya) 455 | vars["Osmanya"] = reflect.ValueOf(&unicode.Osmanya) 456 | vars["Pahawh_Hmong"] = reflect.ValueOf(&unicode.Pahawh_Hmong) 457 | vars["Palmyrene"] = reflect.ValueOf(&unicode.Palmyrene) 458 | vars["Pau_Cin_Hau"] = reflect.ValueOf(&unicode.Pau_Cin_Hau) 459 | vars["Phags_Pa"] = reflect.ValueOf(&unicode.Phags_Pa) 460 | vars["Phoenician"] = reflect.ValueOf(&unicode.Phoenician) 461 | vars["Psalter_Pahlavi"] = reflect.ValueOf(&unicode.Psalter_Pahlavi) 462 | vars["Rejang"] = reflect.ValueOf(&unicode.Rejang) 463 | vars["Runic"] = reflect.ValueOf(&unicode.Runic) 464 | vars["Samaritan"] = reflect.ValueOf(&unicode.Samaritan) 465 | vars["Saurashtra"] = reflect.ValueOf(&unicode.Saurashtra) 466 | vars["Sharada"] = reflect.ValueOf(&unicode.Sharada) 467 | vars["Shavian"] = reflect.ValueOf(&unicode.Shavian) 468 | vars["Siddham"] = reflect.ValueOf(&unicode.Siddham) 469 | vars["Sinhala"] = reflect.ValueOf(&unicode.Sinhala) 470 | vars["Sora_Sompeng"] = reflect.ValueOf(&unicode.Sora_Sompeng) 471 | vars["Sundanese"] = reflect.ValueOf(&unicode.Sundanese) 472 | vars["Syloti_Nagri"] = reflect.ValueOf(&unicode.Syloti_Nagri) 473 | vars["Syriac"] = reflect.ValueOf(&unicode.Syriac) 474 | vars["Tagalog"] = reflect.ValueOf(&unicode.Tagalog) 475 | vars["Tagbanwa"] = reflect.ValueOf(&unicode.Tagbanwa) 476 | vars["Tai_Le"] = reflect.ValueOf(&unicode.Tai_Le) 477 | vars["Tai_Tham"] = reflect.ValueOf(&unicode.Tai_Tham) 478 | vars["Tai_Viet"] = reflect.ValueOf(&unicode.Tai_Viet) 479 | vars["Takri"] = reflect.ValueOf(&unicode.Takri) 480 | vars["Tamil"] = reflect.ValueOf(&unicode.Tamil) 481 | vars["Telugu"] = reflect.ValueOf(&unicode.Telugu) 482 | vars["Thaana"] = reflect.ValueOf(&unicode.Thaana) 483 | vars["Thai"] = reflect.ValueOf(&unicode.Thai) 484 | vars["Tibetan"] = reflect.ValueOf(&unicode.Tibetan) 485 | vars["Tifinagh"] = reflect.ValueOf(&unicode.Tifinagh) 486 | vars["Tirhuta"] = reflect.ValueOf(&unicode.Tirhuta) 487 | vars["Ugaritic"] = reflect.ValueOf(&unicode.Ugaritic) 488 | vars["Vai"] = reflect.ValueOf(&unicode.Vai) 489 | vars["Warang_Citi"] = reflect.ValueOf(&unicode.Warang_Citi) 490 | vars["Yi"] = reflect.ValueOf(&unicode.Yi) 491 | vars["Properties"] = reflect.ValueOf(&unicode.Properties) 492 | vars["ASCII_Hex_Digit"] = reflect.ValueOf(&unicode.ASCII_Hex_Digit) 493 | vars["Bidi_Control"] = reflect.ValueOf(&unicode.Bidi_Control) 494 | vars["Dash"] = reflect.ValueOf(&unicode.Dash) 495 | vars["Deprecated"] = reflect.ValueOf(&unicode.Deprecated) 496 | vars["Diacritic"] = reflect.ValueOf(&unicode.Diacritic) 497 | vars["Extender"] = reflect.ValueOf(&unicode.Extender) 498 | vars["Hex_Digit"] = reflect.ValueOf(&unicode.Hex_Digit) 499 | vars["Hyphen"] = reflect.ValueOf(&unicode.Hyphen) 500 | vars["IDS_Binary_Operator"] = reflect.ValueOf(&unicode.IDS_Binary_Operator) 501 | vars["IDS_Trinary_Operator"] = reflect.ValueOf(&unicode.IDS_Trinary_Operator) 502 | vars["Ideographic"] = reflect.ValueOf(&unicode.Ideographic) 503 | vars["Join_Control"] = reflect.ValueOf(&unicode.Join_Control) 504 | vars["Logical_Order_Exception"] = reflect.ValueOf(&unicode.Logical_Order_Exception) 505 | vars["Noncharacter_Code_Point"] = reflect.ValueOf(&unicode.Noncharacter_Code_Point) 506 | vars["Other_Alphabetic"] = reflect.ValueOf(&unicode.Other_Alphabetic) 507 | vars["Other_Default_Ignorable_Code_Point"] = reflect.ValueOf(&unicode.Other_Default_Ignorable_Code_Point) 508 | vars["Other_Grapheme_Extend"] = reflect.ValueOf(&unicode.Other_Grapheme_Extend) 509 | vars["Other_ID_Continue"] = reflect.ValueOf(&unicode.Other_ID_Continue) 510 | vars["Other_ID_Start"] = reflect.ValueOf(&unicode.Other_ID_Start) 511 | vars["Other_Lowercase"] = reflect.ValueOf(&unicode.Other_Lowercase) 512 | vars["Other_Math"] = reflect.ValueOf(&unicode.Other_Math) 513 | vars["Other_Uppercase"] = reflect.ValueOf(&unicode.Other_Uppercase) 514 | vars["Pattern_Syntax"] = reflect.ValueOf(&unicode.Pattern_Syntax) 515 | vars["Pattern_White_Space"] = reflect.ValueOf(&unicode.Pattern_White_Space) 516 | vars["Quotation_Mark"] = reflect.ValueOf(&unicode.Quotation_Mark) 517 | vars["Radical"] = reflect.ValueOf(&unicode.Radical) 518 | vars["STerm"] = reflect.ValueOf(&unicode.STerm) 519 | vars["Soft_Dotted"] = reflect.ValueOf(&unicode.Soft_Dotted) 520 | vars["Terminal_Punctuation"] = reflect.ValueOf(&unicode.Terminal_Punctuation) 521 | vars["Unified_Ideograph"] = reflect.ValueOf(&unicode.Unified_Ideograph) 522 | vars["Variation_Selector"] = reflect.ValueOf(&unicode.Variation_Selector) 523 | vars["White_Space"] = reflect.ValueOf(&unicode.White_Space) 524 | vars["CaseRanges"] = reflect.ValueOf(&unicode.CaseRanges) 525 | vars["FoldCategory"] = reflect.ValueOf(&unicode.FoldCategory) 526 | vars["FoldScript"] = reflect.ValueOf(&unicode.FoldScript) 527 | pkgs["unicode"] = &eval.SimpleEnv { 528 | Consts: consts, 529 | Funcs: funcs, 530 | Types: types, 531 | Vars: vars, 532 | Pkgs: pkgs, 533 | } 534 | consts = make(map[string] reflect.Value) 535 | consts["RuneError"] = reflect.ValueOf(utf8.RuneError) 536 | consts["RuneSelf"] = reflect.ValueOf(utf8.RuneSelf) 537 | consts["MaxRune"] = reflect.ValueOf(utf8.MaxRune) 538 | consts["UTFMax"] = reflect.ValueOf(utf8.UTFMax) 539 | 540 | funcs = make(map[string] reflect.Value) 541 | funcs["FullRune"] = reflect.ValueOf(utf8.FullRune) 542 | funcs["FullRuneInString"] = reflect.ValueOf(utf8.FullRuneInString) 543 | funcs["DecodeRune"] = reflect.ValueOf(utf8.DecodeRune) 544 | funcs["DecodeRuneInString"] = reflect.ValueOf(utf8.DecodeRuneInString) 545 | funcs["DecodeLastRune"] = reflect.ValueOf(utf8.DecodeLastRune) 546 | funcs["DecodeLastRuneInString"] = reflect.ValueOf(utf8.DecodeLastRuneInString) 547 | funcs["RuneLen"] = reflect.ValueOf(utf8.RuneLen) 548 | funcs["EncodeRune"] = reflect.ValueOf(utf8.EncodeRune) 549 | funcs["RuneCount"] = reflect.ValueOf(utf8.RuneCount) 550 | funcs["RuneCountInString"] = reflect.ValueOf(utf8.RuneCountInString) 551 | funcs["RuneStart"] = reflect.ValueOf(utf8.RuneStart) 552 | funcs["Valid"] = reflect.ValueOf(utf8.Valid) 553 | funcs["ValidString"] = reflect.ValueOf(utf8.ValidString) 554 | funcs["ValidRune"] = reflect.ValueOf(utf8.ValidRune) 555 | 556 | types = make(map[string] reflect.Type) 557 | 558 | vars = make(map[string] reflect.Value) 559 | pkgs["utf8"] = &eval.SimpleEnv { 560 | Consts: consts, 561 | Funcs: funcs, 562 | Types: types, 563 | Vars: vars, 564 | Pkgs: pkgs, 565 | } 566 | 567 | mainEnv := eval.MakeSimpleEnv() 568 | mainEnv.Pkgs = pkgs 569 | return mainEnv 570 | } -------------------------------------------------------------------------------- /validate.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2014 Rocky Bernstein. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // command argument-validation routines 6 | 7 | package repl 8 | 9 | import "strconv" 10 | 11 | func ArgCountOK(min int, max int, args [] string) bool { 12 | l := len(args)-1 // strip command name from count 13 | if l < min { 14 | Errmsg("Too few args; need at least %d, got %d", min, l) 15 | return false 16 | } else if max > 0 && l > max { 17 | Errmsg("Too many args; need at most %d, got %d", max, l) 18 | return false 19 | } 20 | return true 21 | } 22 | 23 | type NumError struct { 24 | bogus bool 25 | } 26 | 27 | func (e *NumError) Error() string { 28 | return "generic error" 29 | } 30 | var genericError = &NumError{bogus: true} 31 | 32 | func GetInt(arg string, what string, min int, max int) (int, error) { 33 | errmsg_fmt := "Expecting integer " + what + "; got '%s'." 34 | i, err := strconv.Atoi(arg) 35 | if err != nil { 36 | Errmsg(errmsg_fmt, arg) 37 | return 0, err 38 | } 39 | if i < min { 40 | Errmsg("Expecting integer value %s to be at least %d; got %d.", 41 | what, min, i) 42 | return 0, genericError 43 | } else if max > 0 && i > max { 44 | Errmsg("Expecting integer value %s to be at most %d; got %d.", 45 | what, max, i) 46 | return 0, genericError 47 | } 48 | return i, nil 49 | } 50 | 51 | 52 | func GetUInt(arg string, what string, min uint64, max uint64) (uint64, error) { 53 | errmsg_fmt := "Expecting integer " + what + "; got '%s'." 54 | i, err := strconv.ParseUint(arg, 10, 0) 55 | if err != nil { 56 | Errmsg(errmsg_fmt, arg) 57 | return 0, err 58 | } 59 | if i < min { 60 | Errmsg("Expecting integer value %s to be at least %d; got %d.", 61 | what, min, i) 62 | return 0, genericError 63 | } else if max > 0 && i > max { 64 | Errmsg("Expecting integer value %s to be at most %d; got %d.", 65 | what, max, i) 66 | return 0, genericError 67 | } 68 | return i, nil 69 | } 70 | --------------------------------------------------------------------------------