void * norls_allocator::nraAlloc(size_t sz) { void * block; assert(sz != 0 && (sz & (sizeof(int) - 1)) == 0); #ifdef _WIN64 //Ensure that we always allocate in pointer sized increments. /* TODO-Cleanup: * This is wasteful. We should add alignment requirements to the allocations so we don't waste space in * the heap. */ sz = (unsigned)roundUp(sz, sizeof(size_t)); #endif #ifdef DEBUG if (nraShouldInjectFault) { // Force the underlying memory allocator (either the OS or the CLR hoster) // to allocate the memory. Any fault injection will kick in. void * p = DbgNew(1); if (p) { DbgDelete(p); } else { NOMEM(); // Throw! } } #endif block = nraFreeNext; nraFreeNext += sz; if ((size_t)block == blockStop) debugStop("Block at %08X allocated", block); if (nraFreeNext > nraFreeLast) block = nraAllocNewPage(sz); #ifdef DEBUG memset(block, UninitializedWord<char>(), sz); #endif return block; }
void Runtime::debugStart(TextEditInput *editWidget, const char *file) { char buf[OS_PATHNAME_SIZE + 1]; bool open; int size; if (g_debugee != -1) { net_print(g_debugee, "l\n"); open = net_input(g_debugee, buf, sizeof(buf), "\n") > 0; } else { open = false; } if (!open) { launchDebug(file); pause(PAUSE_DEBUG_LAUNCH); SDL_RaiseWindow(_window); g_debugee = net_connect("localhost", g_debugPort); if (g_debugee != -1) { net_print(g_debugee, "l\n"); size = net_input(g_debugee, buf, sizeof(buf), "\n"); if (size > 0) { int *marker = editWidget->getMarkers(); for (int i = 0; i < MAX_MARKERS; i++) { if (marker[i] != -1) { net_printf(g_debugee, "b %d\n", marker[i]); } } editWidget->gotoLine(buf); appLog("Debug session ready"); } } else { appLog("Failed to attach to debug window"); } } else { debugStop(); } }
Data DebugSession::debugPrepare(const Data& data) { Data replyData; if (!data.hasKey("xml") && !data.hasKey("url")) { replyData.compound["status"] = Data("failure", Data::VERBATIM); replyData.compound["reason"] = Data("No XML or URL given", Data::VERBATIM); return replyData; } debugStop(data); _isAttached = false; try { if (data.hasKey("xml")) { _interpreter = Interpreter::fromXML(data.at("xml").atom, (data.hasKey("url") ? data.at("url").atom : "")); } else if (data.hasKey("url")) { _interpreter = Interpreter::fromURL(data.at("url").atom); } else { _interpreter = Interpreter(); } } catch(ErrorEvent e) { std::cerr << e; } catch(...) {} if (_interpreter) { // register ourself as a monitor _interpreter.addMonitor(_debugger); _debugger->attachSession(_interpreter.getImpl().get(), shared_from_this()); replyData.compound["status"] = Data("success", Data::VERBATIM); } else { replyData.compound["status"] = Data("failure", Data::VERBATIM); } return replyData; }
void DGLMainWindow::closeEvent(QCloseEvent *_event) { if (!closeProject()) { _event->ignore(); return; } debugStop(); // store QSettings QSettings settings(DGL_MANUFACTURER, DGL_PRODUCT); settings.setValue(DGL_GEOMETRY_SETTINGS, saveGeometry()); settings.setValue(DGL_WINDOW_STATE_SETTINGS, saveState()); settings.setValue(DGL_ColorScheme_SETTINGS, m_ColorScheme); settings.setValue( DGL_ADB_PATH_SETTINGS, QString::fromStdString(DGLAdbInterface::get()->getAdbPath()) .toUtf8()); // Send event to parent class _event->accept(); }
void DGLMainWindow::createActions() { // create "QActions" - bindings between mainwindow clickable widgets, // and // local slots quitAct = new QAction(tr("&Quit"), this); quitAct->setShortcuts(QKeySequence::Quit); quitAct->setStatusTip(tr("Quit the application")); CONNASSERT(quitAct, SIGNAL(triggered()), this, SLOT(close())); quitAct->setShortcut(QKeySequence(Qt::ALT + Qt::Key_F4)); aboutAct = new QAction(tr("&About"), this); aboutAct->setStatusTip(tr("Show the application's About box")); CONNASSERT(aboutAct, SIGNAL(triggered()), this, SLOT(about())); aboutAct->setShortcut(QKeySequence(Qt::Key_F1)); newProjectAct = new QAction(tr("&New Project..."), this); newProjectAct->setStatusTip(tr("Created new debugging project")); CONNASSERT(newProjectAct, SIGNAL(triggered()), this, SLOT(newProject())); newProjectAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N)); openProjectAct = new QAction(tr("&Open Project..."), this); openProjectAct->setStatusTip(tr("Opens a debugging project")); CONNASSERT(openProjectAct, SIGNAL(triggered()), this, SLOT(openProject())); //TODO: implement openProjectAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O)); saveProjectAct = new QAction(tr("&Save Project"), this); saveProjectAct->setStatusTip(tr("Save a debugging project")); CONNASSERT(saveProjectAct, SIGNAL(triggered()), this, SLOT(saveProject())); //TODO: implement saveProjectAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); saveAsProjectAct = new QAction(tr("&Save Project As ..."), this); saveAsProjectAct->setStatusTip(tr("Save a debugging project as as a file ...")); CONNASSERT(saveAsProjectAct, SIGNAL(triggered()), this, SLOT(saveProjectAs())); //TODO: implement saveAsProjectAct->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_S)); projectProperiesAct = new QAction(tr("&Project properties..."), this); projectProperiesAct->setStatusTip(tr("Change properties of current project")); CONNASSERT(projectProperiesAct, SIGNAL(triggered()), this, SLOT(projectProperties())); closeProjectAct = new QAction(tr("&Close project"), this); closeProjectAct->setStatusTip(tr("Created new debugging project")); CONNASSERT(closeProjectAct, SIGNAL(triggered()), this, SLOT(closeProject())); debugStartAct = new QAction(tr("&Start debugging"), this); debugStartAct->setStatusTip(tr("Stop debugging.")); CONNASSERT(debugStartAct, SIGNAL(triggered()), this, SLOT(debugStart())); CONNASSERT(&m_controller, SIGNAL(setDisconnected(bool)), debugStartAct, SLOT(setVisible(bool))); debugStartAct->setShortcut(QKeySequence(Qt::Key_F5)); debugStopAct = new QAction(tr("Sto&p debugging"), this); debugStopAct->setStatusTip(tr("Stop debugging.")); CONNASSERT(debugStopAct, SIGNAL(triggered()), this, SLOT(debugStop())); CONNASSERT(&m_controller, SIGNAL(setConnected(bool)), debugStopAct, SLOT(setEnabled(bool))); debugStopAct->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F5)); debugStopAct->setEnabled(false); debugTerminateAct = new QAction(tr("Terminate"), this); debugTerminateAct->setStatusTip(tr("Terminate debugged process.")); CONNASSERT(debugTerminateAct, SIGNAL(triggered()), this, SLOT(debugTerminate())); CONNASSERT(&m_controller, SIGNAL(setConnected(bool)), debugTerminateAct, SLOT(setEnabled(bool))); debugTerminateAct->setEnabled(false); debugContinueAct = new QAction(tr("&Continue"), this); debugContinueAct->setStatusTip(tr("Continue program execution")); CONNASSERT(debugContinueAct, SIGNAL(triggered()), &m_controller, SLOT(debugContinue())); CONNASSERT(&m_controller, SIGNAL(setConnected(bool)), debugContinueAct, SLOT(setVisible(bool))); CONNASSERT(&m_controller, SIGNAL(setBreaked(bool)), debugContinueAct, SLOT(setEnabled(bool))); debugContinueAct->setShortcut(QKeySequence(Qt::Key_F5)); debugContinueAct->setVisible(false); debugInterruptAct = new QAction(tr("&Break on next call"), this); debugInterruptAct->setStatusTip( tr("Break program execution on GL call")); CONNASSERT(debugInterruptAct, SIGNAL(triggered()), &m_controller, SLOT(debugInterrupt())); CONNASSERT(&m_controller, SIGNAL(setConnected(bool)), debugInterruptAct, SLOT(setEnabled(bool))); CONNASSERT(&m_controller, SIGNAL(setRunning(bool)), debugInterruptAct, SLOT(setEnabled(bool))); debugInterruptAct->setShortcut(QKeySequence(Qt::Key_F6)); debugInterruptAct->setEnabled(false); debugStepAct = new QAction(tr("&Step"), this); debugStepAct->setStatusTip(tr("Step one GL call")); CONNASSERT(debugStepAct, SIGNAL(triggered()), &m_controller, SLOT(debugStep())); CONNASSERT(&m_controller, SIGNAL(setConnected(bool)), debugStepAct, SLOT(setEnabled(bool))); CONNASSERT(&m_controller, SIGNAL(setBreaked(bool)), debugStepAct, SLOT(setEnabled(bool))); debugStepAct->setShortcut(QKeySequence(Qt::Key_F11)); debugStepAct->setEnabled(false); debugStepDrawCallAct = new QAction(tr("&Draw step"), this); debugStepDrawCallAct->setStatusTip(tr("Step one GL drawing call")); CONNASSERT(debugStepDrawCallAct, SIGNAL(triggered()), &m_controller, SLOT(debugStepDrawCall())); CONNASSERT(&m_controller, SIGNAL(setConnected(bool)), debugStepDrawCallAct, SLOT(setEnabled(bool))); CONNASSERT(&m_controller, SIGNAL(setBreaked(bool)), debugStepDrawCallAct, SLOT(setEnabled(bool))); debugStepDrawCallAct->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F11)); debugStepDrawCallAct->setEnabled(false); debugStepFrameAct = new QAction(tr("&Frame step"), this); debugStepFrameAct->setStatusTip(tr("Step one GL frame")); CONNASSERT(debugStepFrameAct, SIGNAL(triggered()), &m_controller, SLOT(debugStepFrame())); CONNASSERT(&m_controller, SIGNAL(setConnected(bool)), debugStepFrameAct, SLOT(setEnabled(bool))); CONNASSERT(&m_controller, SIGNAL(setBreaked(bool)), debugStepFrameAct, SLOT(setEnabled(bool))); debugStepFrameAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F11)); debugStepFrameAct->setEnabled(false); addDeleteBreakPointsAct = new QAction(tr("&Breakpoints..."), this); addDeleteBreakPointsAct->setStatusTip(tr("Add or remove breakpoints")); CONNASSERT(addDeleteBreakPointsAct, SIGNAL(triggered()), this, SLOT(addDeleteBreakPoints())); addDeleteBreakPointsAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); setBreakOnGLErrorAct = new QAction(tr("Break on GL error"), this); setBreakOnGLErrorAct->setStatusTip( tr("Break execution on GL error (glGetError() != GL_NO_ERROR)")); // this action has a state - it is checbox-like checkable DGLConfiguration& currentConfig = m_controller.getConfig(); setBreakOnGLErrorAct->setCheckable(true); setBreakOnGLErrorAct->setChecked(currentConfig.m_BreakOnGLError); CONNASSERT(setBreakOnGLErrorAct, SIGNAL(toggled(bool)), this, SLOT(setBreakOnWhatever(bool))); setBreakOnDebugOutputAct = new QAction(tr("Break on debug output"), this); setBreakOnDebugOutputAct->setStatusTip( tr("Break execution on debug output message")); // this action has a state - it is checbox-like checkable setBreakOnDebugOutputAct->setCheckable(true); setBreakOnDebugOutputAct->setChecked( currentConfig.m_BreakOnGLError); CONNASSERT(setBreakOnDebugOutputAct, SIGNAL(toggled(bool)), this, SLOT(setBreakOnWhatever(bool))); setBreakOnCompilerErrAct = new QAction(tr("Break on compiler/linker error"), this); setBreakOnCompilerErrAct->setStatusTip( tr("Break execution on debug GLSL compiler or linker error")); // this action has a state - it is checbox-like checkable setBreakOnCompilerErrAct->setCheckable(true); setBreakOnCompilerErrAct->setChecked( currentConfig.m_BreakOnCompilerError); CONNASSERT(setBreakOnCompilerErrAct, SIGNAL(toggled(bool)), this, SLOT(setBreakOnWhatever(bool))); // Only one color scheme can be choosed - put all related actions to // action // group setColorSchemeActGroup = new QActionGroup(this); // iterate through all color schemes. for each one create one action for (uint i = 0; i < DGLNUM_COLOR_SCHEMES; i++) { setColorSchemeActs[i] = new QAction(tr(dglColorSchemes[i].name), this); setColorSchemeActs[i]->setCheckable(true); setColorSchemeActs[i]->setActionGroup(setColorSchemeActGroup); setColorSchemeActs[i]->setStatusTip(tr("Set this color scheme")); // connect all color scheme actions to one mapper, so we can connect // it // later to only one signal m_SetColorSchemeSignalMapper.setMapping(setColorSchemeActs[i], i); CONNASSERT(setColorSchemeActs[i], SIGNAL(triggered()), &m_SetColorSchemeSignalMapper, SLOT(map())); } // mapper maps connected actions to one emitted signal by int parameter. // Connect this signal to "this" CONNASSERT(&m_SetColorSchemeSignalMapper, SIGNAL(mapped(int)), this, SLOT(setColorScheme(int))); configurationAct = new QAction(tr("Configuration..."), this); configurationAct->setStatusTip(tr("Configuration options")); CONNASSERT(configurationAct, SIGNAL(triggered()), this, SLOT(configure())); prepareAndroidAct = new QAction(tr("Prepare Android device..."), this); prepareAndroidAct->setStatusTip(tr("Installs " DGL_PRODUCT " on Android device")); CONNASSERT(prepareAndroidAct, SIGNAL(triggered()), this, SLOT(androidPrepare())); }
CONNASSERT(&m_controller, SIGNAL(newStatus(const QString &)), m_ui.statusBar, SLOT(showMessage(const QString &))); CONNASSERT(&m_controller, SIGNAL(connectionLost(const QString &, const QString &)), this, SLOT(connectionLost(const QString &, const QString &))); CONNASSERT(&m_controller, SIGNAL(debugeeInfo(const std::string &)), this, SLOT(updateWindowCaption(const std::string &))); CONNASSERT(&m_controller, SIGNAL(setConnected(bool)), this, SLOT(onConnect(bool))); CONNASSERT(&m_controller, SIGNAL(breaked(const CalledEntryPoint, uint)), this, SLOT(bringupToFront())); CONNASSERT(&m_BusyDialog, SIGNAL(canceled()), this, SLOT(debugStop())); } void DGLMainWindow::readSettings() { // read settings QSettings settings(DGL_MANUFACTURER, DGL_PRODUCT); restoreGeometry(settings.value(DGL_GEOMETRY_SETTINGS).toByteArray()); restoreState(settings.value(DGL_WINDOW_STATE_SETTINGS).toByteArray()); DGLAdbInterface::get()->setAdbCookieFactory( std::make_shared<DGLAdbCookieFactory>( settings.value(DGL_ADB_PATH_SETTINGS).toString().toStdString())); // decode and set actual color scheme from settings
int Runtime::runShell(const char *startupBas, int fontScale, int debugPort) { logEntered(); os_graphics = 1; os_color_depth = 16; opt_interactive = true; opt_usevmt = 0; opt_file_permitted = 1; opt_graphics = true; opt_pref_bpp = 0; opt_nosave = true; _output->setTextColor(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND); _output->setFontSize(getStartupFontSize(_window)); _initialFontSize = _output->getFontSize(); if (fontScale != 100) { _fontScale = fontScale; int fontSize = (_initialFontSize * _fontScale / 100); _output->setFontSize(fontSize); } SDL_Init(SDL_INIT_AUDIO); SDL_AudioSpec desiredSpec; desiredSpec.freq = FREQUENCY; desiredSpec.format = AUDIO_S16SYS; desiredSpec.channels = 1; desiredSpec.samples = 2048; desiredSpec.callback = audio_callback; SDL_AudioSpec obtainedSpec; SDL_OpenAudio(&desiredSpec, &obtainedSpec); net_init(); if (debugPort > 0) { appLog("Debug active on port %d\n", debugPort); g_lock = SDL_CreateMutex(); g_cond = SDL_CreateCond(); opt_trace_on = 1; g_debugBreak = SDL_TRUE; SDL_Thread *thread = SDL_CreateThread(debugThread, "DBg", (void *)(intptr_t)debugPort); SDL_DetachThread(thread); } if (startupBas != NULL) { String bas = startupBas; if (opt_ide == IDE_INTERNAL) { runEdit(bas.c_str()); } else { runOnce(bas.c_str()); } while (_state == kRestartState) { _state = kActiveState; if (_loadPath.length() != 0) { bas = _loadPath; } runOnce(bas.c_str()); } } else { runMain(MAIN_BAS); } if (debugPort > 0) { SDL_DestroyCond(g_cond); SDL_DestroyMutex(g_lock); } debugStop(); net_close(); SDL_CloseAudio(); _state = kDoneState; logLeaving(); return _fontScale; }
bool MarkovRunManager::findAndApplyNextRule() { if(_terminate_on_next_step) { _terminate_on_next_step = false; debugStop(); QCoreApplication::processEvents(); return false; } if(_word_after_last_step.size()>2000) { QString description = tr("Result can not be longer than 2000 symbols. On step #%1 input become %2 symbols long") .arg(_steps_made).arg(_word_after_last_step.size()); RunError error(tr("Too long result"), description, 101); if(_is_debug_mode) { emit debugFinishFail(_input_word,error,_steps_made); QCoreApplication::processEvents(); } else { emit runWithoutDebugFinishFail(_input_word,error,_steps_made); QCoreApplication::processEvents(); } return false; } //Go through MarkovRules and select which fits. //If there are no rules then emit debugFinishSuccess or //runWithoutDebugFinishSuccess depending on run mode. //Use as _word_after_last_step as output word. QString word = _word_after_last_step; MarkovRule rule; if(!choseAndUseRule(word, rule)) { //there are no rules if(_is_debug_mode) { emit debugFinishSuccess(_input_word, word, _steps_made); QCoreApplication::processEvents(); } else { emit runWithoutDebugFinishSuccess(_input_word, word, _steps_made); QCoreApplication::processEvents(); } return false; } ++_steps_made; if(_is_debug_mode) { emit debugStepFinished(_steps_made, _word_after_last_step, word, rule); QCoreApplication::processEvents(); } _word_after_last_step = word; if (_steps_history.contains(StepResult(_word_after_last_step,0))) { QString last_step = _word_after_last_step; if(last_step.size() > 30) last_step = last_step.mid(0, 30) + "..."; int prev_same_stem = getStepNumberOfValue(_word_after_last_step); QString description = tr("The result of step #%1 is same as on the step #%2\n('%3')") .arg(prev_same_stem).arg(_steps_made).arg(last_step); RunError error("Algorithm never terminates", description, 102); if(_is_debug_mode) { emit debugFinishFail(_input_word,error,_steps_made); QCoreApplication::processEvents(); } else { emit runWithoutDebugFinishFail(_input_word,error,_steps_made); QCoreApplication::processEvents(); } return false; } _steps_history.insert(StepResult(_word_after_last_step,_steps_made)); //If rule is final then emit debugFinishSuccess or //runWithoutDebugFinishSuccess depending on run mode. //Use as _word_after_last_step as output word. return false. if(rule.isFinalRule()) { if(_is_debug_mode) { emit debugFinishSuccess(_input_word, _word_after_last_step, _steps_made); QCoreApplication::processEvents(); } else { emit runWithoutDebugFinishSuccess(_input_word, _word_after_last_step, _steps_made); QCoreApplication::processEvents(); } return false; } else { if(_is_debug_mode) { if(_stop_on_next_step || _break_points.contains(rule.getLineNumber())) { _stop_on_next_step = false; emit debugBreakPointReached(rule.getLineNumber()); QCoreApplication::processEvents(); return false; } } } return true; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), _has_unsaved_data(true), _current_file(""), _can_run(false), _is_running(false), _is_debug_input(false) { ui->setupUi(this); initStyles(); updateWindowTitle(); redoAvailable(false); undoAvailable(false); copyAvailable(false); _window = this; ui->debugRun->setVisible(false); ui->runWidget->setVisible(false); registerFileType(tr("Yad.Markov.File"), tr("Markov Algorithm File"), ".yad", 1); updateDebugMenu(); //Connect MainWindow menu connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actionUndo, SIGNAL(triggered()), this, SIGNAL(undo())); connect(ui->actionRedo, SIGNAL(triggered()), this, SIGNAL(redo())); connect(ui->actionSelect_All, SIGNAL(triggered()), this, SIGNAL(selectAll())); connect(ui->actionCopy, SIGNAL(triggered()), this, SIGNAL(copy())); connect(ui->actionPaste, SIGNAL(triggered()), this, SIGNAL(paste())); connect(ui->actionCut, SIGNAL(triggered()), this, SIGNAL(cut())); connect(ui->actionDelete, SIGNAL(triggered()), this, SIGNAL(deleteSelection())); connect(ui->actionNew, SIGNAL(triggered()), this, SIGNAL(newFile())); connect(ui->actionOpen, SIGNAL(triggered()), this, SIGNAL(open())); connect(ui->actionSave, SIGNAL(triggered()), this, SIGNAL(save())); connect(ui->actionSave_As, SIGNAL(triggered()), this, SIGNAL(saveAs())); connect(ui->actionTutorial, SIGNAL(triggered()), this, SLOT(tutorial())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); //Connect InputWidget and HistoryManager HistoryManager* history_manager = HistoryManager::getInstance(); connect(ui->input, SIGNAL(addToHistory(QString)), history_manager, SLOT(addToHistory(QString))); connect(history_manager, SIGNAL(wordSelected(QString)), ui->input, SLOT(setInput(QString))); //Connect HistoryWidget and HistoryManager connect(ui->history, SIGNAL(inputWordSelected(QString)), history_manager, SIGNAL(wordSelected(QString))); connect(ui->history, SIGNAL(removeFromHistory(QString)), history_manager, SLOT(removeFromHistory(QString))); connect(history_manager, SIGNAL(historyChanged(QVector<QString>)), ui->history, SLOT(historyChanged(QVector<QString>))); //Connect MainWindows and FileManager FileManager* file_manager = FileManager::getInstance(); connect(this, SIGNAL(newFile()), file_manager, SLOT(newFile())); connect(this, SIGNAL(open()), file_manager, SLOT(open())); connect(this, SIGNAL(save()), file_manager, SLOT(save())); connect(this, SIGNAL(saveAs()), file_manager, SLOT(saveAs())); connect(file_manager, SIGNAL(hasUnsavedData(bool)), this, SLOT(hasUnsavedData(bool))); connect(file_manager, SIGNAL(fileNameChanged(QString)), this, SLOT(fileNameChanged(QString))); //Connect MainWindows and EditorWindowWidget connect(this, SIGNAL(undo()), ui->editorWindow, SLOT(undo())); connect(this, SIGNAL(redo()), ui->editorWindow, SLOT(redo())); connect(this, SIGNAL(selectAll()), ui->editorWindow, SLOT(selectAll())); connect(this, SIGNAL(copy()), ui->editorWindow, SLOT(copy())); connect(this, SIGNAL(paste()), ui->editorWindow, SLOT(paste())); connect(this, SIGNAL(cut()), ui->editorWindow, SLOT(cut())); connect(this, SIGNAL(deleteSelection()), ui->editorWindow, SLOT(deleteSelection())); connect(ui->editorWindow, SIGNAL(redoAvailable(bool)), this, SLOT(redoAvailable(bool))); connect(ui->editorWindow, SIGNAL(undoAvailable(bool)), this, SLOT(undoAvailable(bool))); connect(ui->editorWindow, SIGNAL(copyAvailable(bool)), this, SLOT(copyAvailable(bool))); //Connect InputWidget and MarkovRunManager MarkovRunManager* run_manager = MarkovRunManager::getInstance(); connect(ui->input, SIGNAL(run(QString)), run_manager, SLOT(runWithoutDebug(QString))); connect(ui->input, SIGNAL(runWithDebug(QString)), run_manager, SLOT(runWithDebug(QString))); connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)), ui->input, SLOT(runStarted())); connect(ui->input, SIGNAL(runWithDebugStepByStep(QString)), run_manager, SLOT(runWithDebugStepByStep(QString))); connect(run_manager, SIGNAL(debugStarted(QString)), ui->input, SLOT(runStarted())); connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)), ui->input, SLOT(runFinished())); connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)), ui->input, SLOT(runFinished())); connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)), ui->input, SLOT(runFinished())); connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)), ui->input, SLOT(runFinished())); connect(run_manager, SIGNAL(canRunSourceCode(bool)), ui->input, SLOT(canRunAlgorithm(bool))); //Connect SourceCodeManager and EditorWindowWidget SourceCodeManager* source_manager = SourceCodeManager::getInstance(); connect(source_manager, SIGNAL(newSourceCodeWasLoaded(QString)), ui->editorWindow, SLOT(newSourceCode(QString))); connect(ui->editorWindow, SIGNAL(sourceCodeChanged(QString)), source_manager, SLOT(setSourceCode(QString))); //Connect InputWidget and FileManager connect(ui->input, SIGNAL(save()), file_manager, SLOT(save())); //Connect MarkovRunManager and EditorWindowWidget connect(ui->editorWindow, SIGNAL(canRun(bool)), run_manager, SLOT(setCanRunSourceCode(bool))); connect(ui->editorWindow, SIGNAL(markovAlgorithmChanged(MarkovAlgorithm)), run_manager, SLOT(setAlgorithm(MarkovAlgorithm))); //Connect SourceCodeManager and FileManager connect(file_manager, SIGNAL(newSourceCodeLoaded(QString)), source_manager, SLOT(setNewSourceCodeFromFile(QString))); connect(source_manager, SIGNAL(sourceCodeChanged(QString)), file_manager, SLOT(sourceCodeChanged())); //Connect FileManager and HistoryManager connect(file_manager, SIGNAL(newHistoryLoaded(QVector<QString>)), this, SLOT(newHistoryLoaded(QVector<QString>))); connect(history_manager, SIGNAL(historyChanged(QVector<QString>)), file_manager, SLOT(historyChanged())); //Connect RunWidget and MarkovRunManager connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)), ui->runWidget, SLOT(runStarted(QString))); connect(run_manager, SIGNAL(runStepsMade(int)), ui->runWidget, SLOT(runStepsMade(int))); connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)), ui->runWidget, SLOT(runFailed(QString,RunError,int))); connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)), ui->runWidget, SLOT(runSuccess(QString,QString,int))); connect(run_manager, SIGNAL(debugStarted(QString)), ui->runWidget, SLOT(hide())); //Connect DebugRunWidget and MarkovRunManager connect(ui->debugRun, SIGNAL(nextStepClicked()), run_manager, SLOT(debugNextStep())); connect(ui->debugRun, SIGNAL(continueClicked()), run_manager, SLOT(debugContinue())); connect(ui->debugRun, SIGNAL(stopClicked()), run_manager, SLOT(debugStop())); connect(run_manager, SIGNAL(debugStarted(QString)), ui->debugRun, SLOT(debugStarted(QString))); connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)), ui->debugRun, SLOT(debugSuccess(QString,QString,int))); connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)), ui->debugRun, SLOT(debugFailed(QString,RunError,int))); connect(run_manager, SIGNAL(debugStepFinished(int,QString,QString,MarkovRule)), ui->debugRun, SLOT(debugStepFinished(int,QString,QString,MarkovRule))); connect(run_manager, SIGNAL(debugBreakPointReached(int)), ui->debugRun, SLOT(breakPointReached(int))); connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)), ui->debugRun, SLOT(hide())); connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)), ui->runWidget, SLOT(hide())); connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)), ui->debugRun, SLOT(hide())); //Connect DebugRunWidget and EditorWindowWidget connect(ui->debugRun, SIGNAL(removeBreakPoint()), ui->editorWindow, SLOT(removeLineHighlight())); connect(ui->debugRun, SIGNAL(showBreakPoint(int)), ui->editorWindow, SLOT(showLineHighlight(int))); //Connect MarkovRunManager and EditorWindowWidget connect(ui->editorWindow, SIGNAL(breakPointAdded(int)), run_manager, SLOT(addBreakPoint(int))); connect(ui->editorWindow, SIGNAL(breakPointRemoved(int)), run_manager, SLOT(removeBreakPoint(int))); //Connect top menu connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)), this, SLOT(runStarted())); connect(run_manager, SIGNAL(debugStarted(QString)), this, SLOT(runStarted())); connect(run_manager, SIGNAL(runWithoutDebugFinishFail(QString,RunError,int)), this, SLOT(runFinished())); connect(run_manager, SIGNAL(runWithoutDebugFinishSuccess(QString,QString,int)), this, SLOT(runFinished())); connect(run_manager, SIGNAL(debugFinishFail(QString,RunError,int)), this, SLOT(runFinished())); connect(run_manager, SIGNAL(debugFinishSuccess(QString,QString,int)), this, SLOT(runFinished())); connect(run_manager, SIGNAL(canRunSourceCode(bool)), this, SLOT(canRunAlgorithm(bool))); connect(run_manager, SIGNAL(debugBreakPointReached(int)), this, SLOT(debugInputStarted())); connect(run_manager, SIGNAL(debugStepFinished(int,QString,QString,MarkovRule)), this, SLOT(debugInputFinished())); connect(ui->actionRun, SIGNAL(triggered()), ui->input, SLOT(runCliked())); connect(ui->actionDebug, SIGNAL(triggered()), ui->input, SLOT(runWithDebugClicked())); connect(ui->actionNext_Step, SIGNAL(triggered()), run_manager, SLOT(debugNextStep())); connect(ui->actionContinue, SIGNAL(triggered()), run_manager, SLOT(debugContinue())); connect(ui->actionStop_Debug, SIGNAL(triggered()), run_manager, SLOT(debugStop())); connect(ui->actionDebug_Step_By_Step, SIGNAL(triggered()), ui->input, SLOT(runWithDebugStepByStepClicked())); //Read file to open from command line QStringList arguments = QCoreApplication::arguments(); if(arguments.size() >= 2) { QString file_name = arguments.at(1); FileManager::getInstance()->openFile(file_name); } else { source_manager->setNewSourceCodeFromFile(tr("//Alphabet\nT = {a, b}\n\n//Rules\nab -> a\na ->. b")); } }