Replaced all TRUE/FALSE macro usages with true/false booleans

This commit is contained in:
Artur K 2012-03-13 00:28:04 +01:00
parent d39449124a
commit 14b06c252e
20 changed files with 116 additions and 106 deletions

View File

@ -3,8 +3,13 @@
* (C) Cristina Cifuentes, Mike van Emmerik * (C) Cristina Cifuentes, Mike van Emmerik
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
//TODO: Remove boolT
#include <llvm/ADT/ilist.h> #include <llvm/ADT/ilist.h>
#include <utility>
#include <algorithm>
#include <bitset> #include <bitset>
#include "Enums.h" #include "Enums.h"
#include "types.h" #include "types.h"
#include "ast.h" #include "ast.h"

View File

@ -12,6 +12,7 @@
#include <llvm/CodeGen/MachineInstr.h> #include <llvm/CodeGen/MachineInstr.h>
#include <llvm/MC/MCInst.h> #include <llvm/MC/MCInst.h>
#include <llvm/MC/MCAsmInfo.h> #include <llvm/MC/MCAsmInfo.h>
#include <llvm/Value.h>
#include "Enums.h" #include "Enums.h"
#include "state.h" // State depends on INDEXBASE, but later need STATE #include "state.h" // State depends on INDEXBASE, but later need STATE
//enum condId; //enum condId;

View File

@ -3,6 +3,12 @@
* (C) Mike van Emmerik * (C) Mike van Emmerik
*/ */
#pragma once #pragma once
#include <string>
#include <stdint.h>
#include "Enums.h"
#include "types.h"
struct COND_EXPR;
struct TypeContainer;
/* * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * */
/* Symbol table structs and protos */ /* Symbol table structs and protos */
/* * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * */

View File

@ -151,7 +151,7 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
traversed = DFS_ALPHA; traversed = DFS_ALPHA;
/* Check for start of loop */ /* Check for start of loop */
repCond = FALSE; repCond = false;
latch = NULL; latch = NULL;
_loopType = loopType; _loopType = loopType;
if (_loopType) if (_loopType)
@ -204,7 +204,7 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
} }
/* Write the code for this basic block */ /* Write the code for this basic block */
if (repCond == FALSE) if (repCond == false)
writeBB (indLevel, pProc, numLoc); writeBB (indLevel, pProc, numLoc);
/* Check for end of path */ /* Check for end of path */
@ -272,7 +272,7 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
{ {
stats.numHLIcode++; stats.numHLIcode++;
indLevel++; indLevel++;
emptyThen = FALSE; emptyThen = false;
if (ifFollow != MAX) /* there is a follow */ if (ifFollow != MAX) /* there is a follow */
{ {

View File

@ -647,37 +647,37 @@ string walkCondExpr (const COND_EXPR* expr, Function * pProc, int* numLoc)
case NEGATION: case NEGATION:
if (expr->expr.unaryExp->type == IDENTIFIER) if (expr->expr.unaryExp->type == IDENTIFIER)
{ {
needBracket = FALSE; needBracket = false;
outStr << "!"; outStr << "!";
} }
else else
outStr << "! ("; outStr << "! (";
outStr << walkCondExpr (expr->expr.unaryExp, pProc, numLoc); outStr << walkCondExpr (expr->expr.unaryExp, pProc, numLoc);
if (needBracket == TRUE) if (needBracket == true)
outStr << ")"; outStr << ")";
break; break;
case ADDRESSOF: case ADDRESSOF:
if (expr->expr.unaryExp->type == IDENTIFIER) if (expr->expr.unaryExp->type == IDENTIFIER)
{ {
needBracket = FALSE; needBracket = false;
outStr << "&"; outStr << "&";
} }
else else
outStr << "&("; outStr << "&(";
outStr << walkCondExpr (expr->expr.unaryExp, pProc, numLoc); outStr << walkCondExpr (expr->expr.unaryExp, pProc, numLoc);
if (needBracket == TRUE) if (needBracket == true)
outStr << ")"; outStr << ")";
break; break;
case DEREFERENCE: case DEREFERENCE:
outStr << "*"; outStr << "*";
if (expr->expr.unaryExp->type == IDENTIFIER) if (expr->expr.unaryExp->type == IDENTIFIER)
needBracket = FALSE; needBracket = false;
else else
outStr << "("; outStr << "(";
outStr << walkCondExpr (expr->expr.unaryExp, pProc, numLoc); outStr << walkCondExpr (expr->expr.unaryExp, pProc, numLoc);
if (needBracket == TRUE) if (needBracket == true)
outStr << ")"; outStr << ")";
break; break;
@ -864,7 +864,7 @@ COND_EXPR *COND_EXPR::insertSubTreeReg (COND_EXPR *_expr, eReg regi,LOCAL_ID *lo
return _expr; return _expr;
} }
} }
return FALSE; return false;
case BOOLEAN_OP: case BOOLEAN_OP:
temp = lhs()->insertSubTreeReg( _expr, regi, locsym); temp = lhs()->insertSubTreeReg( _expr, regi, locsym);

View File

@ -309,7 +309,7 @@ void SetupLibCheck(void)
readProtoFile(); readProtoFile();
prog.bSigs = FALSE; /* False unless everything goes right */ prog.bSigs = false; /* False unless everything goes right */
/* Read the parameters */ /* Read the parameters */
grab(4, g_file); grab(4, g_file);
if (memcmp("dccs", buf, 4) != 0) if (memcmp("dccs", buf, 4) != 0)
@ -419,7 +419,7 @@ void SetupLibCheck(void)
} }
} }
fclose(g_file); fclose(g_file);
prog.bSigs = TRUE; prog.bSigs = true;
} }
@ -431,7 +431,7 @@ void CleanupLibCheck(void)
} }
/* Check this function to see if it is a library function. Return TRUE if /* Check this function to see if it is a library function. Return true if
it is, and copy its name to pProc->name it is, and copy its name to pProc->name
*/ */
bool LibCheck(Function & pProc) bool LibCheck(Function & pProc)
@ -441,11 +441,11 @@ bool LibCheck(Function & pProc)
int Idx; int Idx;
uint8_t pat[PATLEN]; uint8_t pat[PATLEN];
if (prog.bSigs == FALSE) if (prog.bSigs == false)
{ {
/* No signatures... can't rely on hash parameters to be initialised /* No signatures... can't rely on hash parameters to be initialised
so always return false */ so always return false */
return FALSE; return false;
} }
fileOffset = pProc.procEntry; /* Offset into the image */ fileOffset = pProc.procEntry; /* Offset into the image */

