@@ -725,7 +725,10 @@ func ensureBlock(block Value, name string) error {
725725 return nil
726726}
727727
728- func (exec * Execution ) callBlock (block Value , args []Value ) (Value , error ) {
728+ // CallBlock invokes a block value with the provided arguments.
729+ // This is the public entry point for capability adapters that need to
730+ // call user-supplied blocks (e.g. db.each, db.tx).
731+ func (exec * Execution ) CallBlock (block Value , args []Value ) (Value , error ) {
729732 if err := ensureBlock (block , "" ); err != nil {
730733 return NewNil (), err
731734 }
@@ -763,7 +766,7 @@ func (exec *Execution) evalYield(expr *YieldExpr, env *Env) (Value, error) {
763766 }
764767 args = append (args , val )
765768 }
766- return exec .callBlock (block , args )
769+ return exec .CallBlock (block , args )
767770}
768771
769772func (exec * Execution ) evalRangeExpr (expr * RangeExpr , env * Env ) (Value , error ) {
@@ -927,7 +930,7 @@ func (exec *Execution) getMember(obj Value, property string, pos Position) (Valu
927930 return NewNil (), fmt .Errorf ("int.times value too large" )
928931 }
929932 for i := range int (count ) {
930- if _ , err := exec .callBlock (block , []Value {NewInt (int64 (i ))}); err != nil {
933+ if _ , err := exec .CallBlock (block , []Value {NewInt (int64 (i ))}); err != nil {
931934 return NewNil (), err
932935 }
933936 }
@@ -1182,7 +1185,7 @@ func arrayMember(array Value, property string) (Value, error) {
11821185 return NewNil (), err
11831186 }
11841187 for _ , item := range receiver .Array () {
1185- if _ , err := exec .callBlock (block , []Value {item }); err != nil {
1188+ if _ , err := exec .CallBlock (block , []Value {item }); err != nil {
11861189 return NewNil (), err
11871190 }
11881191 }
@@ -1196,7 +1199,7 @@ func arrayMember(array Value, property string) (Value, error) {
11961199 arr := receiver .Array ()
11971200 result := make ([]Value , len (arr ))
11981201 for i , item := range arr {
1199- val , err := exec .callBlock (block , []Value {item })
1202+ val , err := exec .CallBlock (block , []Value {item })
12001203 if err != nil {
12011204 return NewNil (), err
12021205 }
@@ -1212,7 +1215,7 @@ func arrayMember(array Value, property string) (Value, error) {
12121215 arr := receiver .Array ()
12131216 out := make ([]Value , 0 , len (arr ))
12141217 for _ , item := range arr {
1215- val , err := exec .callBlock (block , []Value {item })
1218+ val , err := exec .CallBlock (block , []Value {item })
12161219 if err != nil {
12171220 return NewNil (), err
12181221 }
@@ -1243,7 +1246,7 @@ func arrayMember(array Value, property string) (Value, error) {
12431246 start = 1
12441247 }
12451248 for i := start ; i < len (arr ); i ++ {
1246- next , err := exec .callBlock (block , []Value {acc , arr [i ]})
1249+ next , err := exec .CallBlock (block , []Value {acc , arr [i ]})
12471250 if err != nil {
12481251 return NewNil (), err
12491252 }
0 commit comments