summaryrefslogtreecommitdiffstats
path: root/src/asmformatter.h
blob: f4867cb12b8a000ed308ed33e472a62eb44f458c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/***************************************************************************
 *   Copyright (C) 2003-2005 by David Saxton                               *
 *   david@bluehaze.org                                                    *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/

#ifndef ASMFORMATTER_H
#define ASMFORMATTER_H

#include <tqstringlist.h>

/**
@author David Saxton
 */
class InstructionParts
{
	public:
		/**
		 * Breaks up the line into parts.
		 */
		InstructionParts( TQString line );
		
		TQString label() const { return m_label; }
		TQString operand() const { return m_operand; }
		TQString operandData() const { return m_operandData; }
		TQString comment() const { return m_comment; }
		
	protected:
		TQString m_label;
		TQString m_operand;
		TQString m_operandData;
		TQString m_comment; ///< includes the ";" part
};

/**
@author David Saxton
*/
class AsmFormatter
{
	public:
		AsmFormatter();
		~AsmFormatter();
	
		enum LineType
		{
			Equ,
			Instruction, // could include label
			Other, // eg comments, __config
		};
	
		TQString tidyAsm( TQStringList lines );
	
		static LineType lineType( TQString line );
	
	protected:
		TQString tidyInstruction( const TQString & line );
		TQString tidyEqu( const TQString & line );
		/**
		 * Appends spaces to the end of text until it is greater or equakl to
		 * length.
		 */
		static void pad( TQString & text, int length );
	
		int m_indentAsmName;
		int m_indentAsmData;
		int m_indentEqu;
		int m_indentEquValue;
		int m_indentEquComment;
		int m_indentComment;
};

#endif