View File

@ -494,10 +494,10 @@ void Function::compoundCond()
ICODE * picode, * ticode; ICODE * picode, * ticode;
boolT change; boolT change;
change = TRUE; change = true;
while (change) while (change)
{ {
change = FALSE; change = false;
/* Traverse nodes in postorder, this way, the header node of a /* Traverse nodes in postorder, this way, the header node of a
* compound condition is analysed first */ * compound condition is analysed first */
@ -584,7 +584,7 @@ void Function::compoundCond()
else else
i--; /* to repeat this analysis */ i--; /* to repeat this analysis */
change = TRUE; change = true;
} }
/* Check (X && Y) case */ /* Check (X && Y) case */
@ -616,7 +616,7 @@ void Function::compoundCond()
else else
i--; /* to repeat this analysis */ i--; /* to repeat this analysis */
change = TRUE; change = true;
} }
/* Check (!X || Y) case */ /* Check (!X || Y) case */
@ -654,7 +654,7 @@ void Function::compoundCond()
else else
i--; /* to repeat this analysis */ i--; /* to repeat this analysis */
change = TRUE; change = true;
} }
} }
} }

View File

@ -636,7 +636,7 @@ bool COND_EXPR::xClear (iICODE f, iICODE t, iICODE lastBBinst, Function * pproc)
if(0==rhs()) if(0==rhs())
return false; return false;
res = rhs()->xClear ( f, t, lastBBinst, pproc); res = rhs()->xClear ( f, t, lastBBinst, pproc);
if (res == FALSE) if (res == false)
return false; return false;
if(0==lhs()) if(0==lhs())
return false; return false;
@ -783,7 +783,7 @@ void Function::processHliCall(COND_EXPR *_exp, iICODE picode)
pp->args.adjustForArgType (numArgs,expType (_exp, this)); pp->args.adjustForArgType (numArgs,expType (_exp, this));
res = picode->newStkArg (_exp,(llIcode)picode->ll()->getOpcode(), this); res = picode->newStkArg (_exp,(llIcode)picode->ll()->getOpcode(), this);
} }
if (res == FALSE) if (res == false)
k += hlTypeSize (_exp, this); k += hlTypeSize (_exp, this);
numArgs++; numArgs++;
} }

View File

