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

View File

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

View File

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

View File

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

View File

@ -306,7 +306,7 @@ Token **tokenizeLexemes(LexemeList *list)
/* Integer */ /* Integer */
else if (isInteger(image)) { else if (isInteger(image)) {
token = createToken(TT_INTEGER, image, fname, line); 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); error(TK_EXPECTED_INTEGER, fname, line);
} }
/* FAIL */ /* FAIL */

View File

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