added the debug variable for easy toggling of debug messages
This commit is contained in:
parent
fab6ab5595
commit
1945452429
@ -5,6 +5,8 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var debug bool = false
|
||||||
|
|
||||||
var err_num_args *error_t = &error_t{msg: "wrong number of arguments"}
|
var err_num_args *error_t = &error_t{msg: "wrong number of arguments"}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -154,6 +156,26 @@ func (interp *Interp) dump_vstack(p *process_t) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
[STMT]
|
||||||
|
[TEXT] [DQUOTE] [TEXT]
|
||||||
|
|
||||||
|
[STMT]
|
||||||
|
[BRACKET] [TEXT]
|
||||||
|
[STMT]
|
||||||
|
[TEXT] [TEXT] [TEXT]
|
||||||
|
[STMT]
|
||||||
|
[TEXT] [TEXT]
|
||||||
|
|
||||||
|
"pu[null 1]ts" 10 20
|
||||||
|
|
||||||
|
[STMT]
|
||||||
|
[DQUOTE] [TEXT|10] [TEXT|20]
|
||||||
|
[TEXT|pu] [BRACKET] [JOIN] [TEXT|ts] [JOIN]
|
||||||
|
[STMT]
|
||||||
|
[TEXT|null] [TEXT|1]
|
||||||
|
*/
|
||||||
func (interp *Interp) eval_stmt_nodes(container_node *Cnode_t) (*string, error) {
|
func (interp *Interp) eval_stmt_nodes(container_node *Cnode_t) (*string, error) {
|
||||||
var (
|
var (
|
||||||
p process_t
|
p process_t
|
||||||
@ -193,9 +215,11 @@ func (interp *Interp) eval_stmt_nodes(container_node *Cnode_t) (*string, error)
|
|||||||
stmt_node = inner_node.child // first statement inside []
|
stmt_node = inner_node.child // first statement inside []
|
||||||
p.push_context(stmt_node, inner_node)
|
p.push_context(stmt_node, inner_node)
|
||||||
p.push_string_value("") // for return value
|
p.push_string_value("") // for return value
|
||||||
|
if debug {
|
||||||
fmt.Printf("going to start over\n")
|
fmt.Printf("going to start over\n")
|
||||||
interp.dump_cnodes(stmt_node, true)
|
interp.dump_cnodes(stmt_node, true)
|
||||||
fmt.Printf("\n--\n")
|
fmt.Printf("\n--\n")
|
||||||
|
}
|
||||||
goto start_over
|
goto start_over
|
||||||
} else {
|
} else {
|
||||||
// no statements inside []. treat it like an empty string
|
// no statements inside []. treat it like an empty string
|
||||||
@ -207,9 +231,11 @@ func (interp *Interp) eval_stmt_nodes(container_node *Cnode_t) (*string, error)
|
|||||||
p.push_context(stmt_node, inner_node)
|
p.push_context(stmt_node, inner_node)
|
||||||
//p.push_string_value("") // no placeholder for return value is needed
|
//p.push_string_value("") // no placeholder for return value is needed
|
||||||
inner_node = inner_node.child
|
inner_node = inner_node.child
|
||||||
|
if debug {
|
||||||
fmt.Printf("going to start over\n")
|
fmt.Printf("going to start over\n")
|
||||||
interp.dump_cnodes(stmt_node, true)
|
interp.dump_cnodes(stmt_node, true)
|
||||||
fmt.Printf("\n--\n")
|
fmt.Printf("\n--\n")
|
||||||
|
}
|
||||||
goto resume
|
goto resume
|
||||||
} else {
|
} else {
|
||||||
// no statements inside []. treat it like an empty string
|
// no statements inside []. treat it like an empty string
|
||||||
@ -236,11 +262,15 @@ func (interp *Interp) eval_stmt_nodes(container_node *Cnode_t) (*string, error)
|
|||||||
inner_node = inner_node.next
|
inner_node = inner_node.next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if debug {
|
||||||
interp.dump_vstack(&p)
|
interp.dump_vstack(&p)
|
||||||
|
}
|
||||||
//fmt.Printf("p.ctx.parent_node.code %d p.ctx.container_node.code %d CNODE_STMT %d CNODE_DQUOTE %d\n", p.ctx.parent_node.code, p.ctx.container_node.code, CNODE_STMT, CNODE_DQUOTE)
|
//fmt.Printf("p.ctx.parent_node.code %d p.ctx.container_node.code %d CNODE_STMT %d CNODE_DQUOTE %d\n", p.ctx.parent_node.code, p.ctx.container_node.code, CNODE_STMT, CNODE_DQUOTE)
|
||||||
//if p.ctx.parent_node.code == CNODE_STMT {
|
//if p.ctx.parent_node.code == CNODE_STMT {
|
||||||
if p.ctx.container_node == nil || (p.ctx.container_node.code == CNODE_STMT || p.ctx.container_node.code == CNODE_BRACKET) {
|
if p.ctx.container_node == nil || (p.ctx.container_node.code == CNODE_STMT || p.ctx.container_node.code == CNODE_BRACKET) {
|
||||||
|
if debug {
|
||||||
fmt.Printf("calling..... [%s]\n", *p.GetCalleeName())
|
fmt.Printf("calling..... [%s]\n", *p.GetCalleeName())
|
||||||
|
}
|
||||||
err = p.call()
|
err = p.call()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
goto oops
|
goto oops
|
||||||
@ -248,13 +278,13 @@ func (interp *Interp) eval_stmt_nodes(container_node *Cnode_t) (*string, error)
|
|||||||
|
|
||||||
stmt_node, inner_node = p.pop_context(true)
|
stmt_node, inner_node = p.pop_context(true)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// join the all
|
|
||||||
stmt_node, inner_node = p.pop_context(false)
|
stmt_node, inner_node = p.pop_context(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if inner_node != nil {
|
if inner_node != nil {
|
||||||
|
if debug {
|
||||||
fmt.Printf("resuming... %d\n", p.vsp)
|
fmt.Printf("resuming... %d\n", p.vsp)
|
||||||
|
}
|
||||||
inner_node = inner_node.next
|
inner_node = inner_node.next
|
||||||
goto resume
|
goto resume
|
||||||
}
|
}
|
||||||
@ -263,8 +293,10 @@ func (interp *Interp) eval_stmt_nodes(container_node *Cnode_t) (*string, error)
|
|||||||
stmt_node = stmt_node.next
|
stmt_node = stmt_node.next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if debug {
|
||||||
interp.dump_vstack(&p)
|
interp.dump_vstack(&p)
|
||||||
fmt.Printf("END p.sp = %d\n", p.vsp)
|
fmt.Printf("END p.sp = %d\n", p.vsp)
|
||||||
|
}
|
||||||
return v, nil
|
return v, nil
|
||||||
|
|
||||||
oops:
|
oops:
|
||||||
|
Loading…
Reference in New Issue
Block a user