Skip to content

Commit

Permalink
Merge pull request #4550 from jpf91/endian
Browse files Browse the repository at this point in the history
Fix lexing integers on big-endian systems
  • Loading branch information
9rnsr committed Apr 3, 2015
2 parents f234c39 + 79b2cd1 commit 91ce437
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/iasm.c
Expand Up @@ -3479,10 +3479,10 @@ static code *asm_db_parse(OP *pop)
switch (tok_value)
{
case TOKint32v:
dt.ul = asmtok->int32value;
dt.ul = (d_int32)asmtok->int64value;
goto L1;
case TOKuns32v:
dt.ul = asmtok->uns32value;
dt.ul = (d_uns32)asmtok->uns64value;
goto L1;
case TOKint64v:
dt.ul = asmtok->int64value;
Expand Down Expand Up @@ -3646,11 +3646,11 @@ int asm_getnum()
switch (tok_value)
{
case TOKint32v:
v = asmtok->int32value;
v = (d_int32)asmtok->int64value;
break;

case TOKuns32v:
v = asmtok->uns32value;
v = (d_uns32)asmtok->uns64value;
break;

case TOKidentifier:
Expand Down Expand Up @@ -4422,7 +4422,7 @@ static OPND *asm_primary_exp()
case TOKint32v:
case TOKuns32v:
o1 = new OPND();
o1->disp = asmtok->int32value;
o1->disp = (d_int32)asmtok->int64value;
asm_token();
break;

Expand Down
10 changes: 5 additions & 5 deletions src/parse.c
Expand Up @@ -6338,12 +6338,12 @@ Expression *Parser::parsePrimaryExp()
break;

case TOKint32v:
e = new IntegerExp(loc, token.int32value, Type::tint32);
e = new IntegerExp(loc, (d_int32)token.int64value, Type::tint32);
nextToken();
break;

case TOKuns32v:
e = new IntegerExp(loc, token.uns32value, Type::tuns32);
e = new IntegerExp(loc, (d_uns32)token.uns64value, Type::tuns32);
nextToken();
break;

Expand Down Expand Up @@ -6433,17 +6433,17 @@ Expression *Parser::parsePrimaryExp()
break;

case TOKcharv:
e = new IntegerExp(loc, token.uns32value, Type::tchar);
e = new IntegerExp(loc, (d_uns8)token.uns64value, Type::tchar);
nextToken();
break;

case TOKwcharv:
e = new IntegerExp(loc, token.uns32value, Type::twchar);
e = new IntegerExp(loc, (d_uns16)token.uns64value, Type::twchar);
nextToken();
break;

case TOKdcharv:
e = new IntegerExp(loc, token.uns32value, Type::tdchar);
e = new IntegerExp(loc, (d_uns32)token.uns64value, Type::tdchar);
nextToken();
break;

Expand Down
4 changes: 2 additions & 2 deletions src/tokens.c
Expand Up @@ -59,14 +59,14 @@ const char *Token::toChars()
switch (value)
{
case TOKint32v:
sprintf(&buffer[0],"%d",int32value);
sprintf(&buffer[0],"%d",(d_int32)int64value);
break;

case TOKuns32v:
case TOKcharv:
case TOKwcharv:
case TOKdcharv:
sprintf(&buffer[0],"%uU",uns32value);
sprintf(&buffer[0],"%uU",(d_uns32)uns64value);
break;

case TOKint64v:
Expand Down
2 changes: 0 additions & 2 deletions src/tokens.h
Expand Up @@ -200,8 +200,6 @@ struct Token
union
{
// Integers
d_int32 int32value;
d_uns32 uns32value;
d_int64 int64value;
d_uns64 uns64value;

Expand Down

0 comments on commit 91ce437

Please sign in to comment.