@ -241,7 +241,7 @@ void Disassembler::disassem(Function * ppProc)
destroySymTables(); destroySymTables();
} }
/**************************************************************************** /****************************************************************************
* dis1Line() - disassemble one line to stream fp * * * dis1Line() - disassemble one line to stream fp *
* i is index into Icode for this proc * * i is index into Icode for this proc *
* It is assumed that icode i is already scanned * * It is assumed that icode i is already scanned *
****************************************************************************/ ****************************************************************************/
@ -511,7 +511,7 @@ void Disassembler::dis1Line(LLInst &inst,int loc_ip, int pass)
/* Comments */ /* Comments */
if (inst.testFlags(SYNTHETIC)) if (inst.testFlags(SYNTHETIC))
{ {
fImpure = FALSE; fImpure = false;
} }
else else
{ {

View File

@ -18,8 +18,6 @@
#ifndef bool #ifndef bool
#define bool unsigned char #define bool unsigned char
#define TRUE 1
#define FALSE 0
#define uint8_t unsigned char #define uint8_t unsigned char
#endif #endif
@ -39,7 +37,7 @@ static bool ModRM(uint8_t pat[])
/* A standard mod/rm uint8_t follows opcode */ /* A standard mod/rm uint8_t follows opcode */
op = pat[pc++]; /* The mod/rm uint8_t */ op = pat[pc++]; /* The mod/rm uint8_t */
if (pc >= PATLEN) return TRUE; /* Skip Mod/RM */ if (pc >= PATLEN) return true; /* Skip Mod/RM */
switch (op & 0xC0) switch (op & 0xC0)
{ {
case 0x00: /* [reg] or [nnnn] */ case 0x00: /* [reg] or [nnnn] */
@ -47,26 +45,26 @@ static bool ModRM(uint8_t pat[])
{ {
/* Uses [nnnn] address mode */ /* Uses [nnnn] address mode */
pat[pc++] = WILD; pat[pc++] = WILD;
if (pc >= PATLEN) return TRUE; if (pc >= PATLEN) return true;
pat[pc++] = WILD; pat[pc++] = WILD;
if (pc >= PATLEN) return TRUE; if (pc >= PATLEN) return true;
} }
break; break;
case 0x40: /* [reg + nn] */ case 0x40: /* [reg + nn] */
if ((pc+=1) >= PATLEN) return TRUE; if ((pc+=1) >= PATLEN) return true;
break; break;
case 0x80: /* [reg + nnnn] */ case 0x80: /* [reg + nnnn] */
/* Possibly just a long constant offset from a register, /* Possibly just a long constant offset from a register,
but often will be an index from a variable */ but often will be an index from a variable */
pat[pc++] = WILD; pat[pc++] = WILD;
if (pc >= PATLEN) return TRUE; if (pc >= PATLEN) return true;
pat[pc++] = WILD; pat[pc++] = WILD;
if (pc >= PATLEN) return TRUE; if (pc >= PATLEN) return true;
break; break;
case 0xC0: /* reg */ case 0xC0: /* reg */
break; break;
} }
return FALSE; return false;
} }
/* Change the next two bytes to wild cards */ /* Change the next two bytes to wild cards */
@ -74,10 +72,10 @@ static bool
TwoWild(uint8_t pat[]) TwoWild(uint8_t pat[])
{ {
pat[pc++] = WILD; pat[pc++] = WILD;
if (pc >= PATLEN) return TRUE; /* Pattern exhausted */ if (pc >= PATLEN) return true; /* Pattern exhausted */
pat[pc++] = WILD; pat[pc++] = WILD;
if (pc >= PATLEN) return TRUE; if (pc >= PATLEN) return true;
return FALSE; return false;
} }
/* Change the next four bytes to wild cards */ /* Change the next four bytes to wild cards */
@ -105,7 +103,7 @@ static bool op0F(uint8_t pat[])
{ {
case 0x00: /* 00 - 0F */ case 0x00: /* 00 - 0F */
if (op >= 0x06) /* Clts, Invd, Wbinvd */ if (op >= 0x06) /* Clts, Invd, Wbinvd */
return FALSE; return false;
else else
{ {
/* Grp 6, Grp 7, LAR, LSL */ /* Grp 6, Grp 7, LAR, LSL */
@ -116,7 +114,7 @@ static bool op0F(uint8_t pat[])
case 0x80: case 0x80:
pc += 2; /* uint16_t displacement cond jumps */ pc += 2; /* uint16_t displacement cond jumps */
return FALSE; return false;
case 0x90: /* uint8_t set on condition */ case 0x90: /* uint8_t set on condition */
return ModRM(pat); return ModRM(pat);
@ -128,7 +126,7 @@ static bool op0F(uint8_t pat[])
case 0xA1: /* Pop FS */ case 0xA1: /* Pop FS */
case 0xA8: /* Push GS */ case 0xA8: /* Push GS */
case 0xA9: /* Pop GS */ case 0xA9: /* Pop GS */
return FALSE; return false;
case 0xA3: /* Bt Ev,Gv */ case 0xA3: /* Bt Ev,Gv */
case 0xAB: /* Bts Ev,Gv */ case 0xAB: /* Bts Ev,Gv */
@ -136,9 +134,9 @@ static bool op0F(uint8_t pat[])
case 0xA4: /* Shld EvGbIb */ case 0xA4: /* Shld EvGbIb */
case 0xAC: /* Shrd EvGbIb */ case 0xAC: /* Shrd EvGbIb */
if (ModRM(pat)) return TRUE; if (ModRM(pat)) return true;
pc++; /* The #num bits to shift */ pc++; /* The #num bits to shift */
return FALSE; return false;
case 0xA5: /* Shld EvGb CL */ case 0xA5: /* Shld EvGb CL */
case 0xAD: /* Shrd EvGb CL */ case 0xAD: /* Shrd EvGb CL */
@ -152,9 +150,9 @@ static bool op0F(uint8_t pat[])
if (op == 0xBA) if (op == 0xBA)
{ {
/* Grp 8: bt/bts/btr/btc Ev,#nn */ /* Grp 8: bt/bts/btr/btc Ev,#nn */
if (ModRM(pat)) return TRUE; if (ModRM(pat)) return true;
pc++; /* The #num bits to shift */ pc++; /* The #num bits to shift */
return FALSE; return false;
} }
return ModRM(pat); return ModRM(pat);
@ -165,10 +163,10 @@ static bool op0F(uint8_t pat[])
return ModRM(pat); return ModRM(pat);
} }
/* Else BSWAP */ /* Else BSWAP */
return FALSE; return false;
default: default:
return FALSE; /* Treat as double uint8_t opcodes */ return false; /* Treat as double uint8_t opcodes */
} }

