Permalink
Browse files

Replace C-style NULL constant with C++11 nullptr

  • Loading branch information...
sp1187 committed May 23, 2018
1 parent 0450d1a commit 3adf53009db148fc6ba4334b8386a17fa7ac0241
@@ -249,5 +249,5 @@ const tArmOpcode ArmOpcodes[] = {
{ "qdsubC", "d1,m1,n1", 0x01600050, ARM_MISC, ARM_D|ARM_N|ARM_M|ARM_ARM9 },
{ "qdsubC", "d1,n1", 0x01600050, ARM_MISC, ARM_D|ARM_N|ARM_M|ARM_ARM9|ARM_DM },
{ NULL, NULL, 0, 0, 0}
{ nullptr, nullptr, 0, 0, 0 }
};
@@ -640,7 +640,7 @@ CArmInstruction* ArmParser::parseArmOpcode(Parser& parser)
bool paramFail = false;
const std::wstring stringValue = token.getStringValue();
for (int z = 0; ArmOpcodes[z].name != NULL; z++)
for (int z = 0; ArmOpcodes[z].name != nullptr; z++)
{
if ((ArmOpcodes[z].flags & ARM_ARM9) && Arm.getVersion() == AARCH_GBA)
continue;
@@ -737,7 +737,7 @@ CThumbInstruction* ArmParser::parseThumbOpcode(Parser& parser)
bool paramFail = false;
const std::wstring stringValue = token.getStringValue();
for (int z = 0; ThumbOpcodes[z].name != NULL; z++)
for (int z = 0; ThumbOpcodes[z].name != nullptr; z++)
{
if ((ThumbOpcodes[z].flags & THUMB_ARM9) && Arm.getVersion() == AARCH_GBA)
continue;
@@ -149,6 +149,6 @@ const tThumbOpcode ThumbOpcodes[] = {
{ "bl", "/#I\x16", 0xF800, THUMB_TYPE19, 4, THUMB_IMMEDIATE|THUMB_BRANCH|THUMB_LONG },
{ "blx", "/#I\x16", 0xF800, THUMB_TYPE19, 4, THUMB_IMMEDIATE|THUMB_ARM9|THUMB_EXCHANGE|THUMB_BRANCH|THUMB_LONG },
{ NULL, NULL, 0, 0, 0}
{ nullptr, nullptr, 0, 0, 0, 0 }
};
@@ -63,7 +63,7 @@ std::unique_ptr<IElfRelocator> CMipsArchitecture::getElfRelocator()
case MARCH_PSX:
case MARCH_RSP:
default:
return NULL;
return nullptr;
}
}
@@ -771,5 +771,5 @@ const MipsMacroDefinition mipsMacros[] = {
{ L"ror", L"d,s,t", &generateMipsMacroRotate, MIPSM_RIGHT },
{ L"ror", L"d,s,i", &generateMipsMacroRotate, MIPSM_RIGHT|MIPSM_IMM },
{ NULL, NULL, NULL, 0 }
{ nullptr, nullptr, nullptr, 0 }
};
@@ -1017,7 +1017,7 @@ const tMipsOpcode MipsOpcodes[] = {
{"stv", "RtRo,i7(s)", MIPS_RSP_SWC2(0x0b), MA_RSP, MO_RSP_QWOFFSET },
{"stv", "RtRo,(s)", MIPS_RSP_SWC2(0x0b), MA_RSP, MO_RSP_QWOFFSET },
// END
{ NULL, NULL, 0, 0 }
{ nullptr, nullptr, 0, 0 }
};
const MipsArchDefinition mipsArchs[] = {
@@ -1409,7 +1409,7 @@ CMipsInstruction* MipsParser::parseOpcode(Parser& parser)
const MipsArchDefinition& arch = mipsArchs[Mips.GetVersion()];
const std::wstring stringValue = token.getStringValue();
for (int z = 0; MipsOpcodes[z].name != NULL; z++)
for (int z = 0; MipsOpcodes[z].name != nullptr; z++)
{
if ((MipsOpcodes[z].archs & arch.supportSets) == 0)
continue;
@@ -1502,7 +1502,7 @@ CAssemblerCommand* MipsParser::parseMacro(Parser& parser)
parser.eatToken();
const std::wstring stringValue = token.getStringValue();
for (int z = 0; mipsMacros[z].name != NULL; z++)
for (int z = 0; mipsMacros[z].name != nullptr; z++)
{
if (stringValue == mipsMacros[z].name)
{
@@ -347,7 +347,7 @@ bool PsxRelocator::init(const std::wstring& inputName)
std::transform(lowered.begin(), lowered.end(), lowered.begin(), ::towlower);
sym.label = Global.symbolTable.getLabel(lowered,-1,-1);
if (sym.label == NULL)
if (sym.label == nullptr)
{
Logger::printError(Logger::Error,L"Invalid label name \"%s\"",sym.name);
continue;
@@ -8,13 +8,13 @@
CAssemblerLabel::CAssemblerLabel(const std::wstring& name, const std::wstring& originalName)
{
this->defined = false;
this->label = NULL;
this->label = nullptr;
if (Global.symbolTable.isLocalSymbol(name) == false)
updateSection(++Global.Section);
label = Global.symbolTable.getLabel(name, FileNum, getSection());
if (label == NULL)
if (label == nullptr)
{
Logger::printError(Logger::Error, L"Invalid label name \"%s\"", name);
return;
@@ -19,7 +19,7 @@ CDirectiveConditional::CDirectiveConditional(ConditionType type, const std::wstr
: CDirectiveConditional(type)
{
label = Global.symbolTable.getLabel(name,Global.FileInfo.FileNum,Global.Section);
if (label == NULL)
if (label == nullptr)
Logger::printError(Logger::Error,L"Invalid label name \"%s\"",name);
}
@@ -78,7 +78,7 @@ bool CDirectiveConditional::Validate()
ifBlock->applyFileInfo();
if (ifBlock->Validate())
returnValue = true;
} else if (elseBlock != NULL)
} else if (elseBlock != nullptr)
{
elseBlock->applyFileInfo();
if (elseBlock->Validate())
@@ -93,7 +93,7 @@ void CDirectiveConditional::Encode() const
if (previousResult)
{
ifBlock->Encode();
} else if (elseBlock != NULL)
} else if (elseBlock != nullptr)
{
elseBlock->Encode();
}
@@ -105,7 +105,7 @@ void CDirectiveConditional::writeTempData(TempData& tempData) const
{
ifBlock->applyFileInfo();
ifBlock->writeTempData(tempData);
} else if (elseBlock != NULL)
} else if (elseBlock != nullptr)
{
elseBlock->applyFileInfo();
elseBlock->writeTempData(tempData);
@@ -117,7 +117,7 @@ void CDirectiveConditional::writeSymData(SymbolData& symData) const
if (previousResult)
{
ifBlock->writeSymData(symData);
} else if (elseBlock != NULL)
} else if (elseBlock != nullptr)
{
elseBlock->writeSymData(symData);
}
@@ -196,7 +196,7 @@ bool runArmips(ArmipsArguments& arguments)
}
// return errors
if (arguments.errorsResult != NULL)
if (arguments.errorsResult != nullptr)
{
StringList errors = Logger::getErrors();
for (size_t i = 0; i < errors.size(); i++)
@@ -46,7 +46,7 @@ struct ArmipsArguments
mode = ArmipsMode::FILE;
errorOnWarning = false;
silent = false;
errorsResult = NULL;
errorsResult = nullptr;
}
};
@@ -492,7 +492,7 @@ void ExpressionInternal::replaceMemoryPos(const std::wstring& identifierName)
{
for (size_t i = 0; i < childrenCount; i++)
{
if (children[i] != NULL)
if (children[i] != nullptr)
{
children[i]->replaceMemoryPos(identifierName);
}
@@ -845,7 +845,7 @@ std::wstring ExpressionInternal::toString()
Expression::Expression()
{
expression = NULL;
expression = nullptr;
constExpression = true;
}
@@ -860,7 +860,7 @@ void Expression::setExpression(ExpressionInternal* exp, bool inUnknownOrFalseBlo
ExpressionValue Expression::evaluate()
{
if (expression == NULL)
if (expression == nullptr)
{
ExpressionValue invalid;
return invalid;
@@ -871,7 +871,7 @@ ExpressionValue Expression::evaluate()
void Expression::replaceMemoryPos(const std::wstring& identifierName)
{
if (expression != NULL)
if (expression != nullptr)
expression->replaceMemoryPos(identifierName);
}
@@ -134,8 +134,8 @@ class ExpressionInternal
ExpressionInternal(int64_t value);
ExpressionInternal(double value);
ExpressionInternal(const std::wstring& value, OperatorType type);
ExpressionInternal(OperatorType op, ExpressionInternal* a = NULL,
ExpressionInternal* b = NULL, ExpressionInternal* c = NULL);
ExpressionInternal(OperatorType op, ExpressionInternal* a = nullptr,
ExpressionInternal* b = nullptr, ExpressionInternal* c = nullptr);
ExpressionInternal(const std::wstring& name, const std::vector<ExpressionInternal*>& parameters);
ExpressionValue evaluate();
std::wstring toString();
@@ -171,15 +171,15 @@ class Expression
public:
Expression();
ExpressionValue evaluate();
bool isLoaded() const { return expression != NULL; }
bool isLoaded() const { return expression != nullptr; }
void setExpression(ExpressionInternal* exp, bool inUnknownOrFalseBlock);
void replaceMemoryPos(const std::wstring& identifierName);
bool isConstExpression() { return constExpression; }
template<typename T>
bool evaluateInteger(T& dest)
{
if (expression == NULL)
if (expression == nullptr)
return false;
ExpressionValue value = expression->evaluate();
@@ -192,7 +192,7 @@ class Expression
bool evaluateString(std::wstring& dest, bool convert)
{
if (expression == NULL)
if (expression == nullptr)
return false;
ExpressionValue value = expression->evaluate();
@@ -217,14 +217,14 @@ class Expression
bool evaluateIdentifier(std::wstring& dest)
{
if (expression == NULL || expression->isIdentifier() == false)
if (expression == nullptr || expression->isIdentifier() == false)
return false;
dest = expression->getStringValue();
return true;
}
std::wstring toString() { return expression != NULL ? expression->toString() : L""; };
std::wstring toString() { return expression != nullptr ? expression->toString() : L""; };
private:
std::shared_ptr<ExpressionInternal> expression;
std::wstring originalText;
@@ -229,13 +229,13 @@ FileManager::~FileManager()
void FileManager::reset()
{
activeFile = NULL;
activeFile = nullptr;
setEndianness(Endianness::Little);
}
bool FileManager::checkActiveFile()
{
if (activeFile == NULL)
if (activeFile == nullptr)
{
Logger::queueError(Logger::Error,L"No file opened");
return false;
@@ -245,7 +245,7 @@ bool FileManager::checkActiveFile()
bool FileManager::openFile(AssemblerFile* file, bool onlyCheck)
{
if (activeFile != NULL)
if (activeFile != nullptr)
{
Logger::queueError(Logger::Warning,L"File not closed before opening a new one");
activeFile->close();
@@ -262,14 +262,14 @@ void FileManager::addFile(AssemblerFile* file)
void FileManager::closeFile()
{
if (activeFile == NULL)
if (activeFile == nullptr)
{
Logger::queueError(Logger::Warning,L"No file opened");
return;
}
activeFile->close();
activeFile = NULL;
activeFile = nullptr;
}
bool FileManager::write(void* data, size_t length)
@@ -317,21 +317,21 @@ bool FileManager::writeU64(uint64_t data)
int64_t FileManager::getVirtualAddress()
{
if (activeFile == NULL)
if (activeFile == nullptr)
return -1;
return activeFile->getVirtualAddress();
}
int64_t FileManager::getPhysicalAddress()
{
if (activeFile == NULL)
if (activeFile == nullptr)
return -1;
return activeFile->getPhysicalAddress();
}
int64_t FileManager::getHeaderSize()
{
if (activeFile == NULL)
if (activeFile == nullptr)
return -1;
return activeFile->getHeaderSize();
}
@@ -67,7 +67,7 @@ class FileManager
void reset();
bool openFile(AssemblerFile* file, bool onlyCheck);
void addFile(AssemblerFile* file);
bool hasOpenFile() { return activeFile != NULL; };
bool hasOpenFile() { return activeFile != nullptr; };
void closeFile();
bool write(void* data, size_t length);
bool writeU8(uint8_t data);
@@ -20,7 +20,7 @@ void SymbolData::clear()
currentFunction = -1;
SymDataModule defaultModule;
defaultModule.file = NULL;
defaultModule.file = nullptr;
modules.push_back(defaultModule);
}
@@ -59,7 +59,7 @@ void SymbolTable::setFileSectionValues(const std::wstring& symbol, int& file, in
Label* SymbolTable::getLabel(const std::wstring& symbol, int file, int section)
{
if (isValidSymbolName(symbol) == false)
return NULL;
return nullptr;
int actualSection = section;
setFileSectionValues(symbol,file,section);
@@ -83,7 +83,7 @@ Label* SymbolTable::getLabel(const std::wstring& symbol, int file, int section)
// make sure not to match symbols that aren't labels
if (it->second.type != LabelSymbol)
return NULL;
return nullptr;
return labels[it->second.index];
}
@@ -121,7 +121,7 @@ bool SymbolTable::isValidSymbolName(const std::wstring& symbol)
for (size_t i = start; i < size; i++)
{
if (wcschr(validSymbolCharacters,symbol[i]) == NULL)
if (wcschr(validSymbolCharacters,symbol[i]) == nullptr)
return false;
}
@@ -187,7 +187,7 @@ void SymbolTable::addLabels(const std::vector<LabelDefinition>& labels)
continue;
Label* label = getLabel(def.name,Global.FileInfo.FileNum,Global.Section);
if (label == NULL)
if (label == nullptr)
continue;
if (isLocalSymbol(def.name) == false)
@@ -36,10 +36,10 @@ StringList TestRunner::listSubfolders(const std::wstring& dir)
std::string utf8 = convertWStringToUtf8(dir);
auto directory = opendir(utf8.c_str());
if (directory != NULL)
if (directory != nullptr)
{
auto elem = readdir(directory);
while (elem != NULL)
while (elem != nullptr)
{
#if defined(__HAIKU__)
// dirent in Posix does not have a d_type
@@ -15,7 +15,7 @@ static ExpressionInternal* primaryExpression(Tokenizer& tokenizer)
const Token &tok = tokenizer.peekToken();
if (tok.type == TokenType::Invalid)
return NULL;
return nullptr;
switch (tok.type)
{
Oops, something went wrong.

0 comments on commit 3adf530

Please sign in to comment.