83 {
84
87
88 try {
91 return EXIT_SUCCESS;
93 std::cerr << "Error: Illegal commandline: "
96 return 1;
97 }
98
100 std::cerr << "Error: Illegal number of parameters.\n\n";
102 return 1;
103 }
104
105
108
111
112 try {
114 } catch ( ... ) {
115 std::cerr << "Error: " << adfFileName << " is not valid ADF file.\n\n";
117 return 1;
118 }
119
121 std::cerr << "Error: cannot read " << asmFileName << std::endl;
122 return 2;
123 }
124
125
126
127
128 std::string::size_type dotPosition = asmFileName.rfind('.');
129 std::string genOutputFileName;
130
132
133 if (dotPosition != std::string::npos) {
134 genOutputFileName = asmFileName.substr(0, dotPosition);
135 } else {
136 genOutputFileName = asmFileName;
137 }
138
139 genOutputFileName += ".tpef";
140
142
145 };
146
148
150
151
152 bool failure = false;
153
154 try {
155 Binary* compiledTPEF = assembler.compile();
156
159 std::cerr << message.toString() << std::endl;
160 }
161 }
162
163 try {
165
167
169
170 delete compiledTPEF;
171 compiledTPEF = NULL;
172
175 "Problems while writing Binary to file: " +
177
178 error.setCause(e);
179
180 throw error;
181 }
182
184 std::cerr << "Error while compiling file: " << asmFileName << std::endl
186 failure = true;
187
189 std::cerr << "Strange exception while compiling file: " << asmFileName << std::endl
191 failure = true;
192
193 } catch ( ... ) {
194 std::cerr << "Unknown exception!\n";
195 failure = true;
196 }
197
198
201
202 if (failure) {
203 return 1;
204 } else {
205 return 0;
206 }
207}
static std::string outputFileName(const std::string &adfFile)
TTAMachine::Machine * machine
the architecture definition of the estimated processor
static MachInfoCmdLineOptions options
TTAMachine::Machine * readMachine()
void parse(char *argv[], int argc)
virtual std::string argument(int index) const
virtual int numberOfArguments() const
std::string errorMessage() const
static bool fileIsReadable(const std::string fileName)
virtual void printHelp() const
void writeBinary(BinaryStream &stream, const Binary *bin) const
static const BinaryWriter & instance()
void setSourceFile(const std::string &fileName)