View File

@ -80,7 +80,7 @@ CondJumps:
pBB = BB::Create(start, ip, MULTI_BRANCH, ll->caseTbl.numEntries, this); pBB = BB::Create(start, ip, MULTI_BRANCH, ll->caseTbl.numEntries, this);
for (i = 0; i < ll->caseTbl.numEntries; i++) for (i = 0; i < ll->caseTbl.numEntries; i++)
pBB->edges[i].ip = ll->caseTbl.entries[i]; pBB->edges[i].ip = ll->caseTbl.entries[i];
hasCase = TRUE; hasCase = true;
} }
else if ((ll->getFlag() & (I | NO_LABEL)) == I) //TODO: WHY NO_LABEL TESTIT else if ((ll->getFlag() & (I | NO_LABEL)) == I) //TODO: WHY NO_LABEL TESTIT
{ {
@ -285,7 +285,7 @@ BB *BB::rmJMP(int marker, BB * pBB)
else else
{ {
pBB->front().ll()->setFlags(NO_CODE); pBB->front().ll()->setFlags(NO_CODE);
pBB->front().invalidate(); //pProc->Icode.SetLlInvalid(pBB->begin(), TRUE); pBB->front().invalidate(); //pProc->Icode.SetLlInvalid(pBB->begin(), true);
} }
pBB = pBB->edges[0].BBptr; pBB = pBB->edges[0].BBptr;
@ -304,7 +304,7 @@ BB *BB::rmJMP(int marker, BB * pBB)
pBB->front().ll()->setFlags(NO_CODE); pBB->front().ll()->setFlags(NO_CODE);
pBB->front().invalidate(); pBB->front().invalidate();
// pProc->Icode.setFlags(pBB->start, NO_CODE); // pProc->Icode.setFlags(pBB->start, NO_CODE);
// pProc->Icode.SetLlInvalid(pBB->start, TRUE); // pProc->Icode.SetLlInvalid(pBB->start, true);
} }
} while (pBB->nodeType != NOWHERE_NODE); } while (pBB->nodeType != NOWHERE_NODE);

View File

@ -74,7 +74,7 @@ void ICODE::setJCond(COND_EXPR *cexp)
} }
/* Sets the invalid field to TRUE as this low-level icode is no longer valid, /* Sets the invalid field to true as this low-level icode is no longer valid,
* it has been replaced by a high-level icode. */ * it has been replaced by a high-level icode. */
void ICODE ::invalidate() void ICODE ::invalidate()
{ {

View File

@ -18,7 +18,7 @@
#include <llvm/Support/PatternMatch.h> #include <llvm/Support/PatternMatch.h>
#include <boost/iterator/filter_iterator.hpp> #include <boost/iterator/filter_iterator.hpp>
/***************************************************************************** /*****************************************************************************
* JmpInst - Returns TRUE if opcode is a conditional or unconditional jump * JmpInst - Returns true if opcode is a conditional or unconditional jump
****************************************************************************/ ****************************************************************************/
bool LLInst::isJmpInst() bool LLInst::isJmpInst()
{ {

View File

@ -432,15 +432,15 @@ void LOCAL_ID::propLongId (uint8_t regL, uint8_t regH, const char *name)
{ {
strcpy (_id->name, name); strcpy (_id->name, name);
strcpy (_id->macro, "LO"); strcpy (_id->macro, "LO");
_id->hasMacro = TRUE; _id->hasMacro = true;
_id->illegal = TRUE; _id->illegal = true;
} }
else if (_id->id.regi == regH) else if (_id->id.regi == regH)
{ {
strcpy (_id->name, name); strcpy (_id->name, name);
strcpy (_id->macro, "HI"); strcpy (_id->macro, "HI");
_id->hasMacro = TRUE; _id->hasMacro = true;
_id->illegal = TRUE; _id->illegal = true;
} }
} }
} }

View File

