package yaegi

import (
	
	
	
	

	
	

	amsym 
	yhost 
	am 
)

// Exec executes the given code in a yaegi VM. The [host] is passed as `host.H`,
// and [symbols] allow for custom imports. IO streams are optional and default
// to STD.
func [ any](
	 am.Api,  fstest.MapFS,  ,  interp.Exports,
	,  io.Writer,
) (*yhost.Ret, error) {
	// TODO handler errs

	 := interp.Options{
		SourcecodeFilesystem: ,
		GoPath:               "./_pkg",
	}
	if  != nil {
		.Stdout = 
	}
	if  != nil {
		.Stderr = 
	}

	// init base VM
	 := interp.New()
	if  := .Use(stdlib.Symbols);  != nil {
		return nil, 
	}

	// load local symbols
	if  := .Use(amsym.Symbols);  != nil {
		return nil, 
	}

	// load user symbols
	if len() > 0 {
		if  := .Use();  != nil {
			return nil, 
		}
	}
	 := .Use(interp.Exports{
		"host/host": map[string]reflect.Value{
			"H":   reflect.ValueOf(),
			"Ret": reflect.ValueOf((*yhost.Ret)(nil)),
		},
	})
	if  != nil {
		return nil, 
	}

	_,  = .EvalPath(`interpreted.go`)
	if  != nil {
		return nil, 
	}
	,  := .Eval("vfs.Run()")
	if  != nil {
		return nil, 
	}

	,  := .Interface().(*yhost.Ret)
	if ! {
		 = fmt.Errorf("expected *host.Ret, got %T", .Interface())
	}

	return , 
}