This commit is contained in:
markjreed 2013-10-04 11:04:23 -07:00
commit c4af2b1537
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) {
@ -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;
@ -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;
}
@ -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: {

View File

@ -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. */
@ -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 *);

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

@ -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;
@ -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 *);

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

@ -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;