public BreakPointSetter(DebuggerWindow debuggerWindow)
        {
            _debuggerWindow = debuggerWindow;

            foreach (var item in _debuggerWindow.BreakPointMap)
            {
                foreach (var line in item.Value)
                {
                    listBox1.Items.Add(new BreakPoint
                    {
                        Source = item.Key,
                        Line = line
                    });
                }
            }

            InitializeComponent();
        }
 public MessageHandler(DebuggerWindow window)
 {
     _window = window;
 }
        public void Init()
        {
            WebRequest.RegisterPrefix("gspack", new GSPackRequestCreate());

            ReadConfig();
            // TODO: Edit config
            SaveConfig();

            SquirrelHelper.RegisterGlobalFunction("DebugHook", vm =>
            {
                int type;
                string srcname;
                int line;
                string funcname;
                SquirrelFunctions.getinteger(vm, 2, out type);
                SquirrelFunctions.getstring(vm, 3, out srcname);
                SquirrelFunctions.getinteger(vm, 4, out line);
                SquirrelFunctions.getstring(vm, 5, out funcname);

                foreach (var handler in _messageHandlers)
                {
                    handler.DebugInfomationArrived(type, srcname, line, funcname);
                }

                return 0;
            });

            SquirrelHelper.RegisterGlobalFunction("ErrorHandler", vm =>
            {
                SquirrelFunctions.tostring(vm, 2);
                string exceptionDescription;
                SquirrelFunctions.getstring(vm, -1, out exceptionDescription);
                SquirrelFunctions.poptop(vm);

                foreach (var handler in _messageHandlers)
                {
                    handler.RuntimeExceptionArrived(exceptionDescription);
                }

                return 0;
            });

            SquirrelHelper.Run(vm =>
            {
                SquirrelFunctions.enabledebuginfo(vm, 1);

                SquirrelHelper.RegisterGlobalFunction("RegisterFinalizable", sqvm =>
                {
                    SquirrelFunctions.SQObject obj;
                    SquirrelFunctions.getstackobj(sqvm, -1, out obj);
                    SquirrelFunctions.setreleasehook(sqvm, -1, Marshal.GetFunctionPointerForDelegate((ReleaseHook)(
                            (userdata, size) =>
                            {
                                SquirrelFunctions.pushobject(sqvm, obj);
                                SquirrelFunctions.pushstring(sqvm, "Finalize", -1);
                                SquirrelFunctions.get(sqvm, -2);
                                SquirrelFunctions.pushobject(sqvm, obj);
                                SquirrelFunctions.call(sqvm, 1, 0, 0);
                                SquirrelFunctions.pop(sqvm, 2);

                                return 0;
                            })));

                    return 0;
                });

                var CreateIFinalizable = SquirrelHelper.CompileScriptFunction(
                  @"class IFinalizable
                    {
                        constructor() { RegisterFinalizable(this); }
                        function Finalize() {}
                        function _inherited(attributes) {}
                    }", "CreateIFinalizable");
                SquirrelFunctions.pushobject(vm, CreateIFinalizable);
                SquirrelFunctions.pushroottable(vm);
                SquirrelFunctions.call(vm, 1, 0, 0);
                SquirrelFunctions.pop(vm, 1);

                SquirrelHelper.InjectCompileFileMain("data/script/boot.nut").AddBefore(sqvm =>
                {
                    SquirrelFunctions.pushroottable(vm);
                    SquirrelFunctions.pushstring(vm, "DebugHook", -1);
                    SquirrelFunctions.get(vm, -2);
                    SquirrelFunctions.setdebughook(vm);
                    SquirrelFunctions.pushstring(vm, "ErrorHandler", -1);
                    SquirrelFunctions.get(vm, -2);
                    SquirrelFunctions.seterrorhandler(vm);
                    SquirrelFunctions.poptop(vm);

                    var compilerErrorHandler =
                        Marshal.GetFunctionPointerForDelegate(
                            (CompilerErrorHandler) ((sqvm1, desc, src, line, column) =>
                            {
                                foreach (var handler in _messageHandlers)
                                {
                                    handler.CompilerExceptionArrived(desc, src, line, column);
                                }
                            }));

                    SquirrelFunctions.setcompilererrorhandler(vm, compilerErrorHandler);
                });
            });

            WindowsHelper.Run(() =>
            {
                _window = new DebuggerWindow(this);
                _window.Show();
            });
        }