void assembleFile() { std::ifstream in(inPath_.c_str()); if (!in) { error("couldn't open: " + errorString()); } while (getline(in, line_)) { ++lineNumber_; p_ = line_.c_str(); // Handle labels. if (isalnum(*p_)) { handleLabel(); } else { // Trim leading whitespace. trimLeft(); if (*p_ == 0 || *p_ == '#') { // Skip blank or comment lines. } else if (*p_ == '.') { handleDirective(); } else { handleInstruction(); } } } fixForwardBranches(); writeBytes(&code_[0], &code_[code_.size()]); }
void WorksheetSubStreamHandler::handleRecord(Record* record) { if (!record) return; const unsigned type = record->rtti(); if (type == BottomMarginRecord::id) handleBottomMargin(static_cast<BottomMarginRecord*>(record)); else if (type == BoolErrRecord::id) handleBoolErr(static_cast<BoolErrRecord*>(record)); else if (type == BlankRecord::id) handleBlank(static_cast<BlankRecord*>(record)); else if (type == CalcModeRecord::id) handleCalcMode(static_cast<CalcModeRecord*>(record)); else if (type == ColInfoRecord::id) handleColInfo(static_cast<ColInfoRecord*>(record)); else if (type == DataTableRecord::id) handleDataTable(static_cast<DataTableRecord*>(record)); else if (type == FormulaRecord::id) handleFormula(static_cast<FormulaRecord*>(record)); else if (type == FooterRecord::id) handleFooter(static_cast<FooterRecord*>(record)); else if (type == HeaderRecord::id) handleHeader(static_cast<HeaderRecord*>(record)); else if (type == LabelRecord::id) handleLabel(static_cast<LabelRecord*>(record)); else if (type == LabelSSTRecord::id) handleLabelSST(static_cast<LabelSSTRecord*>(record)); else if (type == LeftMarginRecord::id) handleLeftMargin(static_cast<LeftMarginRecord*>(record)); else if (type == MergedCellsRecord::id) handleMergedCells(static_cast<MergedCellsRecord*>(record)); else if (type == MulBlankRecord::id) handleMulBlank(static_cast<MulBlankRecord*>(record)); else if (type == MulRKRecord::id) handleMulRK(static_cast<MulRKRecord*>(record)); else if (type == NumberRecord::id) handleNumber(static_cast<NumberRecord*>(record)); else if (type == RightMarginRecord::id) handleRightMargin(static_cast<RightMarginRecord*>(record)); else if (type == RKRecord::id) handleRK(static_cast<RKRecord*>(record)); else if (type == RowRecord::id) handleRow(static_cast<RowRecord*>(record)); else if (type == RStringRecord::id) handleRString(static_cast<RStringRecord*>(record)); else if (type == SharedFormulaRecord::id) handleSharedFormula(static_cast<SharedFormulaRecord*>(record)); else if (type == StringRecord::id) handleString(static_cast<StringRecord*>(record)); else if (type == TopMarginRecord::id) handleTopMargin(static_cast<TopMarginRecord*>(record)); else if (type == HLinkRecord::id) handleHLink(static_cast<HLinkRecord*>(record)); else if (type == NoteRecord::id) handleNote(static_cast<NoteRecord*>(record)); else if (type == ObjRecord::id) handleObj(static_cast<ObjRecord*>(record)); else if (type == TxORecord::id) handleTxO(static_cast<TxORecord*>(record)); else if (type == BOFRecord::id) handleBOF(static_cast<BOFRecord*>(record)); else if (type == DefaultRowHeightRecord::id) handleDefaultRowHeight(static_cast<DefaultRowHeightRecord*>(record)); else if (type == DefaultColWidthRecord::id) handleDefaultColWidth(static_cast<DefaultColWidthRecord*>(record)); else if (type == SetupRecord::id) handleSetup(static_cast<SetupRecord*>(record)); else if (type == HCenterRecord::id) handleHCenter(static_cast<HCenterRecord*>(record)); else if (type == VCenterRecord::id) handleVCenter(static_cast<VCenterRecord*>(record)); else if (type == ZoomLevelRecord::id) handleZoomLevel(static_cast<ZoomLevelRecord*>(record)); else if (type == 0xA) {} //EofRecord else if (type == DimensionRecord::id) handleDimension(static_cast<DimensionRecord*>(record)); else if (type == MsoDrawingRecord::id) handleMsoDrawing(static_cast<MsoDrawingRecord*>(record)); else if (type == Window2Record::id) handleWindow2(static_cast<Window2Record*>(record)); else if (type == PasswordRecord::id) handlePassword(static_cast<PasswordRecord*>(record)); else if (type == BkHimRecord::id) handleBkHim(static_cast<BkHimRecord*>(record)); else if (type == VerticalPageBreaksRecord::id) handleVerticalPageBreaksRecord(static_cast<VerticalPageBreaksRecord*>(record)); else if (type == HorizontalPageBreaksRecord::id) handleHorizontalPageBreaksRecord(static_cast<HorizontalPageBreaksRecord*>(record)); else if (type == CondFmtRecord::id) handleCondFmtRecord(static_cast<CondFmtRecord*>(record)); else if (type == CFRecord::id) handleCFRecord(static_cast<CFRecord*>(record)); else { //std::cout << "Unhandled worksheet record with type=" << type << " name=" << record->name() << std::endl; } }
bool Script::executeCommand(int index, MasterTimer* timer, QList<Universe *> universes) { if (index < 0 || index >= m_lines.size()) { qWarning() << "Invalid command index:" << index; return false; } QList <QStringList> tokens = m_lines[index]; if (tokens.isEmpty() == true) return true; // Empty line bool continueLoop = true; QString error; if (tokens[0].size() < 2) { error = QString("Syntax error"); } else if (tokens[0][0] == Script::startFunctionCmd) { error = handleStartFunction(tokens, timer); } else if (tokens[0][0] == Script::stopFunctionCmd) { error = handleStopFunction(tokens); } else if (tokens[0][0] == Script::waitCmd) { // Waiting should break out of the execution loop to prevent skipping // straight to the next command. If there is no error in wait parsing, // we must wait at least one cycle. error = handleWait(tokens); if (error.isEmpty() == true) continueLoop = false; } else if (tokens[0][0] == Script::waitKeyCmd) { // Waiting for a key should break out of the execution loop to prevent // skipping straight to the next command. If there is no error in waitkey // parsing,we must wait at least one cycle. error = handleWaitKey(tokens); if (error.isEmpty() == true) continueLoop = false; } else if (tokens[0][0] == Script::setFixtureCmd) { error = handleSetFixture(tokens, universes); } else if (tokens[0][0] == Script::labelCmd) { error = handleLabel(tokens); } else if (tokens[0][0] == Script::jumpCmd) { // Jumping can cause an infinite non-waiting loop, causing starvation // among other functions. Therefore, the script must relinquish its // time slot after each jump. If there is no error in jumping, the jump // must have happened. error = handleJump(tokens); if (error.isEmpty() == true) continueLoop = false; } else { error = QString("Unknown command: %1").arg(tokens[0][0]); } if (error.isEmpty() == false) qWarning() << QString("Script:%1, line:%2, error:%3").arg(name()).arg(index).arg(error); return continueLoop; }