From 343d661a4d23a3db023005c237605e9614681a4c Mon Sep 17 00:00:00 2001 From: "Mark J. Reed" Date: Fri, 4 Oct 2013 12:17:19 -0400 Subject: [PATCH] use long long integers instead of ints --- interpreter.c | 16 ++++++++-------- interpreter.h | 4 ++-- parser.c | 2 +- parser.h | 4 ++-- tokenizer.c | 2 +- tokenizer.h | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/interpreter.c b/interpreter.c index faa7190..089aa59 100644 --- a/interpreter.c +++ b/interpreter.c @@ -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: { diff --git a/interpreter.h b/interpreter.h index bc5abad..8478e11 100644 --- a/interpreter.h +++ b/interpreter.h @@ -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 *); diff --git a/parser.c b/parser.c index c73051b..ce93c8c 100644 --- a/parser.c +++ b/parser.c @@ -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) { diff --git a/parser.h b/parser.h index 6eb1f39..f3e7717 100644 --- a/parser.h +++ b/parser.h @@ -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 *); diff --git a/tokenizer.c b/tokenizer.c index 3873dab..5d3d3d8 100644 --- a/tokenizer.c +++ b/tokenizer.c @@ -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 */ diff --git a/tokenizer.h b/tokenizer.h index 1abdebd..9d744ad 100644 --- a/tokenizer.h +++ b/tokenizer.h @@ -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;