61 if(!iParameterListInterface->E32ImageOutput()) |
64 if(!iParameterListInterface->E32ImageOutput()) |
62 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--output"); |
65 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--output"); |
63 if(!iParameterListInterface->DefInput()) |
66 if(!iParameterListInterface->DefInput()) |
64 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--definput"); |
67 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--definput"); |
65 |
68 |
66 GenerateAsmFile(iParameterListInterface->E32ImageOutput()); |
69 GenerateAsmFile(); |
67 } |
70 } |
68 else |
71 else |
69 { |
72 { |
70 if(!iParameterListInterface->E32Input()) |
73 if(!iParameterListInterface->E32Input()) |
71 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--e32input"); |
74 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--e32input"); |
72 if(iParameterListInterface->DumpOptions() & EDumpAsm ) |
75 if(iParameterListInterface->DumpOptions() & EDumpAsm ) |
73 throw InvalidArgumentError(INVALIDARGUMENTERROR,iParameterListInterface->FileDumpSubOptions() ,"--dump"); |
76 throw InvalidArgumentError(INVALIDARGUMENTERROR,iParameterListInterface->FileDumpSubOptions() ,"--dump"); |
74 DumpE32Image(iParameterListInterface->E32Input()); |
77 DumpE32Image(); |
75 } |
78 } |
76 return 0; |
79 return 0; |
77 } |
80 } |
78 |
81 |
79 /** |
82 /** |
81 @param afileName - ASM File name |
84 @param afileName - ASM File name |
82 @return 0 on success, otherwise throw error |
85 @return 0 on success, otherwise throw error |
83 @internalComponent |
86 @internalComponent |
84 @released |
87 @released |
85 */ |
88 */ |
86 int FileDump::GenerateAsmFile(const char* afileName)//DumpAsm |
89 int FileDump::GenerateAsmFile() //DumpAsm |
|
90 { |
|
91 EAsmDialect asmDialect = iParameterListInterface->AsmDialect(); |
|
92 switch(asmDialect) |
|
93 { |
|
94 case EGas: |
|
95 return GenerateGasAsmFile(); |
|
96 case EArmas: |
|
97 return GenerateArmasAsmFile(); |
|
98 default: |
|
99 assert(false); |
|
100 } |
|
101 return 0; |
|
102 } |
|
103 |
|
104 /** |
|
105 Function to generate an RVCT armas ASM File. |
|
106 @param afileName - ASM File name |
|
107 @return 0 on success, otherwise throw error |
|
108 @internalComponent |
|
109 @released |
|
110 */ |
|
111 int FileDump::GenerateArmasAsmFile() |
87 { |
112 { |
88 DefFile *iDefFile = new DefFile(); |
113 DefFile *iDefFile = new DefFile(); |
89 SymbolList *aSymList; |
114 SymbolList *aSymList; |
90 aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput()); |
115 aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput()); |
|
116 char const *afileName = iParameterListInterface->E32ImageOutput(); |
91 |
117 |
92 FILE *fptr; |
118 FILE *fptr; |
93 |
119 |
94 if((fptr=fopen(afileName,"w"))==NULL) |
120 if((fptr=fopen(afileName,"w"))==NULL) |
95 { |
121 { |
153 } |
179 } |
154 return 0; |
180 return 0; |
155 } |
181 } |
156 |
182 |
157 /** |
183 /** |
|
184 Function to generate a GNU as ASM File. |
|
185 @param afileName - ASM File name |
|
186 @return 0 on success, otherwise throw error |
|
187 @internalComponent |
|
188 @released |
|
189 */ |
|
190 int FileDump::GenerateGasAsmFile() |
|
191 { |
|
192 DefFile *iDefFile = new DefFile(); |
|
193 SymbolList *aSymList; |
|
194 aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput()); |
|
195 char const *afileName = iParameterListInterface->E32ImageOutput(); |
|
196 |
|
197 FILE *fptr; |
|
198 |
|
199 if((fptr=fopen(afileName,"w"))==NULL) |
|
200 { |
|
201 throw FileError(FILEOPENERROR,(char*)afileName); |
|
202 } |
|
203 else |
|
204 { |
|
205 SymbolList::iterator aItr = aSymList->begin(); |
|
206 SymbolList::iterator last = aSymList->end(); |
|
207 Symbol *aSym; |
|
208 |
|
209 while( aItr != last) |
|
210 { |
|
211 aSym = *aItr; |
|
212 |
|
213 if(aSym->Absent()) |
|
214 { |
|
215 aItr++; |
|
216 continue; |
|
217 } |
|
218 fputs("\t.common ",fptr); |
|
219 fputs(aSym->SymbolName(),fptr); |
|
220 fputs(" 4\n",fptr); |
|
221 aItr++; |
|
222 } |
|
223 |
|
224 fclose(fptr); |
|
225 } |
|
226 return 0; |
|
227 } |
|
228 |
|
229 |
|
230 /** |
158 Function to Dump E32 Image. |
231 Function to Dump E32 Image. |
159 @param afileName - E32 Image File name |
232 @param afileName - E32 Image File name |
160 @return 1 on success, otherwise throw error |
233 @return 1 on success, otherwise throw error |
161 @internalComponent |
234 @internalComponent |
162 @released |
235 @released |
163 */ |
236 */ |
164 int FileDump::DumpE32Image(const char* afileName) |
237 int FileDump::DumpE32Image() |
165 { |
238 { |
|
239 char const *afileName = iParameterListInterface->E32Input(); |
166 E32ImageFile *aE32Imagefile=new E32ImageFile(); |
240 E32ImageFile *aE32Imagefile=new E32ImageFile(); |
167 TInt result = aE32Imagefile->Open(afileName); |
241 TInt result = aE32Imagefile->Open(afileName); |
168 |
242 |
169 if (result > 0) |
243 if (result > 0) |
170 return 1; |
244 return 1; |