本文整理汇总了C++中TextFile::openMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ TextFile::openMemory方法的具体用法?C++ TextFile::openMemory怎么用?C++ TextFile::openMemory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextFile
的用法示例。
在下文中一共展示了TextFile::openMemory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addEquation
void Parser::addEquation(const Token& startToken, const std::wstring& name, const std::wstring& value)
{
// parse value string
TextFile f;
f.openMemory(value);
FileTokenizer tok;
tok.init(&f);
TokenizerPosition start = tok.getPosition();
while (tok.atEnd() == false)
{
const Token& token = tok.nextToken();
if (token.type == TokenType::Identifier && token.getStringValue() == name)
{
printError(startToken,L"Recursive enum definition for \"%s\" not allowed",name);
return;
}
}
// extract tokens
TokenizerPosition end = tok.getPosition();
std::vector<Token> tokens = tok.getTokens(start, end);
size_t index = Tokenizer::addEquValue(tokens);
for (FileEntry& entry : entries)
entry.tokenizer->resetLookaheadCheckMarks();
// register equation
Global.symbolTable.addEquation(name, Global.FileInfo.FileNum, Global.Section, index);
}
示例2: parseString
CAssemblerCommand* Parser::parseString(const std::wstring& text)
{
TextFile file;
file.openMemory(text);
return parseFile(file,true);
}
示例3: runArmips
bool runArmips(ArmipsArguments& arguments)
{
// initialize and reset global data
Global.Radix = 10;
Global.Revalidate = true;
Global.Section = 0;
Global.nocash = false;
Global.IncludeNestingLevel = 0;
Global.MacroNestingLevel = 0;
Global.FileInfo.FileCount = 0;
Global.FileInfo.TotalLineCount = 0;
Global.DebugMessages = 0;
Global.relativeInclude = false;
Global.validationPasses = 0;
Global.multiThreading = true;
Arch = &InvalidArchitecture;
Tokenizer::clearEquValues();
Logger::clear();
Global.symData.clear();
Global.Table.clear();
Global.symbolTable.clear();
Global.tempData.clear();
Global.FileInfo.FileList.clear();
Global.FileInfo.FileCount = 0;
Global.FileInfo.TotalLineCount = 0;
Global.FileInfo.LineNumber = 0;
Global.FileInfo.FileNum = 0;
Arm.clear();
// process arguments
Parser parser;
Logger::setSilent(arguments.silent);
Logger::setErrorOnWarning(arguments.errorOnWarning);
if (!arguments.symFileName.empty())
Global.symData.setNocashSymFileName(arguments.symFileName,arguments.symFileVersion);
if (!arguments.tempFileName.empty())
Global.tempData.setFileName(arguments.tempFileName);
Token token;
for (size_t i = 0; i < arguments.equList.size(); i++)
{
parser.addEquation(token,arguments.equList[i].name, arguments.equList[i].value);
}
Global.symbolTable.addLabels(arguments.labels);
if (Logger::hasError())
return false;
// run assembler
TextFile input;
switch (arguments.mode)
{
case ArmipsMode::FILE:
Global.memoryMode = false;
if (input.open(arguments.inputFileName,TextFile::Read) == false)
{
Logger::printError(Logger::Error,L"Could not open file");
return false;
}
break;
case ArmipsMode::MEMORY:
Global.memoryMode = true;
Global.memoryFile = arguments.memoryFile;
input.openMemory(arguments.content);
break;
}
CAssemblerCommand* content = parser.parseFile(input);
bool result = !Logger::hasError();
if (result == true && content != nullptr)
result = encodeAssembly(content);
else if (g_fileManager->hasOpenFile())
{
if (!Global.memoryMode)
Logger::printError(Logger::Warning,L"File not closed");
g_fileManager->closeFile();
}
// return errors
if (arguments.errorsResult != NULL)
{
StringList errors = Logger::getErrors();
for (size_t i = 0; i < errors.size(); i++)
arguments.errorsResult->push_back(errors[i]);
}
return result;
}