Call closure generation after all CFGs are processed
This commit is contained in:
@@ -10,7 +10,7 @@ func F1() {
|
||||
fmt.Println("SomeString:", SomeString)
|
||||
}
|
||||
|
||||
//func F2() {
|
||||
//var buf [SomeInt]byte
|
||||
//fmt.Println("buf:", buf)
|
||||
//}
|
||||
func F2() {
|
||||
var buf [SomeInt]byte
|
||||
fmt.Println("buf:", buf)
|
||||
}
|
||||
|
||||
@@ -675,7 +675,6 @@ func (interp *Interpreter) Cfg(root *Node) []*Node {
|
||||
} else if sym, level, ok := scope.lookup(n.ident); ok {
|
||||
n.typ, n.findex, n.level = sym.typ, sym.index, level
|
||||
if n.findex < 0 {
|
||||
//log.Println(n.index, n.ident, sym.node.index, sym.node.kind)
|
||||
n.val = sym.node
|
||||
n.kind = sym.node.kind
|
||||
} else {
|
||||
@@ -935,7 +934,11 @@ func (interp *Interpreter) Cfg(root *Node) []*Node {
|
||||
return true
|
||||
}, nil)
|
||||
|
||||
root.Walk(func(n *Node) bool {
|
||||
return initNodes
|
||||
}
|
||||
|
||||
func genRun(n *Node) {
|
||||
n.Walk(func(n *Node) bool {
|
||||
if n.kind == FuncType && len(n.anc.child) == 4 {
|
||||
getExec(n.anc.child[3].start)
|
||||
}
|
||||
@@ -945,8 +948,6 @@ func (interp *Interpreter) Cfg(root *Node) []*Node {
|
||||
}
|
||||
return true
|
||||
}, nil)
|
||||
|
||||
return initNodes
|
||||
}
|
||||
|
||||
// Find default case clause index of a switch statement, if any
|
||||
|
||||
@@ -179,6 +179,7 @@ func (i *Interpreter) Eval(src string) string {
|
||||
|
||||
// Execute CFG
|
||||
if !i.NoRun {
|
||||
genRun(root)
|
||||
i.fsize++
|
||||
i.resizeFrame()
|
||||
runCfg(root.start, i.Frame)
|
||||
|
||||
@@ -57,6 +57,7 @@ func (interp *Interpreter) importSrcFile(path string) {
|
||||
|
||||
// Once all package sources have been parsed, execute entry points then init functions
|
||||
for _, n := range rootNodes {
|
||||
genRun(n)
|
||||
interp.fsize++
|
||||
interp.resizeFrame()
|
||||
runCfg(n.start, interp.Frame)
|
||||
|
||||
@@ -289,7 +289,7 @@ func (t *Type) zero() interface{} {
|
||||
t = nodeType(t.node.interp, t.scope, t.node)
|
||||
t.node.typ = t
|
||||
if t.incomplete {
|
||||
log.Panic("incomplete type")
|
||||
log.Panicln("incomplete type", t.node.index)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user