/*************************************************************************** * Copyright (C) 2006-2007 Nicolas Hadacek * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "disassembler.h" #include #include "devices/base/device_group.h" #include "devices/pic/pic/pic_memory.h" #include "coff_object.h" //----------------------------------------------------------------------------- TQString SourceLine::comment(PURL::SourceFamily family, const TQString &text) { switch (family.type()) { case PURL::SourceFamily::Asm: return "; " + text; case PURL::SourceFamily::C: return "/* " + text + " */"; case PURL::SourceFamily::JAL: return "-- " + text; case PURL::SourceFamily::Cpp: return "// " + text; case PURL::SourceFamily::Basic: return "' " + text; case PURL::SourceFamily::Nb_Types: break; } Q_ASSERT(false); return TQString(); } namespace SourceLine { class LineData { public: LineData() : group(-1) {} TQString text, comment; int group; }; } // namespace TQStringList SourceLine::lines(PURL::SourceFamily family, const List &list, uint nbSpaces) { TQValueList lines; TQValueList groupCommentColumn; groupCommentColumn.append(0); List::const_iterator it; for (it=list.begin(); it!=list.end(); ++it) { LineData data; switch((*it).type) { case Indented: data.text = repeat(" ", nbSpaces); case NotIndented: if ( (*it).code.isEmpty() && !(*it).comment.isEmpty() ) data.text += comment(family, (*it).comment); else { data.text += (*it).code; data.comment = (*it).comment; data.group = groupCommentColumn.count() - 1; groupCommentColumn[data.group] = qMax(groupCommentColumn[data.group], uint(data.text.length())); } break; case Separator: data.text = comment(family, "-----------------------------------------------------------------------"); groupCommentColumn.append(0); break; case Empty: break; case Title: data.text = comment(family, (*it).comment); break; } lines += data; } TQStringList slines; TQValueList::const_iterator lit; for (lit=lines.begin(); lit!=lines.end(); ++lit) { if ( (*lit).group==-1 || (*lit).comment.isEmpty() ) slines += (*lit).text; else { uint col = groupCommentColumn[(*lit).group] + 1; slines += (*lit).text.leftJustify(col, ' ') + comment(family, (*lit).comment); } } return slines; } TQString SourceLine::text(PURL::SourceFamily family, const List &list, uint nbSpaces) { return lines(family, list, nbSpaces).join("\n") + "\n"; } TQString SourceLine::transformConfigName(const Pic::Data &data, uint wordIndex, const TQString &name) { if ( !data.is18Family() ) return name; bool ok; (void)fromHexLabel(name, &ok); if (ok) return name; TQString s = name + '_'; if ( data.name()=="18C601" || data.name()=="18C801" || data.name().startsWith("18F" ) ) s += TQString::number(wordIndex/2+1) + (wordIndex%2==0 ? 'L' : 'H'); else s += TQString::number(wordIndex); return s; } TQStringList SourceLine::ignoredConfigNames(const Pic::Data &data, uint wordIndex) { TQStringList cnames; const TQStringList &names = data.config()._words[wordIndex].ignoredCNames; for (uint i=0; i=0; l--) { const Pic::Config::Value &cvalue = ctqmask.values[l]; if ( !cvalue.value.isInside(v) ) continue; TQStringList vcnames = cvalue.configNames[type]; if ( vcnames.isEmpty() && type!=Pic::ConfigNameType::Default ) vcnames = cvalue.configNames[Pic::ConfigNameType::Default]; for (uint i=0; i"); return lines; } SourceLine::List GPUtils::generateConfigLines(const Pic::Memory &memory, bool &ok) { SourceLine::List lines; const Pic::Data &data = memory.device(); const Pic::Config &config = data.config(); for (uint i=0; i