experimental: remove return value of FunctionListener.Before (#1453)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
This commit is contained in:
@@ -556,7 +556,7 @@ func RunTestModuleEngineBeforeListenerStackIterator(t *testing.T, et EngineTeste
|
||||
}
|
||||
|
||||
fnListener := &fnListener{
|
||||
beforeFn: func(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, si experimental.StackIterator) context.Context {
|
||||
beforeFn: func(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, si experimental.StackIterator) {
|
||||
require.True(t, len(expectedCallstacks) > 0)
|
||||
expectedCallstack := expectedCallstacks[0]
|
||||
for si.Next() {
|
||||
@@ -567,7 +567,6 @@ func RunTestModuleEngineBeforeListenerStackIterator(t *testing.T, et EngineTeste
|
||||
}
|
||||
require.Equal(t, 0, len(expectedCallstack))
|
||||
expectedCallstacks = expectedCallstacks[1:]
|
||||
return ctx
|
||||
},
|
||||
}
|
||||
|
||||
@@ -693,7 +692,7 @@ func RunTestModuleEngineBeforeListenerGlobals(t *testing.T, et EngineTester) {
|
||||
}
|
||||
|
||||
fnListener := &fnListener{
|
||||
beforeFn: func(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, si experimental.StackIterator) context.Context {
|
||||
beforeFn: func(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, si experimental.StackIterator) {
|
||||
require.True(t, len(expectedGlobals) > 0)
|
||||
|
||||
imod := mod.(experimental.InternalModule)
|
||||
@@ -707,7 +706,6 @@ func RunTestModuleEngineBeforeListenerGlobals(t *testing.T, et EngineTester) {
|
||||
}
|
||||
|
||||
expectedGlobals = expectedGlobals[1:]
|
||||
return ctx
|
||||
},
|
||||
}
|
||||
|
||||
@@ -803,19 +801,19 @@ func RunTestModuleEngineBeforeListenerGlobals(t *testing.T, et EngineTester) {
|
||||
}
|
||||
|
||||
type fnListener struct {
|
||||
beforeFn func(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, stackIterator experimental.StackIterator) context.Context
|
||||
afterFn func(ctx context.Context, mod api.Module, def api.FunctionDefinition, results []uint64)
|
||||
beforeFn func(context.Context, api.Module, api.FunctionDefinition, []uint64, experimental.StackIterator)
|
||||
afterFn func(context.Context, api.Module, api.FunctionDefinition, []uint64)
|
||||
abortFn func(context.Context, api.Module, api.FunctionDefinition, any)
|
||||
}
|
||||
|
||||
func (f *fnListener) NewFunctionListener(api.FunctionDefinition) experimental.FunctionListener {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *fnListener) Before(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, stackIterator experimental.StackIterator) context.Context {
|
||||
func (f *fnListener) Before(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, stackIterator experimental.StackIterator) {
|
||||
if f.beforeFn != nil {
|
||||
return f.beforeFn(ctx, mod, def, params, stackIterator)
|
||||
f.beforeFn(ctx, mod, def, params, stackIterator)
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
func (f *fnListener) After(ctx context.Context, mod api.Module, def api.FunctionDefinition, results []uint64) {
|
||||
@@ -824,6 +822,12 @@ func (f *fnListener) After(ctx context.Context, mod api.Module, def api.Function
|
||||
}
|
||||
}
|
||||
|
||||
func (f *fnListener) Abort(ctx context.Context, mod api.Module, def api.FunctionDefinition, err error) {
|
||||
if f.abortFn != nil {
|
||||
f.abortFn(ctx, mod, def, err)
|
||||
}
|
||||
}
|
||||
|
||||
func RunTestModuleEngineStackIteratorOffset(t *testing.T, et EngineTester) {
|
||||
e := et.NewEngine(api.CoreFeaturesV2)
|
||||
|
||||
@@ -835,7 +839,7 @@ func RunTestModuleEngineStackIteratorOffset(t *testing.T, et EngineTester) {
|
||||
var tape [][]frame
|
||||
|
||||
fnListener := &fnListener{
|
||||
beforeFn: func(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, si experimental.StackIterator) context.Context {
|
||||
beforeFn: func(ctx context.Context, mod api.Module, def api.FunctionDefinition, params []uint64, si experimental.StackIterator) {
|
||||
var stack []frame
|
||||
for si.Next() {
|
||||
fn := si.Function()
|
||||
@@ -843,7 +847,6 @@ func RunTestModuleEngineStackIteratorOffset(t *testing.T, et EngineTester) {
|
||||
stack = append(stack, frame{fn.Definition(), fn.SourceOffsetForPC(pc)})
|
||||
}
|
||||
tape = append(tape, stack)
|
||||
return ctx
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user