@ -122,14 +122,14 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
SYM * psym; SYM * psym;
uint32_t offset; uint32_t offset;
eErrorId err; eErrorId err;
boolT done = FALSE; boolT done = false;
if (name.find("chkstk") != string::npos) if (name.find("chkstk") != string::npos)
{ {
// Danger! Dcc will likely fall over in this code. // Danger! Dcc will likely fall over in this code.
// So we act as though we have done with this proc // So we act as though we have done with this proc
// pProc->flg &= ~TERMINATES; // Not sure about this // pProc->flg &= ~TERMINATES; // Not sure about this
done = TRUE; done = true;
// And mark it as a library function, so structure() won't choke on it // And mark it as a library function, so structure() won't choke on it
flg |= PROC_ISLIB; flg |= PROC_ISLIB;
return; return;
@ -252,7 +252,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
{ STATE StCopy; { STATE StCopy;
int ip = Icode.size()-1; /* Index of this jump */ int ip = Icode.size()-1; /* Index of this jump */
ICODE &prev(Icode.back()); /* Previous icode */ ICODE &prev(Icode.back()); /* Previous icode */
boolT fBranch = FALSE; boolT fBranch = false;
pstate->JCond.regi = 0; pstate->JCond.regi = 0;
@ -286,7 +286,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
/*** Jumps ***/ /*** Jumps ***/
case iJMP: case iJMP:
case iJMPF: /* Returns TRUE if we've run into a loop */ case iJMPF: /* Returns true if we've run into a loop */
done = process_JMP (*pIcode, pstate, pcallGraph); done = process_JMP (*pIcode, pstate, pcallGraph);
break; break;
@ -305,7 +305,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
/* Fall through */ /* Fall through */
case iIRET: case iIRET:
this->flg &= ~TERMINATES; this->flg &= ~TERMINATES;
done = TRUE; done = true;
break; break;
case iINT: case iINT:
@ -397,7 +397,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
} }
/* process_JMP - Handles JMPs, returns TRUE if we should end recursion */ /* process_JMP - Handles JMPs, returns true if we should end recursion */
boolT Function::process_JMP (ICODE & pIcode, STATE *pstate, CALL_GRAPH * pcallGraph) boolT Function::process_JMP (ICODE & pIcode, STATE *pstate, CALL_GRAPH * pcallGraph)
{ {
static uint8_t i2r[4] = {rSI, rDI, rBP, rBX}; static uint8_t i2r[4] = {rSI, rDI, rBP, rBX};
@ -416,7 +416,7 @@ boolT Function::process_JMP (ICODE & pIcode, STATE *pstate, CALL_GRAPH * pcallGr
exit(1); exit(1);
} }
/* Return TRUE if jump target is already parsed */ /* Return true if jump target is already parsed */
return Icode.labelSrch(i, tmp); return Icode.labelSrch(i, tmp);
} }
@ -486,7 +486,7 @@ boolT Function::process_JMP (ICODE & pIcode, STATE *pstate, CALL_GRAPH * pcallGr
pIcode.ll()->setFlags(SWITCH); pIcode.ll()->setFlags(SWITCH);
pIcode.ll()->caseTbl.numEntries = (endTable - offTable) / 2; pIcode.ll()->caseTbl.numEntries = (endTable - offTable) / 2;
assert(pIcode.ll()->caseTbl.numEntries<512); assert(pIcode.ll()->caseTbl.numEntries<512);
psw = (uint32_t*)allocMem(pIcode.ll()->caseTbl.numEntries*sizeof(uint32_t)); psw = new uint32_t [pIcode.ll()->caseTbl.numEntries];
pIcode.ll()->caseTbl.entries = psw; pIcode.ll()->caseTbl.entries = psw;
for (i = offTable, k = 0; i < endTable; i += 2) for (i = offTable, k = 0; i < endTable; i += 2)
@ -503,7 +503,7 @@ boolT Function::process_JMP (ICODE & pIcode, STATE *pstate, CALL_GRAPH * pcallGr
*psw++ = last_current_insn->ll()->GetLlLabel(); *psw++ = last_current_insn->ll()->GetLlLabel();
} }
return TRUE; return true;
} }
} }
@ -512,13 +512,13 @@ boolT Function::process_JMP (ICODE & pIcode, STATE *pstate, CALL_GRAPH * pcallGr
flg |= PROC_IJMP; flg |= PROC_IJMP;
flg &= ~TERMINATES; flg &= ~TERMINATES;
interactDis(this, this->Icode.size()-1); interactDis(this, this->Icode.size()-1);
return TRUE; return true;
} }
/* Process procedure call. /* Process procedure call.
* Note: We assume that CALL's will return unless there is good evidence to * Note: We assume that CALL's will return unless there is good evidence to
* the contrary - thus we return FALSE unless all paths in the called * the contrary - thus we return false unless all paths in the called
* procedure end in DOS exits. This is reasonable since C procedures * procedure end in DOS exits. This is reasonable since C procedures
* will always include the epilogue after the call anyway and it's to * will always include the epilogue after the call anyway and it's to
* be assumed that if an assembler program contains a CALL that the * be assumed that if an assembler program contains a CALL that the
@ -533,7 +533,7 @@ boolT Function::process_CALL (ICODE & pIcode, CALL_GRAPH * pcallGraph, STATE *ps
boolT indirect; boolT indirect;
/* For Indirect Calls, find the function address */ /* For Indirect Calls, find the function address */
indirect = FALSE; indirect = false;
//pIcode.ll()->immed.proc.proc=fakeproc; //pIcode.ll()->immed.proc.proc=fakeproc;
if ( not pIcode.ll()->testFlags(I) ) if ( not pIcode.ll()->testFlags(I) )
{ {
@ -863,19 +863,19 @@ void STATE::setState(uint16_t reg, int16_t value)
{ {
value &= 0xFFFF; value &= 0xFFFF;
r[reg] = value; r[reg] = value;
f[reg] = TRUE; f[reg] = true;
switch (reg) { switch (reg) {
case rAX: case rCX: case rDX: case rBX: case rAX: case rCX: case rDX: case rBX:
r[reg + rAL - rAX] = value & 0xFF; r[reg + rAL - rAX] = value & 0xFF;
f[reg + rAL - rAX] = TRUE; f[reg + rAL - rAX] = true;
r[reg + rAH - rAX] = (value >> 8) & 0xFF; r[reg + rAH - rAX] = (value >> 8) & 0xFF;
f[reg + rAH - rAX] = TRUE; f[reg + rAH - rAX] = true;
break; break;
case rAL: case rCL: case rDL: case rBL: case rAL: case rCL: case rDL: case rBL:
if (f[reg - rAL + rAH]) { if (f[reg - rAL + rAH]) {
r[reg - rAL + rAX] =(r[reg - rAL + rAH] << 8) + (value & 0xFF); r[reg - rAL + rAX] =(r[reg - rAL + rAH] << 8) + (value & 0xFF);
f[reg - rAL + rAX] = TRUE; f[reg - rAL + rAX] = true;
} }
break; break;
@ -883,7 +883,7 @@ void STATE::setState(uint16_t reg, int16_t value)
if (f[reg - rAH + rAL]) if (f[reg - rAH + rAL])
{ {
r[reg - rAH + rAX] = r[reg - rAH + rAL] + ((value & 0xFF) << 8); r[reg - rAH + rAX] = r[reg - rAH + rAL] + ((value & 0xFF) << 8);
f[reg - rAH + rAX] = TRUE; f[reg - rAH + rAX] = true;
} }
break; break;
} }
@ -1233,6 +1233,6 @@ void Function::process_operands(ICODE & pIcode, STATE * pstate)
for (i = rSP; i <= rBH; i++) /* Kill all defined registers */ for (i = rSP; i <= rBH; i++) /* Kill all defined registers */
if (pIcode.ll()->flagDU.d & (1 << i)) if (pIcode.ll()->flagDU.d & (1 << i))
pstate->f[i] = FALSE; pstate->f[i] = false;
} }

View File

@ -131,7 +131,7 @@ void Function::newRegArg(iICODE picode, iICODE ticode)
} }
/* Check if register argument already on the formal argument list */ /* Check if register argument already on the formal argument list */
regExist = FALSE; regExist = false;
for (i = 0; i < ts->sym.size(); i++) for (i = 0; i < ts->sym.size(); i++)
{ {
if (type == REGISTER) if (type == REGISTER)
@ -139,7 +139,7 @@ void Function::newRegArg(iICODE picode, iICODE ticode)
if ((ts->sym[i].regs != NULL) && if ((ts->sym[i].regs != NULL) &&
(ts->sym[i].regs->expr.ident.idNode.regiIdx == tidx)) (ts->sym[i].regs->expr.ident.idNode.regiIdx == tidx))
{ {
regExist = TRUE; regExist = true;
i = ts->sym.size(); i = ts->sym.size();
} }
} }
@ -148,14 +148,14 @@ void Function::newRegArg(iICODE picode, iICODE ticode)
if ((ts->sym[i].regs != NULL) && if ((ts->sym[i].regs != NULL) &&
(ts->sym[i].regs->expr.ident.idNode.longIdx == tidx)) (ts->sym[i].regs->expr.ident.idNode.longIdx == tidx))
{ {
regExist = TRUE; regExist = true;
i = ts->sym.size(); i = ts->sym.size();
} }
} }
} }
/* Do ts (formal arguments) */ /* Do ts (formal arguments) */
if (regExist == FALSE) if (regExist == false)
{ {
STKSYM newsym; STKSYM newsym;
sprintf (newsym.name, "arg%ld", ts->sym.size()); sprintf (newsym.name, "arg%ld", ts->sym.size());
@ -366,10 +366,10 @@ void STKFRAME::adjustForArgType(int numArg_, hlType actType_)
nsym = psym + 1; nsym = psym + 1;
sprintf (nsym->macro, "HI"); sprintf (nsym->macro, "HI");
sprintf (psym->macro, "LO"); sprintf (psym->macro, "LO");
nsym->hasMacro = TRUE; nsym->hasMacro = true;
psym->hasMacro = TRUE; psym->hasMacro = true;
sprintf (nsym->name, "%s", psym->name); sprintf (nsym->name, "%s", psym->name);
nsym->invalid = TRUE; nsym->invalid = true;
numArgs--; numArgs--;
} }
break; break;

