cfg: fix range exit
This commit is contained in:
6
gi.go
6
gi.go
@@ -73,12 +73,14 @@ func main() {
|
||||
*/
|
||||
}
|
||||
|
||||
// Plugin struct stores metadata for external modules
|
||||
type Plugin struct {
|
||||
Pkgname, Typename string
|
||||
Id int
|
||||
ID int
|
||||
Syms *interp.SymMap
|
||||
}
|
||||
|
||||
// Handler redirect http.Handler processing in the interpreter
|
||||
func (p *Plugin) Handler(w http.ResponseWriter, r *http.Request) {
|
||||
(*p.Syms)["WrapHandler"].(func(int, http.ResponseWriter, *http.Request))(p.Id, w, r)
|
||||
(*p.Syms)["WrapHandler"].(func(int, http.ResponseWriter, *http.Request))(p.ID, w, r)
|
||||
}
|
||||
|
||||
@@ -508,6 +508,7 @@ func (interp *Interpreter) Cfg(root *Node, sdef *NodeMap) []*Node {
|
||||
loop, loopRestart = nil, nil
|
||||
n.start = n.child[0].start
|
||||
n.findex = n.child[0].findex
|
||||
n.child[0].fnext = n
|
||||
scope = scope.anc
|
||||
|
||||
case FuncDecl:
|
||||
|
||||
@@ -58,7 +58,7 @@ func (n *Node) CfgDot(out io.WriteCloser) {
|
||||
fmt.Fprintf(out, "}\n")
|
||||
}
|
||||
|
||||
// Dotty returns an output stream to a dotty(1) co-process where to write data in .dot format
|
||||
// DotX returns an output stream to a dot(1) co-process where to write data in .dot format
|
||||
func DotX() io.WriteCloser {
|
||||
//cmd := exec.Command("dotty", "-")
|
||||
cmd := exec.Command("dot", "-T", "xlib")
|
||||
|
||||
@@ -58,6 +58,28 @@ func main() {
|
||||
// test
|
||||
}
|
||||
|
||||
func Example_a11() {
|
||||
src := `
|
||||
package main
|
||||
|
||||
func main() {
|
||||
a := []int{1, 2, 3, 4}
|
||||
for _, v := range a {
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
`
|
||||
i := NewInterpreter(Opt{Entry: "main"})
|
||||
i.ImportBin(export.Pkg)
|
||||
i.Eval(src)
|
||||
|
||||
// Output:
|
||||
// 1
|
||||
// 2
|
||||
// 3
|
||||
// 4
|
||||
}
|
||||
|
||||
func Example_a2() {
|
||||
src := `
|
||||
package main
|
||||
@@ -278,12 +300,15 @@ package main
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(true)
|
||||
}`
|
||||
fmt.Println(false, true)
|
||||
}
|
||||
`
|
||||
i := NewInterpreter(Opt{Entry: "main"})
|
||||
i.ImportBin(export.Pkg)
|
||||
i.Eval(src)
|
||||
|
||||
// Output:
|
||||
// false true
|
||||
}
|
||||
|
||||
func Example_chan0() {
|
||||
|
||||
14
test/a11.go
Normal file
14
test/a11.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
a := []int{1, 2, 3, 4}
|
||||
for _, v := range a {
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
|
||||
// Output:
|
||||
// 1
|
||||
// 2
|
||||
// 3
|
||||
// 4
|
||||
Reference in New Issue
Block a user