本文整理汇总了C++中LocationVector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ LocationVector::push_back方法的具体用法?C++ LocationVector::push_back怎么用?C++ LocationVector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocationVector
的用法示例。
在下文中一共展示了LocationVector::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
cout << "\n\t\tLC-3 Assembler Converter 1.0, Ashley Wise\n\n";
if(!ProcessArgs(argc, argv))
{
PrintUsage();
return 0;
}
char sMessageBuffer[65 + MAX_FILENAME_CHAR];
LocationVector LocationStack;
bool fRetVal = true;
for(unsigned int i = 0; i < InputList.size(); i++)
{
ifstream AsmFile(InputList[i].c_str());
if(!AsmFile.good())
{
sprintf(sMessageBuffer, "Unable to open file %.255s", InputList[i].c_str());
AsmCallBack(Fatal, sMessageBuffer, LocationVector());
fRetVal = false;
continue;
}
string sAsm3FileName = InputList[i]+"3";
ofstream Asm3File(sAsm3FileName.c_str());
if(!Asm3File.good())
{
sprintf(sMessageBuffer, "Unable to open file %.255s", sAsm3FileName.c_str());
AsmCallBack(Fatal, sMessageBuffer, LocationVector());
fRetVal = false;
continue;
}
LocationStack.push_back( LocationVector::value_type(i, 1) );
cout << "Translating " << InputList[i].c_str() << endl;
if(!AsmConvertLC3(AsmFile, Asm3File, LocationStack, AsmCallBack))
{
fRetVal = false;
continue;
}
}
cout << endl;
return 0;
}
示例2: AssemblerUI
bool AssemblerUI(vector<Program *> &AsmPrograms, RamVector &MemoryImage)
{
bool fRetVal = true;
char sMessageBuffer[65 + MAX_FILENAME_CHAR];
unsigned int i;
ofstream VHDLFile;
AsmCallBack(Info, "", LocationVector());
sprintf(sMessageBuffer, "\t\tLC-3b Assembler %.15s, Ashley Wise", ASM_VER);
AsmCallBack(Info, sMessageBuffer, LocationVector());
AsmCallBack(Info, "", LocationVector());
#ifdef BIG_ENDIAN_BUILD
if(EndianCheck())
{
AsmCallBack(Fatal, "Platform is little endian; assembler built for big endian! Aborting...", LocationVector());
return false;
}
#else
if(!EndianCheck())
{
AsmCallBack(Fatal, "Platform is big endian; assembler built for little endian! Aborting...", LocationVector());
return false;
}
#endif
//Initialize program list
for(i = 0; i < InputList.size(); i++)
{
LocationVector LocationStack;
LocationStack.push_back( LocationVector::value_type(i, 0) );
AsmPrograms.push_back(new Program(LocationStack, InputList[i], LC3bISA::Addressability));
}
//*** Perform Compilation ***
//Lex, parse, and optimize each input asm file
AsmCallBack(Info, "Compiling...", LocationVector());
for(i = 0; i < AsmPrograms.size(); i++)
{
//Open the assembly file
if(ToLower(AsmPrograms[i]->sFileName.Ext) == "obj" || ToLower(AsmPrograms[i]->sFileName.Ext) == "bin")
{
ifstream AsmFile(InputList[i].c_str(), ios::in | ios::binary);
if(!AsmFile.good())
{
sprintf(sMessageBuffer, "Unable to open file %.255s", InputList[i].c_str());
AsmCallBack(Fatal, sMessageBuffer, LocationVector());
fRetVal = false;
continue;
}
if(!Assemble<LC3bISA>::Disassemble(AsmFile, *AsmPrograms[i], AsmCallBack))
fRetVal = false;
}
else
{
ifstream AsmFile(InputList[i].c_str());
if(!AsmFile.good())
{
sprintf(sMessageBuffer, "Unable to open file %.255s", InputList[i].c_str());
AsmCallBack(Fatal, sMessageBuffer, LocationVector());
fRetVal = false;
continue;
}
if(!Assemble<LC3bISA>::Compile(AsmFile, *AsmPrograms[i], AsmCallBack))
fRetVal = false;
}
}
if(!fRetVal)
goto CleanUp;
//*** Perform Linking ***
//Convert the symbolic assembly program into a memory image
AsmCallBack(Info, "Linking...", LocationVector());
fRetVal = Assemble<LC3bISA>::Link(AsmPrograms, MemoryImage, AsmCallBack);
if(!fRetVal)
goto CleanUp;
if(Flags.fOutputVHDL)
{
//Create output file name. If none is specified, the filename will be the same as
//the first input file except the extention is replaced with ".vhd"
if(sOutputFileName == "")
sOutputFileName = AsmPrograms[0]->sFileName.Path + AsmPrograms[0]->sFileName.Bare + ".vhd";
//Open the output file.
VHDLFile.open(sOutputFileName.c_str());
if(!VHDLFile.good())
{
sprintf(sMessageBuffer, "Unable to create file %.255s...", sOutputFileName.c_str());
AsmCallBack(Fatal, sMessageBuffer, LocationVector());
goto CleanUp;
}
//write the memory image into a VHDL Ram vectors file
sprintf(sMessageBuffer, "Writing VHDL to %.255s...", sOutputFileName.c_str());
AsmCallBack(Info, sMessageBuffer, LocationVector());
Assemble<LC3bISA>::VHDLWrite(VHDLFile, MemoryImage, AsmCallBack);
}
else
sOutputFileName = AsmPrograms[0]->sFileName.Path + AsmPrograms[0]->sFileName.Bare;
//.........这里部分代码省略.........