Skip to content

Commit

Permalink
Merge pull request #4249 from yebblies/moremorebool
Browse files Browse the repository at this point in the history
[cleanup] [trivial] Change more functions to return bool
  • Loading branch information
AndrejMitrovic committed Jan 4, 2015
2 parents acd0754 + aa2f22d commit d9e4196
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 63 deletions.
6 changes: 3 additions & 3 deletions src/glue.c
Expand Up @@ -555,7 +555,7 @@ void Module::genhelpers(bool iscomdat)
/**************************************
* Search for a druntime array op
*/
int isDruntimeArrayOp(Identifier *ident)
bool isDruntimeArrayOp(Identifier *ident)
{
/* Some of the array op functions are written as library functions,
* presumably to optimize them with special CPU vector instructions.
Expand Down Expand Up @@ -726,7 +726,7 @@ int isDruntimeArrayOp(Identifier *ident)
char *name = ident->toChars();
int i = binary(name, libArrayopFuncs, sizeof(libArrayopFuncs) / sizeof(char *));
if (i != -1)
return 1;
return true;

#ifdef DEBUG // Make sure our array is alphabetized
for (i = 0; i < sizeof(libArrayopFuncs) / sizeof(char *); i++)
Expand All @@ -735,7 +735,7 @@ int isDruntimeArrayOp(Identifier *ident)
assert(0);
}
#endif
return 0;
return false;
}

/* ================================================================== */
Expand Down
12 changes: 6 additions & 6 deletions src/iasm.c
Expand Up @@ -2105,25 +2105,25 @@ static opflag_t asm_float_type_size(Type *ptype, opflag_t *pusFloat)
/*******************************
*/

static int asm_isint(OPND *o)
static bool asm_isint(OPND *o)
{
if (!o || o->base || o->s)
return 0;
return false;
//return o->disp != 0;
return 1;
return true;
}

static int asm_isNonZeroInt(OPND *o)
static bool asm_isNonZeroInt(OPND *o)
{
if (!o || o->base || o->s)
return 0;
return false;
return o->disp != 0;
}

/*******************************
*/

static int asm_is_fpreg(char *szReg)
static bool asm_is_fpreg(char *szReg)
{
#if 1
return(szReg[0] == 'S' &&
Expand Down
16 changes: 8 additions & 8 deletions src/inline.c
Expand Up @@ -34,7 +34,7 @@
static Expression *expandInline(FuncDeclaration *fd, FuncDeclaration *parent,
Expression *eret, Expression *ethis, Expressions *arguments, Statement **ps);
bool walkPostorder(Expression *e, StoppableVisitor *v);
int canInline(FuncDeclaration *fd, int hasthis, int hdrscan, int statementsToo);
bool canInline(FuncDeclaration *fd, int hasthis, int hdrscan, int statementsToo);

/* ========== Compute cost of inlining =============== */

Expand Down Expand Up @@ -1613,7 +1613,7 @@ void inlineScan(Module *m)
m->semanticRun = PASSinlinedone;
}

int canInline(FuncDeclaration *fd, int hasthis, int hdrscan, int statementsToo)
bool canInline(FuncDeclaration *fd, int hasthis, int hdrscan, int statementsToo)
{
int cost;

Expand All @@ -1624,14 +1624,14 @@ int canInline(FuncDeclaration *fd, int hasthis, int hdrscan, int statementsToo)
#endif

if (fd->needThis() && !hasthis)
return 0;
return false;

if (fd->inlineNest || (fd->semanticRun < PASSsemantic3 && !hdrscan))
{
#if CANINLINE_LOG
printf("\t1: no, inlineNest = %d, semanticRun = %d\n", fd->inlineNest, fd->semanticRun);
#endif
return 0;
return false;
}

switch (statementsToo ? fd->inlineStatusStmt : fd->inlineStatusExp)
Expand All @@ -1640,13 +1640,13 @@ int canInline(FuncDeclaration *fd, int hasthis, int hdrscan, int statementsToo)
#if CANINLINE_LOG
printf("\t1: yes %s\n", fd->toChars());
#endif
return 1;
return true;

case ILSno:
#if CANINLINE_LOG
printf("\t1: no %s\n", fd->toChars());
#endif
return 0;
return false;

case ILSuninitialized:
break;
Expand Down Expand Up @@ -1749,7 +1749,7 @@ int canInline(FuncDeclaration *fd, int hasthis, int hdrscan, int statementsToo)
#if CANINLINE_LOG
printf("\t2: yes %s\n", fd->toChars());
#endif
return 1;
return true;

Lno:
if (!hdrscan) // Don't modify inlineStatus for header content scan
Expand All @@ -1762,7 +1762,7 @@ int canInline(FuncDeclaration *fd, int hasthis, int hdrscan, int statementsToo)
#if CANINLINE_LOG
printf("\t2: no %s\n", fd->toChars());
#endif
return 0;
return false;
}

static Expression *expandInline(FuncDeclaration *fd, FuncDeclaration *parent,
Expand Down
6 changes: 3 additions & 3 deletions src/lexer.c
Expand Up @@ -271,7 +271,7 @@ Token *Lexer::peekPastParen(Token *tk)
* 0 invalid
*/

int Lexer::isValidIdentifier(const char *p)
bool Lexer::isValidIdentifier(const char *p)
{
size_t len;
size_t idx;
Expand All @@ -294,10 +294,10 @@ int Lexer::isValidIdentifier(const char *p)
if (!((dc >= 0x80 && isUniAlpha(dc)) || isalnum(dc) || dc == '_'))
goto Linvalid;
}
return 1;
return true;

Linvalid:
return 0;
return false;
}

/****************************
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.h
Expand Up @@ -73,7 +73,7 @@ class Lexer
unsigned decodeUTF();
void getDocComment(Token *t, unsigned lineComment);

static int isValidIdentifier(const char *p);
static bool isValidIdentifier(const char *p);
static const utf8_t *combineComments(const utf8_t *c1, const utf8_t *c2);

private:
Expand Down
20 changes: 10 additions & 10 deletions src/libomf.c
Expand Up @@ -59,7 +59,7 @@ class LibOMF : public Library
private:
void scanObjModule(ObjModule *om);
unsigned short numDictPages(unsigned padding);
int FillDict(unsigned char *bucketsP, unsigned short uNumPages);
bool FillDict(unsigned char *bucketsP, unsigned short uNumPages);
void WriteLibToBuffer(OutBuffer *libbuf);

void error(const char *format, ...)
Expand Down Expand Up @@ -453,10 +453,10 @@ unsigned short LibOMF::numDictPages(unsigned padding)
/*******************************************
* Write a single entry into dictionary.
* Returns:
* 0 failure
* false failure
*/

static int EnterDict( unsigned char *bucketsP, unsigned short ndicpages, unsigned char *entry, unsigned entrylen )
static bool EnterDict( unsigned char *bucketsP, unsigned short ndicpages, unsigned char *entry, unsigned entrylen )
{
unsigned short uStartIndex;
unsigned short uStep;
Expand Down Expand Up @@ -528,7 +528,7 @@ static int EnterDict( unsigned char *bucketsP, unsigned short ndicpages, unsigne
aP[ HASHMOD ] += (nbytes + 1) >> 1;
if (aP[HASHMOD] == 0)
aP[HASHMOD] = 0xFF;
return 1;
return true;
}
}
uIndex += uStep;
Expand All @@ -545,16 +545,16 @@ static int EnterDict( unsigned char *bucketsP, unsigned short ndicpages, unsigne
break;
}

return 0;
return false;
}

/*******************************************
* Write the module and symbol names to the dictionary.
* Returns:
* 0 failure
* false failure
*/

int LibOMF::FillDict(unsigned char *bucketsP, unsigned short ndicpages)
bool LibOMF::FillDict(unsigned char *bucketsP, unsigned short ndicpages)
{
unsigned char entry[4 + LIBIDMAX + 2 + 1];

Expand All @@ -581,7 +581,7 @@ int LibOMF::FillDict(unsigned char *bucketsP, unsigned short ndicpages)
if ( n & 1 )
entry[ n + 2 + 2 ] = 0;
if ( !EnterDict( bucketsP, ndicpages, entry, n + 1 ) )
return 0;
return false;
}

// Sort the symbols
Expand All @@ -608,10 +608,10 @@ int LibOMF::FillDict(unsigned char *bucketsP, unsigned short ndicpages)
entry[ n + 3] = 0;
if ( !EnterDict( bucketsP, ndicpages, entry, n ) )
{
return 0;
return false;
}
}
return 1;
return true;
}