View File

@ -248,7 +248,7 @@ void Function::propLongStk (int i, const ID &pLocId)
continue; continue;
if (pIcode->ll()->getOpcode() == next1->ll()->getOpcode()) if (pIcode->ll()->getOpcode() == next1->ll()->getOpcode())
{ {
if (checkLongEq (pLocId.id.longStkId, pIcode, i, this, asgn, next1) == TRUE) if (checkLongEq (pLocId.id.longStkId, pIcode, i, this, asgn, next1) == true)
{ {
switch (pIcode->ll()->getOpcode()) switch (pIcode->ll()->getOpcode())
{ {

View File

@ -105,10 +105,10 @@ void derSeq_Entry::findIntervals (Function *c)
*succ; /* Successor basic block */ *succ; /* Successor basic block */
int i; /* Counter */ int i; /* Counter */
queue H; /* Queue of possible header nodes */ queue H; /* Queue of possible header nodes */
boolT first = TRUE; /* First pass through the loop */ boolT first = true; /* First pass through the loop */
appendQueue (H, Gi); /* H = {first node of G} */ appendQueue (H, Gi); /* H = {first node of G} */
Gi->beenOnH = TRUE; Gi->beenOnH = true;
Gi->reachingInt = BB::Create(0,"",c); /* ^ empty BB */ Gi->reachingInt = BB::Create(0,"",c); /* ^ empty BB */
/* Process header nodes list H */ /* Process header nodes list H */
@ -138,7 +138,7 @@ void derSeq_Entry::findIntervals (Function *c)
else if (! succ->beenOnH) /* out edge */ else if (! succ->beenOnH) /* out edge */
{ {
appendQueue (H, succ); appendQueue (H, succ);
succ->beenOnH = TRUE; succ->beenOnH = true;
pI->numOutEdges++; pI->numOutEdges++;
} }
} }
@ -250,7 +250,7 @@ bool Function::nextOrderGraph (derSeq &derivedGi)
derivedGi.push_back(derSeq_Entry()); derivedGi.push_back(derSeq_Entry());
derSeq_Entry &new_entry(derivedGi.back()); derSeq_Entry &new_entry(derivedGi.back());
Ii = prev_entry.Ii; Ii = prev_entry.Ii;
sameGraph = TRUE; sameGraph = true;
BBnode = 0; BBnode = 0;
std::vector<BB *> bbs; std::vector<BB *> bbs;
while (Ii) while (Ii)
@ -263,7 +263,7 @@ bool Function::nextOrderGraph (derSeq &derivedGi)
/* Check for more than 1 interval */ /* Check for more than 1 interval */
if (sameGraph && (listIi.size()>1)) if (sameGraph && (listIi.size()>1))
sameGraph = FALSE; sameGraph = false;
/* Find out edges */ /* Find out edges */
@ -335,10 +335,10 @@ uint8_t Function::findDerivedSeq (derSeq &derivedGi)
derivedGi.erase(iter,derivedGi.end()); /* remove Gi+1 */ derivedGi.erase(iter,derivedGi.end()); /* remove Gi+1 */
// freeDerivedSeq(derivedGi->next); // freeDerivedSeq(derivedGi->next);
// derivedGi->next = NULL; // derivedGi->next = NULL;
return FALSE; return false;
} }
derivedGi.back().findIntervals (this); derivedGi.back().findIntervals (this);
return TRUE; return true;
} }
/* Converts the irreducible graph G into an equivalent reducible one, by /* Converts the irreducible graph G into an equivalent reducible one, by

View File

@ -365,7 +365,7 @@ eErrorId scan(uint32_t ip, ICODE &p)
/*************************************************************************** /***************************************************************************
relocItem - returns TRUE if uint16_t pointed at is in relocation table relocItem - returns true if uint16_t pointed at is in relocation table
**************************************************************************/ **************************************************************************/
static boolT relocItem(uint8_t *p) static boolT relocItem(uint8_t *p)
{ {
@ -374,8 +374,8 @@ static boolT relocItem(uint8_t *p)
for (i = 0; i < prog.cReloc; i++) for (i = 0; i < prog.cReloc; i++)
if (prog.relocTable[i] == off) if (prog.relocTable[i] == off)
return TRUE; return true;
return FALSE; return false;
} }
@ -402,8 +402,8 @@ static int signex(uint8_t b)
/**************************************************************************** /****************************************************************************
* setAddress - Updates the source or destination field for the current * setAddress - Updates the source or destination field for the current
* icode, based on fdst and the TO_REG flag. * icode, based on fdst and the TO_REG flag.
* Note: fdst == TRUE is for the r/m part of the field (dest, unless TO_REG) * Note: fdst == true is for the r/m part of the field (dest, unless TO_REG)
* fdst == FALSE is for reg part of the field * fdst == false is for reg part of the field
***************************************************************************/ ***************************************************************************/
static void setAddress(int i, boolT fdst, uint16_t seg, int16_t reg, uint16_t off) static void setAddress(int i, boolT fdst, uint16_t seg, int16_t reg, uint16_t off)
{ {
@ -458,24 +458,24 @@ static void rm(int i)
switch (mod) { switch (mod) {
case 0: /* No disp unless rm == 6 */ case 0: /* No disp unless rm == 6 */
if (rm == 6) { if (rm == 6) {
setAddress(i, TRUE, SegPrefix, 0, getWord()); setAddress(i, true, SegPrefix, 0, getWord());
pIcode->ll()->setFlags(WORD_OFF); pIcode->ll()->setFlags(WORD_OFF);
} }
else else
setAddress(i, TRUE, SegPrefix, rm + INDEX_BX_SI, 0); setAddress(i, true, SegPrefix, rm + INDEX_BX_SI, 0);
break; break;
case 1: /* 1 uint8_t disp */ case 1: /* 1 uint8_t disp */
setAddress(i, TRUE, SegPrefix, rm+INDEX_BX_SI, (uint16_t)signex(*pInst++)); setAddress(i, true, SegPrefix, rm+INDEX_BX_SI, (uint16_t)signex(*pInst++));
break; break;
case 2: /* 2 uint8_t disp */ case 2: /* 2 uint8_t disp */
setAddress(i, TRUE, SegPrefix, rm + INDEX_BX_SI, getWord()); setAddress(i, true, SegPrefix, rm + INDEX_BX_SI, getWord());
pIcode->ll()->setFlags(WORD_OFF); pIcode->ll()->setFlags(WORD_OFF);
break; break;
case 3: /* reg */ case 3: /* reg */
setAddress(i, TRUE, 0, rm + rAX, 0); setAddress(i, true, 0, rm + rAX, 0);
break; break;
} }
@ -490,7 +490,7 @@ static void rm(int i)
***************************************************************************/ ***************************************************************************/
static void modrm(int i) static void modrm(int i)
{ {
setAddress(i, FALSE, 0, REG(*pInst) + rAX, 0); setAddress(i, false, 0, REG(*pInst) + rAX, 0);
rm(i); rm(i);
} }
@ -505,7 +505,7 @@ static void segrm(int i)
if (reg > rDS || (reg == rCS && (stateTable[i].flg & TO_REG))) if (reg > rDS || (reg == rCS && (stateTable[i].flg & TO_REG)))
pIcode->ll()->setOpcode((llIcode)0); // setCBW because it has that index pIcode->ll()->setOpcode((llIcode)0); // setCBW because it has that index
else { else {
setAddress(i, FALSE, 0, (int16_t)reg, 0); setAddress(i, false, 0, (int16_t)reg, 0);
rm(i); rm(i);
} }
} }
@ -516,7 +516,7 @@ static void segrm(int i)
***************************************************************************/ ***************************************************************************/
static void regop(int i) static void regop(int i)
{ {
setAddress(i, FALSE, 0, ((int16_t)i & 7) + rAX, 0); setAddress(i, false, 0, ((int16_t)i & 7) + rAX, 0);
pIcode->ll()->dst.regi = pIcode->ll()->src.regi; pIcode->ll()->dst.regi = pIcode->ll()->src.regi;
} }
@ -526,7 +526,7 @@ static void regop(int i)
*****************************************************************************/ *****************************************************************************/
static void segop(int i) static void segop(int i)
{ {
setAddress(i, TRUE, 0, (((int16_t)i & 0x18) >> 3) + rES, 0); setAddress(i, true, 0, (((int16_t)i & 0x18) >> 3) + rES, 0);
} }
@ -535,7 +535,7 @@ static void segop(int i)
***************************************************************************/ ***************************************************************************/
static void axImp(int i) static void axImp(int i)
{ {
setAddress(i, TRUE, 0, rAX, 0); setAddress(i, true, 0, rAX, 0);
} }
/* Implied AX source */ /* Implied AX source */
@ -556,7 +556,7 @@ static void alImp (int )
****************************************************************************/ ****************************************************************************/
static void memImp(int i) static void memImp(int i)
{ {
setAddress(i, FALSE, SegPrefix, 0, 0); setAddress(i, false, SegPrefix, 0, 0);
} }
@ -674,7 +674,7 @@ static void arith(int i)
else if (!(opcode == iNOT || opcode == iNEG)) else if (!(opcode == iNOT || opcode == iNEG))
{ {
pIcode->ll()->src = pIcode->ll()->dst; pIcode->ll()->src = pIcode->ll()->dst;
setAddress(i, TRUE, 0, rAX, 0); /* dst = AX */ setAddress(i, true, 0, rAX, 0); /* dst = AX */
} }
else if (opcode == iNEG || opcode == iNOT) else if (opcode == iNEG || opcode == iNOT)
pIcode->ll()->setFlags(NO_SRC); pIcode->ll()->setFlags(NO_SRC);
@ -727,7 +727,7 @@ static void data2(int )
****************************************************************************/ ****************************************************************************/
static void dispM(int i) static void dispM(int i)
{ {
setAddress(i, FALSE, SegPrefix, 0, getWord()); setAddress(i, false, SegPrefix, 0, getWord());
} }

View File

@ -106,7 +106,7 @@ void createSymTables(void)
/* Now the string table */ /* Now the string table */
strTabNext = 0; strTabNext = 0;
pStrTab = (char *)allocMem(STRTABSIZE); pStrTab = new char[STRTABSIZE];
curTableType = Label; curTableType = Label;