use long long integers instead of ints

This commit is contained in:
Mark J. Reed 2013-10-04 12:17:19 -04:00 committed by Justin Meza
parent 323bb35b6d
commit 343d661a4d
6 changed files with 15 additions and 15 deletions

View File

@ -197,7 +197,7 @@ ValueObject *createBooleanValueObject(int data)
*
* \retval NULL Memory allocation failed.
*/
ValueObject *createIntegerValueObject(int data)
ValueObject *createIntegerValueObject(long long data)
{
ValueObject *p = malloc(sizeof(ValueObject));
if (!p) {
@ -1212,20 +1212,20 @@ ValueObject *castIntegerExplicit(ValueObject *node,
case VT_INTEGER:
return createIntegerValueObject(getInteger(node));
case VT_FLOAT:
return createIntegerValueObject((int)getFloat(node));
return createIntegerValueObject((long long)getFloat(node));
case VT_STRING:
if (strstr(getString(node), ":{")) {
/* Perform interpolation */
ValueObject *ret = NULL;
ValueObject *interp = castStringExplicit(node, scope);
int value;
long long value;
if (!interp) return NULL;
if (!isDecString(getString(interp))) {
error(IN_UNABLE_TO_CAST_VALUE);
deleteValueObject(interp);
return NULL;
}
if (sscanf(getString(interp), "%i", &value) != 1) {
if (sscanf(getString(interp), "%lli", &value) != 1) {
error(IN_EXPECTED_INTEGER_VALUE);
deleteValueObject(interp);
return NULL;
@ -1235,12 +1235,12 @@ ValueObject *castIntegerExplicit(ValueObject *node,
return ret;
}
else {
int value;
long long value;
if (!isDecString(getString(node))) {
error(IN_UNABLE_TO_CAST_VALUE);
return NULL;
}
if (sscanf(getString(node), "%i", &value) != 1) {
if (sscanf(getString(node), "%lli", &value) != 1) {
error(IN_EXPECTED_INTEGER_VALUE);
return NULL;
}
@ -1371,10 +1371,10 @@ ValueObject *castStringExplicit(ValueObject *node,
* One character per integer bit plus one more for the
* null character
*/
size_t size = sizeof(int) * 8 + 1;
size_t size = sizeof(long long) * 8 + 1;
data = malloc(sizeof(char) * size);
if (!data) return NULL;
sprintf(data, "%i", getInteger(node));
sprintf(data, "%lli", getInteger(node));
return createStringValueObject(data);
}
case VT_FLOAT: {

View File

@ -69,7 +69,7 @@ typedef enum {
* Stores value data.
*/
typedef union {
int i; /**< Integer data. */
long long i; /**< Integer data. */
float f; /**< Decimal data. */
char *s; /**< String data. */
FuncDefStmtNode *fn; /**< Function data. */
@ -146,7 +146,7 @@ char *resolveIdentifierName(IdentifierNode *, ScopeObject *);
/**@{*/
ValueObject *createNilValueObject(void);
ValueObject *createBooleanValueObject(int);
ValueObject *createIntegerValueObject(int);
ValueObject *createIntegerValueObject(long long);
ValueObject *createFloatValueObject(float);
ValueObject *createStringValueObject(char *);
ValueObject *createFunctionValueObject(FuncDefStmtNode *);

View File

@ -176,7 +176,7 @@ ConstantNode *createBooleanConstantNode(int data)
*
* \retval NULL Memory allocation failed.
*/
ConstantNode *createIntegerConstantNode(int data)
ConstantNode *createIntegerConstantNode(long long data)
{
ConstantNode *p = malloc(sizeof(ConstantNode));
if (!p) {

View File

@ -334,7 +334,7 @@ typedef enum {
* Stores constant data.
*/
typedef union {
int i; /**< Integer data. */
long long i; /**< Integer data. */
float f; /**< Decimal data. */
char *s; /**< String data. */
} ConstantData;
@ -851,7 +851,7 @@ StmtNode *parseImportStmtNode(Token ***);
*/
/**@{*/
ConstantNode *createBooleanConstantNode(int);
ConstantNode *createIntegerConstantNode(int);
ConstantNode *createIntegerConstantNode(long long);
ConstantNode *createFloatConstantNode(float);
ConstantNode *createStringConstantNode(char *);
void deleteConstantNode(ConstantNode *);

View File

@ -306,7 +306,7 @@ Token **tokenizeLexemes(LexemeList *list)
/* Integer */
else if (isInteger(image)) {
token = createToken(TT_INTEGER, image, fname, line);
if (sscanf(lexeme->image, "%i", &(token->data.i)) != 1)
if (sscanf(lexeme->image, "%lli", &(token->data.i)) != 1)
error(TK_EXPECTED_INTEGER, fname, line);
}
/* FAIL */

View File

@ -192,7 +192,7 @@ static const char *keywords[] = {
* Stores token data with semantic meaning.
*/
typedef union {
int i; /**< Integer data. */
long long i; /**< Integer data. */
float f; /**< Decimal data. */
} TokenData;