Expand Down
8 changes: 4 additions & 4 deletions src/mtype.c
Expand Up @@ -1819,7 +1819,7 @@ bool Type::isZeroInit(Loc loc)
return false; // assume not
}

int Type::isBaseOf(Type *t, int *poffset)
bool Type::isBaseOf(Type *t, int *poffset)
{
return 0; // assume not
}
Expand Down Expand Up @@ -8328,15 +8328,15 @@ bool TypeClass::isscope()
return sym->isscope;
}

int TypeClass::isBaseOf(Type *t, int *poffset)
bool TypeClass::isBaseOf(Type *t, int *poffset)
{
if (t && t->ty == Tclass)
{
ClassDeclaration *cd = ((TypeClass *)t)->sym;
if (sym->isBaseOf(cd, poffset))
return 1;
return true;
}
return 0;
return false;
}

MATCH TypeClass::implicitConvTo(Type *to)
Expand Down
4 changes: 2 additions & 2 deletions src/mtype.h
Expand Up @@ -315,7 +315,7 @@ class Type : public RootObject
virtual Type *makeMutable();
virtual Dsymbol *toDsymbol(Scope *sc);
virtual Type *toBasetype();
virtual int isBaseOf(Type *t, int *poffset);
virtual bool isBaseOf(Type *t, int *poffset);
virtual MATCH implicitConvTo(Type *to);
virtual MATCH constConv(Type *to);
virtual unsigned char deduceWild(Type *t, bool isRef);
Expand Down Expand Up @@ -858,7 +858,7 @@ class TypeClass : public Type
Dsymbol *toDsymbol(Scope *sc);
Expression *dotExp(Scope *sc, Expression *e, Identifier *ident, int flag);
ClassDeclaration *isClassHandle();
int isBaseOf(Type *t, int *poffset);
bool isBaseOf(Type *t, int *poffset);
MATCH implicitConvTo(Type *to);
MATCH constConv(Type *to);
unsigned char deduceWild(Type *t, bool isRef);
Expand Down
36 changes: 18 additions & 18 deletions src/parse.c
Expand Up @@ -5546,7 +5546,7 @@ void Parser::checkParens(TOK value, Expression *e)
* if *pt is not NULL, it is set to the ending token, which would be endtok
*/

