File indexing completed on 2024-06-16 08:27:28

0001 /***************************************************************************
0002  *   Copyright (C) 2005 by David Saxton                                    *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #ifndef ASMPARSER_H
0012 #define ASMPARSER_H
0013 
0014 #include <QString>
0015 
0016 class GpsimDebugger;
0017 
0018 /**
0019 Reads in an assembly file, and extracts useful information from it, such as the
0020 PIC ID
0021 
0022 @author David Saxton
0023 */
0024 class AsmParser
0025 {
0026 public:
0027     /// @param url a path to a file in the local filesystem
0028     AsmParser(const QString &url);
0029     ~AsmParser();
0030 
0031     enum Type { Relocatable, Absolute };
0032 
0033     /**
0034      * Read in data from file, return success status.
0035      * @param debugger if this is non-null, then source-line markers read
0036      * from the assembly file (such as those beginning with ";#CSRC" will be
0037      * passed to hllDebugger).
0038      */
0039     bool parse(GpsimDebugger *debugger = nullptr);
0040     /**
0041      * Returns the PIC ID
0042      */
0043     QString picID() const
0044     {
0045         return m_picID;
0046     }
0047     /**
0048      * Returns whether or not the assembly file contained the "set radix"
0049      * directive
0050      */
0051     bool containsRadix() const
0052     {
0053         return m_bContainsRadix;
0054     }
0055     /**
0056      * If the assembly file contains any of several key words that identify
0057      * it as a relocatable object, then this will return Relocatable.
0058      */
0059     Type type() const
0060     {
0061         return m_type;
0062     }
0063 
0064 protected:
0065     const QString m_url;
0066     QString m_picID;
0067     bool m_bContainsRadix;
0068     Type m_type;
0069 };
0070 
0071 #endif