/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


#ifndef	__SCRIPT_VM_DEBUG_PROFILE_EVENT_HANDLER__
#define	__SCRIPT_VM_DEBUG_PROFILE_EVENT_HANDLER__


		#include "script/script_vm.h"
		#include "script/script_debugger.h"
		#include "memory/nauto_ptr.h"


namespace GS {
	namespace Script {

/*!
	@short	Debugger/profiling VM event handler.

	This handler provides basic functionality such as VM stepping and profiling.
	This class should be further derived to implement complete control over the VM.

	@author Emmanuel Julien (ejulien@owloh.com)
*/
class	IDebuggerProfiler : public IVM::IDebug
{
static	String		ConvertCallStackToMetaString(const AutoList <IVM::CallStackEntry *> &, int stack_frame_index);

protected:

		sVM			vm;

public:

		AutoPtr <IDebugger> debugger;

		String		GetCallstack();
		String		GetDebugStackFrameLocals();

		void		Kill();

		// Debugger interface.
virtual	void		OnSuspendExecution(const char *source, int line) = 0;
virtual	bool		OnUpdateSuspendedExecution() = 0;

		// VM interface implementation.
		void		OnStep(char type, const char *source, int line, const char *func);

		IDebuggerProfiler(IVM *vm, IDebugger *debugger);
};

	} // Script
} // GS


#endif	// __SCRIPT_VM_DEBUG_PROFILE_EVENT_HANDLER__