int Parser::isDeclaration(Token *t, int needId, TOK endtok, Token **pt)
bool Parser::isDeclaration(Token *t, int needId, TOK endtok, Token **pt)
{
//printf("isDeclaration(needId = %d)\n", needId);
int haveId = 0;
Expand Down Expand Up @@ -5597,7 +5597,7 @@ int Parser::isDeclaration(Token *t, int needId, TOK endtok, Token **pt)
return false;
}

int Parser::isBasicType(Token **pt)
bool Parser::isBasicType(Token **pt)
{
// This code parallels parseBasicType()
Token *t = *pt;
Expand Down Expand Up @@ -5738,7 +5738,7 @@ int Parser::isBasicType(Token **pt)
return false;
}

int Parser::isDeclarator(Token **pt, int *haveId, int *haveTpl, TOK endtok)
bool Parser::isDeclarator(Token **pt, int *haveId, int *haveTpl, TOK endtok)
{ // This code parallels parseDeclarator()
Token *t = *pt;
int parens;
Expand Down Expand Up @@ -5927,7 +5927,7 @@ int Parser::isDeclarator(Token **pt, int *haveId, int *haveTpl, TOK endtok)
}


int Parser::isParameters(Token **pt)
bool Parser::isParameters(Token **pt)
{ // This code parallels parseParameters()
Token *t = *pt;

Expand Down Expand Up @@ -6022,7 +6022,7 @@ int Parser::isParameters(Token **pt)
return true;
}

int Parser::isExpression(Token **pt)
bool Parser::isExpression(Token **pt)
{
// This is supposed to determine if something is an expression.
// What it actually does is scan until a closing right bracket
Expand Down Expand Up @@ -6099,14 +6099,14 @@ int Parser::isExpression(Token **pt)
* Output:
* *pt is set to closing token, which is ')' on success
* Returns:
* !=0 successful
* 0 some parsing error
* true successful
* false some parsing error
*/

int Parser::skipParens(Token *t, Token **pt)
bool Parser::skipParens(Token *t, Token **pt)
{
if (t->value != TOKlparen)
return 0;
return false;

int parens = 0;

Expand Down Expand Up @@ -6138,19 +6138,19 @@ int Parser::skipParens(Token *t, Token **pt)
Ldone:
if (pt)
*pt = peek(t); // skip found rparen
return 1;
return true;

Lfalse:
return 0;
return false;
}

int Parser::skipParensIf(Token *t, Token **pt)
bool Parser::skipParensIf(Token *t, Token **pt)
{
if (t->value != TOKlparen)
{
if (pt)
*pt = t;
return 1;
return true;
}
return skipParens(t, pt);
}
Expand All @@ -6162,11 +6162,11 @@ int Parser::skipParensIf(Token *t, Token **pt)
* Output:
* *pt is set to first non-attribute token on success
* Returns:
* !=0 successful
* 0 some parsing error
* true successful
* false some parsing error
*/

int Parser::skipAttributes(Token *t, Token **pt)
bool Parser::skipAttributes(Token *t, Token **pt)
{
while (1)
{
Expand Down Expand Up @@ -6269,10 +6269,10 @@ int Parser::skipAttributes(Token *t, Token **pt)
Ldone:
if (pt)
*pt = t;
return 1;
return true;

Lerror:
return 0;
return false;
}

/********************************* Expression Parser ***************************/
Expand Down

0 comments on commit d9e4196

Please sign in to comment.