ref: d94fc20497e2cc7a537af73b9551b9e03e2df6d0
parent: 875ede79568398912b40563f74c515fbb7b8e177
author: asau <asau@ficl.sf.net>
date: Thu Dec 2 07:56:43 CST 2010
Cast pointers.
--- a/dictionary.c
+++ b/dictionary.c
@@ -3,7 +3,7 @@
** Forth Inspired Command Language - dictionary methods
** Author: John Sadler (john_sadler@alum.mit.edu)
** Created: 19 July 1997
-** $Id: dictionary.c,v 1.4 2010/11/01 14:10:27 asau Exp $
+** $Id: dictionary.c,v 1.5 2010/12/02 13:56:43 asau Exp $
*******************************************************************/
/*
** This file implements the dictionary -- Ficl's model of
@@ -92,7 +92,7 @@
**************************************************************************/
void ficlDictionaryAlign(ficlDictionary *dictionary)
{
- dictionary->here = ficlAlignPointer(dictionary->here);
+ dictionary->here = (ficlCell*)ficlAlignPointer(dictionary->here);
}
@@ -199,7 +199,7 @@
if (length > FICL_NAME_LENGTH)
length = FICL_NAME_LENGTH;
- return ficlDictionaryAppendData(dictionary, data, length);
+ return (char*)ficlDictionaryAppendData(dictionary, data, length);
}
@@ -273,10 +273,10 @@
/* only reuse the existing word if we're sure it has space for a 2constant */
if ((word != NULL) &&
- ((((ficlInstruction)word->code) == ficlInstruction2ConstantParen)
+ ((((ficlInstruction)(uintptr_t)word->code) == ficlInstruction2ConstantParen)
#if FICL_WANT_FLOAT
||
- (((ficlInstruction)word->code) == ficlInstructionF2ConstantParen)
+ (((ficlInstruction)(uintptr_t)word->code) == ficlInstructionF2ConstantParen)
#endif /* FICL_WANT_FLOAT */
)
)
@@ -454,7 +454,7 @@
nAlloc = sizeof(ficlDictionary) + (size * sizeof (ficlCell))
+ sizeof(ficlHash) + (bucketCount - 1) * sizeof (ficlWord *);
- dictionary = ficlMalloc(nAlloc);
+ dictionary = (ficlDictionary*)ficlMalloc(nAlloc);
FICL_SYSTEM_ASSERT(system, dictionary != NULL);
dictionary->size = size;
@@ -532,8 +532,8 @@
**************************************************************************/
int ficlDictionaryIsAWord(ficlDictionary *dictionary, ficlWord *word)
{
- if ( (((ficlInstruction)word) > ficlInstructionInvalid)
- && (((ficlInstruction)word) < ficlInstructionLast) )
+ if ( (((ficlInstruction)(uintptr_t)word) > ficlInstructionInvalid)
+ && (((ficlInstruction)(uintptr_t)word) < ficlInstructionLast) )
return 1;
if (!ficlDictionaryIncludes(dictionary, word))
@@ -683,7 +683,7 @@
break;
case FICL_WORDKIND_LITERAL:
c = *++cell;
- if (ficlDictionaryIsAWord(dictionary, c.p) && (c.i >= ficlInstructionLast))
+ if (ficlDictionaryIsAWord(dictionary, (ficlWord*)c.p) && (c.i >= ficlInstructionLast))
{
ficlWord *word = (ficlWord *)c.p;
sprintf(trace, "%.*s ( %#jx literal )",
--- a/primitives.c
+++ b/primitives.c
@@ -4,7 +4,7 @@
** ANS Forth CORE word-set written in C
** Author: John Sadler (john_sadler@alum.mit.edu)
** Created: 19 July 1997
-** $Id: primitives.c,v 1.6 2010/11/01 14:10:27 asau Exp $
+** $Id: primitives.c,v 1.7 2010/12/02 13:56:43 asau Exp $
*******************************************************************/
/*
** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu)
@@ -156,7 +156,7 @@
FICL_STACK_CHECK(vm->dataStack, 2, 0);
- tag = ficlStackPopPointer(vm->dataStack);
+ tag = (char *)ficlStackPopPointer(vm->dataStack);
/*
** Changed the comparison below to compare the pointers first (by popular demand)
*/
@@ -696,7 +696,7 @@
if (ficlStackGetTop(vm->dataStack).p == fallthroughTag)
{
matchControlTag(vm, fallthroughTag);
- patchAddr = ficlStackPopPointer(vm->dataStack);
+ patchAddr = (ficlCell *)ficlStackPopPointer(vm->dataStack);
matchControlTag(vm, caseTag);
fixupCount = ficlStackPopUnsigned(vm->dataStack);
ficlStackPushPointer(vm->dataStack, patchAddr);
@@ -740,7 +740,7 @@
if (ficlStackGetTop(vm->dataStack).p == fallthroughTag)
{
matchControlTag(vm, fallthroughTag);
- fallthroughFixup = ficlStackPopPointer(vm->dataStack);
+ fallthroughFixup = (ficlCell *)ficlStackPopPointer(vm->dataStack);
}
matchControlTag(vm, caseTag);
@@ -1290,7 +1290,7 @@
FICL_VM_ASSERT(vm, pComma);
ficlPrimitiveTick(vm);
- word = ficlStackGetTop(vm->dataStack).p;
+ word = (ficlWord *)ficlStackGetTop(vm->dataStack).p;
if (ficlWordIsImmediate(word))
{
ficlDictionaryAppendCell(dictionary, ficlStackPop(vm->dataStack));
@@ -1318,7 +1318,7 @@
FICL_STACK_CHECK(vm->dataStack, 1, 0);
- word = ficlStackPopPointer(vm->dataStack);
+ word = (ficlWord *)ficlStackPopPointer(vm->dataStack);
ficlVmExecuteWord(vm, word);
return;
@@ -1455,7 +1455,7 @@
dictionary = ficlVmGetDictionary(vm);
length = ficlStackPopUnsigned(vm->dataStack);
- from = ficlStackPopPointer(vm->dataStack);
+ from = (char *)ficlStackPopPointer(vm->dataStack);
ficlDictionaryAppendUnsigned(dictionary, ficlInstructionStringLiteralParen);
to = (char *) dictionary->here;
@@ -1535,7 +1535,7 @@
ficlWord *word;
FICL_STACK_CHECK(vm->dataStack, 1, 1);
- word = ficlStackPopPointer(vm->dataStack);
+ word = (ficlWord *)ficlStackPopPointer(vm->dataStack);
ficlStackPushPointer(vm->dataStack, word->param + 1);
return;
}
@@ -1567,7 +1567,7 @@
FICL_STACK_CHECK(vm->dataStack, 1, 2);
- word = ficlStackPopPointer(vm->dataStack);
+ word = (ficlWord *)ficlStackPopPointer(vm->dataStack);
ficlStackPushPointer(vm->dataStack, word->name);
ficlStackPushUnsigned(vm->dataStack, word->length);
return;
@@ -1857,7 +1857,7 @@
** Now we have something in the text buffer - use it
*/
size = ficlStackPopInteger(vm->dataStack);
- address = ficlStackPopPointer(vm->dataStack);
+ address = (char *)ficlStackPopPointer(vm->dataStack);
length = (size < length) ? size : length;
strncpy(address, trace, length);
@@ -2010,7 +2010,7 @@
FICL_STACK_CHECK(vm->dataStack,1,1);
- p = ficlStackPopPointer(vm->dataStack);
+ p = (char *)ficlStackPopPointer(vm->dataStack);
ficlStackPushPointer(vm->dataStack, p + 1);
return;
}
@@ -2059,7 +2059,7 @@
FICL_STACK_CHECK(vm->dataStack,1,2);
- counted = ficlStackPopPointer(vm->dataStack);
+ counted = (ficlCountedString *)ficlStackPopPointer(vm->dataStack);
ficlStackPushPointer(vm->dataStack, counted->text);
ficlStackPushUnsigned(vm->dataStack, counted->length);
return;
@@ -2089,7 +2089,7 @@
environment = vm->callback.system->environment;
name.length = ficlStackPopUnsigned(vm->dataStack);
- name.text = ficlStackPopPointer(vm->dataStack);
+ name.text = (char *)ficlStackPopPointer(vm->dataStack);
word = ficlDictionaryLookup(environment, name);
@@ -2181,7 +2181,7 @@
length = ficlStackPopUnsigned(vm->dataStack);
- s = ficlStackPopPointer(vm->dataStack);
+ s = (char *)ficlStackPopPointer(vm->dataStack);
if ((s == NULL) || (length == 0))
return;
@@ -2343,7 +2343,7 @@
FICL_STACK_CHECK(vm->dataStack, 1, 2);
- counted = ficlStackPopPointer(vm->dataStack);
+ counted = (ficlCountedString *)ficlStackPopPointer(vm->dataStack);
FICL_STRING_SET_FROM_COUNTED_STRING(name, *counted);
do_find(vm, name, counted);
}
@@ -2364,7 +2364,7 @@
name.length = ficlStackPopInteger(vm->dataStack);
- name.text = ficlStackPopPointer(vm->dataStack);
+ name.text = (char *)ficlStackPopPointer(vm->dataStack);
do_find(vm, name, NULL);
}
@@ -3081,7 +3081,7 @@
FICL_STACK_CHECK(vm->dataStack, 1, 0);
- word = ficlStackPopPointer(vm->dataStack);
+ word = (ficlWord *)ficlStackPopPointer(vm->dataStack);
/*
** Save vm's state -- a catch will not back out environmental
--- a/search.c
+++ b/search.c
@@ -4,7 +4,7 @@
** ANS Forth SEARCH and SEARCH-EXT word-set written in C
** Author: John Sadler (john_sadler@alum.mit.edu)
** Created: 6 June 2000
-** $Id: search.c,v 1.11 2010/11/01 14:10:27 asau Exp $
+** $Id: search.c,v 1.12 2010/12/02 13:56:43 asau Exp $
*******************************************************************/
/*
** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu)
@@ -136,10 +136,10 @@
ficlString name;
ficlUnsigned16 hashCode;
ficlWord *word;
- ficlHash *hash = ficlStackPopPointer(vm->dataStack);
+ ficlHash *hash = (ficlHash*)ficlStackPopPointer(vm->dataStack);
name.length = (ficlUnsigned8)ficlStackPopUnsigned(vm->dataStack);
- name.text = ficlStackPopPointer(vm->dataStack);
+ name.text = (char*)ficlStackPopPointer(vm->dataStack);
hashCode = ficlHashCode(name);
ficlDictionaryLock(ficlVmGetDictionary(vm), FICL_TRUE);
@@ -167,7 +167,7 @@
**************************************************************************/
static void ficlPrimitiveSetCurrent(ficlVm *vm)
{
- ficlHash *hash = ficlStackPopPointer(vm->dataStack);
+ ficlHash *hash = (ficlHash*)ficlStackPopPointer(vm->dataStack);
ficlDictionary *dictionary = ficlVmGetDictionary(vm);
ficlDictionaryLock(dictionary, FICL_TRUE);
dictionary->compilationWordlist = hash;
@@ -205,7 +205,7 @@
dictionary->wordlistCount = wordlistCount;
for (i = wordlistCount-1; i >= 0; --i)
{
- dictionary->wordlists[i] = ficlStackPopPointer(vm->dataStack);
+ dictionary->wordlists[i] = (ficlHash*)ficlStackPopPointer(vm->dataStack);
}
}
else
@@ -284,7 +284,7 @@
{
ficlVmThrowError(vm, ">search error: search order overflow");
}
- dictionary->wordlists[dictionary->wordlistCount++] = ficlStackPopPointer(vm->dataStack);
+ dictionary->wordlists[dictionary->wordlistCount++] = (ficlHash*)ficlStackPopPointer(vm->dataStack);
ficlDictionaryLock(dictionary, FICL_FALSE);
return;
}
@@ -301,7 +301,7 @@
char *name;
ficlInteger length;
- hash = ficlVmPop(vm).p;
+ hash = (ficlHash*)ficlVmPop(vm).p;
name = hash->name;
if (name != NULL)
@@ -322,7 +322,7 @@
static void ficlPrimitiveWidSetName(ficlVm *vm)
{
char *name = (char *)ficlVmPop(vm).p;
- ficlHash *hash = ficlVmPop(vm).p;
+ ficlHash *hash = (ficlHash*)ficlVmPop(vm).p;
hash->name = name;
return;
}
--- a/softcore/makesoftcore.c
+++ b/softcore/makesoftcore.c
@@ -219,7 +219,7 @@
"#if FICL_WANT_LZ_SOFTCORE\n"
" char *ficlSoftcoreUncompressed = NULL;\n"
" size_t gotUncompressedSize = 0;\n"
-" returnValue = ficlLzUncompress(ficlSoftcoreCompressed, (unsigned char **)&ficlSoftcoreUncompressed, &gotUncompressedSize);\n"
+" returnValue = ficlLzUncompress(ficlSoftcoreCompressed, (unsigned char**)&ficlSoftcoreUncompressed, &gotUncompressedSize);\n"
" FICL_VM_ASSERT(vm, returnValue == 0);\n"
" FICL_VM_ASSERT(vm, gotUncompressedSize == ficlSoftcoreUncompressedSize);\n"
"#endif /* FICL_WANT_LZ_SOFTCORE */\n"
--- a/stack.c
+++ b/stack.c
@@ -3,7 +3,7 @@
** Forth Inspired Command Language
** Author: John Sadler (john_sadler@alum.mit.edu)
** Created: 16 Oct 1997
-** $Id: stack.c,v 1.12 2010/11/01 14:10:27 asau Exp $
+** $Id: stack.c,v 1.13 2010/12/02 13:56:43 asau Exp $
*******************************************************************/
/*
** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu)
@@ -100,7 +100,7 @@
ficlStack *ficlStackCreate(ficlVm *vm, char *name, unsigned size)
{
size_t totalSize = sizeof (ficlStack) + (size * sizeof (ficlCell));
- ficlStack *stack = ficlMalloc(totalSize);
+ ficlStack *stack = (ficlStack*)ficlMalloc(totalSize);
FICL_VM_ASSERT(vm, size != 0);
FICL_VM_ASSERT(vm, stack != NULL);
@@ -209,7 +209,7 @@
void ficlStackUnlink(ficlStack *stack)
{
stack->top = stack->frame - 1;
- stack->frame = ficlStackPopPointer(stack);
+ stack->frame = (ficlCell*)ficlStackPopPointer(stack);
return;
}
#endif /* FICL_WANT_LOCALS */
--- a/system.c
+++ b/system.c
@@ -3,7 +3,7 @@
** Forth Inspired Command Language - external interface
** Author: John Sadler (john_sadler@alum.mit.edu)
** Created: 19 July 1997
-** $Id: system.c,v 1.3 2010/11/01 14:10:27 asau Exp $
+** $Id: system.c,v 1.4 2010/12/02 13:56:43 asau Exp $
*******************************************************************/
/*
** This is an ANS Forth interpreter written in C.
@@ -137,7 +137,7 @@
FICL_ASSERT(&callback, sizeof(ficlFloat) <= sizeof(ficlInteger));
#endif
- system = ficlMalloc(sizeof(ficlSystem));
+ system = (ficlSystem*)ficlMalloc(sizeof(ficlSystem));
FICL_ASSERT(&callback, system);
--- a/tools.c
+++ b/tools.c
@@ -3,7 +3,7 @@
** Forth Inspired Command Language - programming tools
** Author: John Sadler (john_sadler@alum.mit.edu)
** Created: 20 June 2000
-** $Id: tools.c,v 1.14 2010/11/01 14:10:27 asau Exp $
+** $Id: tools.c,v 1.15 2010/12/02 13:56:43 asau Exp $
*******************************************************************/
/*
** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu)
@@ -295,7 +295,7 @@
**************************************************************************/
static void ficlPrimitiveDebugXT(ficlVm *vm)
{
- ficlWord *xt = ficlStackPopPointer(vm->dataStack);
+ ficlWord *xt = (ficlWord*)ficlStackPopPointer(vm->dataStack);
ficlWordKind wk = ficlWordClassify(xt);
ficlStackPushPointer(vm->dataStack, xt);
@@ -653,7 +653,7 @@
*/
if (ficlDictionaryIncludes(context->dictionary, cell->p))
{
- ficlWord *word = ficlDictionaryFindEnclosingWord(context->dictionary, cell->p);
+ ficlWord *word = ficlDictionaryFindEnclosingWord(context->dictionary, (ficlCell*)cell->p);
if (word)
{
int offset = (ficlCell *)cell->p - &word->param[0];
--- a/vm.c
+++ b/vm.c
@@ -3,7 +3,7 @@
** Forth Inspired Command Language - virtual machine methods
** Author: John Sadler (john_sadler@alum.mit.edu)
** Created: 19 July 1997
-** $Id: vm.c,v 1.19 2010/11/03 14:44:38 asau Exp $
+** $Id: vm.c,v 1.20 2010/12/02 13:56:43 asau Exp $
*******************************************************************/
/*
** This file implements the virtual machine of Ficl. Each virtual
@@ -378,8 +378,8 @@
(++dataTop)->i = length;
cp += length + 1;
- cp = ficlAlignPointer(cp);
- ip = (void *)cp;
+ cp = (char *)ficlAlignPointer(cp);
+ ip = (ficlInstruction *)cp;
continue;
}
@@ -389,8 +389,8 @@
s = (ficlCountedString *)(ip);
cp = s->text + s->length + 1;
- cp = ficlAlignPointer(cp);
- ip = (void *)cp;
+ cp = (char *)ficlAlignPointer(cp);
+ ip = (ficlInstruction *)cp;
(++dataTop)->p = s;
continue;
}
@@ -525,7 +525,7 @@
case ficlInstructionUnlinkParen:
{
returnTop = frame - 1;
- frame = (returnTop--)->p;
+ frame = (ficlCell *)(returnTop--)->p;
continue;
}
@@ -1122,8 +1122,8 @@
CHECK_STACK(3, 0);
u = (dataTop--)->u;
- addr2 = (dataTop--)->p;
- addr1 = (dataTop--)->p;
+ addr2 = (char *)(dataTop--)->p;
+ addr1 = (char *)(dataTop--)->p;
if (u == 0)
continue;
@@ -1372,7 +1372,7 @@
if (limit.u == index.u)
{
- ip = leave.p;
+ ip = (ficlInstruction *)leave.p;
}
else
{
@@ -1490,22 +1490,22 @@
case ficlInstructionF2Fetch:
CHECK_FLOAT_STACK(0, 2);
CHECK_STACK(1, 0);
- FLOAT_PUSH_CELL_POINTER_DOUBLE((dataTop--)->p);
+ FLOAT_PUSH_CELL_POINTER_DOUBLE((ficlCell *)(dataTop--)->p);
case ficlInstructionFFetch:
CHECK_FLOAT_STACK(0, 1);
CHECK_STACK(1, 0);
- FLOAT_PUSH_CELL_POINTER((dataTop--)->p);
+ FLOAT_PUSH_CELL_POINTER((ficlCell *)(dataTop--)->p);
case ficlInstructionF2Store:
CHECK_FLOAT_STACK(2, 0);
CHECK_STACK(1, 0);
- FLOAT_POP_CELL_POINTER_DOUBLE((dataTop--)->p);
+ FLOAT_POP_CELL_POINTER_DOUBLE((ficlCell *)(dataTop--)->p);
case ficlInstructionFStore:
CHECK_FLOAT_STACK(1, 0);
CHECK_STACK(1, 0);
- FLOAT_POP_CELL_POINTER((dataTop--)->p);
+ FLOAT_POP_CELL_POINTER((ficlCell *)(dataTop--)->p);
#endif /* FICL_WANT_FLOAT */
/*
@@ -1517,7 +1517,7 @@
*/
case ficlInstruction2Fetch:
CHECK_STACK(1, 2);
- PUSH_CELL_POINTER_DOUBLE((dataTop--)->p);
+ PUSH_CELL_POINTER_DOUBLE((ficlCell *)(dataTop--)->p);
/*
** fetch CORE ( a-addr -- x )
@@ -1526,7 +1526,7 @@
*/
case ficlInstructionFetch:
CHECK_STACK(1, 1);
- PUSH_CELL_POINTER((dataTop--)->p);
+ PUSH_CELL_POINTER((ficlCell *)(dataTop--)->p);
/*
** two-store CORE ( x1 x2 a-addr -- )
@@ -1536,7 +1536,7 @@
*/
case ficlInstruction2Store:
CHECK_STACK(3, 0);
- POP_CELL_POINTER_DOUBLE((dataTop--)->p);
+ POP_CELL_POINTER_DOUBLE((ficlCell *)(dataTop--)->p);
/*
** store CORE ( x a-addr -- )
@@ -1544,7 +1544,7 @@
*/
case ficlInstructionStore:
CHECK_STACK(2, 0);
- POP_CELL_POINTER((dataTop--)->p);
+ POP_CELL_POINTER((ficlCell *)(dataTop--)->p);
case ficlInstructionComma:
{