OpenASIP  2.0
Assembler.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2017 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file Assembler.hh
26  *
27  * Declaration of Assembler class.
28  *
29  * @author Mikael Lepistö 2005 (tmlepist-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2006 (pekka.jaaskelainen-no.spam-tut.fi)
31  * @author Henry Linjamäki 2017 (henry.linjamaki-no.spam-tut.fi)
32  *
33  * @note rating yellow
34  */
35 
36 #ifndef TCEASM_ASSEMBLER_HH
37 #define TCEASM_ASSEMBLER_HH
38 
39 #include "Exception.hh"
40 #include "ParserStructs.hh"
42 
43 namespace TPEF {
44  class BinaryStream;
45  class Binary;
46 }
47 
48 namespace TTAMachine {
49  class Machine;
50 }
51 
52 /**
53  * TCE Assembler user interface.
54  */
55 class Assembler {
56 public:
57  Assembler(
58  TPEF::BinaryStream& assemblerFile,
59  TTAMachine::Machine& assemblerMachine);
60 
62 
63  const std::set<CompilerMessage>& warnings() const;
64 
65  const CompilerMessage& error() const;
66 
67  void addWarning(UValue lineNumber, std::string errorMessage);
68 
69  const TTAMachine::Machine& targetMachine() const;
70 
71 private:
72  void readAssemblerCode();
73 
74  std::string codeLine(UValue lineNumber) const;
75 
76  /// File containing file to assemble.
78 
79  /// Machine for assembled TPEF.
81 
82  /// Last thrown error message
84 
85  /// Parser messages.
87 
88  /// String containing code to compile.
89  std::shared_ptr<std::string> asmCode_;
90 };
91 
92 #endif
Assembler::error
const CompilerMessage & error() const
Definition: Assembler.cc:165
Assembler::warnings
const std::set< CompilerMessage > & warnings() const
Definition: Assembler.cc:155
Exception.hh
AssemblyParserDiagnostic.hh
TPEF::Binary
Definition: Binary.hh:49
TPEF::BinaryStream
Definition: BinaryStream.hh:59
Assembler::stream_
TPEF::BinaryStream & stream_
File containing file to assemble.
Definition: Assembler.hh:77
ParserStructs.hh
Assembler::Assembler
Assembler(TPEF::BinaryStream &assemblerFile, TTAMachine::Machine &assemblerMachine)
Definition: Assembler.cc:55
AssemblyParserDiagnostic
Definition: AssemblyParserDiagnostic.hh:68
Assembler::parserDiagnostic_
AssemblyParserDiagnostic parserDiagnostic_
Parser messages.
Definition: Assembler.hh:86
UValue
unsigned long UValue
Definition: ParserStructs.hh:44
CompilerMessage
Definition: AssemblyParserDiagnostic.hh:46
Assembler::asmCode_
std::shared_ptr< std::string > asmCode_
String containing code to compile.
Definition: Assembler.hh:89
Assembler::mach_
TTAMachine::Machine * mach_
Machine for assembled TPEF.
Definition: Assembler.hh:80
Assembler::codeLine
std::string codeLine(UValue lineNumber) const
Definition: Assembler.cc:196
Assembler::readAssemblerCode
void readAssemblerCode()
Definition: Assembler.cc:173
Assembler::compile
TPEF::Binary * compile()
Definition: Assembler.cc:68
Assembler::targetMachine
const TTAMachine::Machine & targetMachine() const
Definition: Assembler.cc:150
Assembler
Definition: Assembler.hh:55
TTAMachine
Definition: Assembler.hh:48
Assembler::addWarning
void addWarning(UValue lineNumber, std::string errorMessage)
Definition: Assembler.cc:140
TPEF
Definition: Assembler.hh:43
TTAMachine::Machine
Definition: Machine.hh:73
Assembler::error_
CompilerMessage error_
Last thrown error message.
Definition: Assembler.hh:83