Skip to content

Commit

Permalink
use long long integers instead of ints
Browse files Browse the repository at this point in the history
  • Loading branch information
mjreed-wbd committed Oct 4, 2013
1 parent e309811 commit 4cf3583
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1188,20 +1188,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;
Expand All @@ -1211,12 +1211,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;
}
Expand Down Expand Up @@ -1347,10 +1347,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: {
Expand Down
4 changes: 2 additions & 2 deletions interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,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. */
Expand Down Expand Up @@ -139,7 +139,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 *);
Expand Down
2 changes: 1 addition & 1 deletion parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,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;
Expand Down Expand Up @@ -810,7 +810,7 @@ StmtNode *parseAltArrayDefStmtNode(Token ***);
*/
/**@{*/
ConstantNode *createBooleanConstantNode(int);
ConstantNode *createIntegerConstantNode(int);
ConstantNode *createIntegerConstantNode(long long);
ConstantNode *createFloatConstantNode(float);
ConstantNode *createStringConstantNode(char *);
void deleteConstantNode(ConstantNode *);
Expand Down
2 changes: 1 addition & 1 deletion tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,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;

Expand Down

0 comments on commit 4cf3583

Please sign in to comment.