Interactive mode error handling fixed for surveyor.
All surveyor warnings fixed. git-svn-id: http://picoc.googlecode.com/svn/trunk@216 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
ccbf149212
commit
61174fb115
|
@ -13,7 +13,7 @@ void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct Libr
|
|||
|
||||
for (Count = 0; (*FuncList)[Count].Prototype != NULL; Count++)
|
||||
{
|
||||
Tokens = LexAnalyse(IntrinsicName, (*FuncList)[Count].Prototype, strlen((*FuncList)[Count].Prototype), NULL);
|
||||
Tokens = LexAnalyse(IntrinsicName, (*FuncList)[Count].Prototype, strlen((char *)(*FuncList)[Count].Prototype), NULL);
|
||||
LexInitParser(&Parser, Tokens, IntrinsicName, Count+1, TRUE);
|
||||
TypeParse(&Parser, &ReturnType, &Identifier);
|
||||
NewValue = ParseFunctionDefinition(&Parser, ReturnType, Identifier, TRUE);
|
||||
|
|
|
@ -274,7 +274,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
ProgramFail(Parser, "can't assign incompatible types");
|
||||
|
||||
if (TotalValue->Typ->Base != TypeArray)
|
||||
memcpy(TotalValue->Val, CurrentValue->Val, TotalValue->Typ->Sizeof);
|
||||
memcpy((void *)TotalValue->Val, (void *)CurrentValue->Val, TotalValue->Typ->Sizeof);
|
||||
else
|
||||
{ /* array assignment */
|
||||
if (TotalValue->Val->Array.Size != CurrentValue->Val->Array.Size)
|
||||
|
@ -407,7 +407,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
case TokenAmpersand: IntResult = IntX & IntY; break;
|
||||
case TokenArithmeticOr: IntResult = IntX | IntY; break;
|
||||
case TokenArithmeticExor: IntResult = IntX ^ IntY; break;
|
||||
default: break;
|
||||
default: IntResult = 0; break;
|
||||
}
|
||||
TotalValue = ParsePushInt(Parser, IntResult);
|
||||
}
|
||||
|
@ -954,7 +954,7 @@ void ExpressionParseFunctionCall(struct ParseState *Parser, struct Value **Resul
|
|||
{
|
||||
struct Value *FuncValue;
|
||||
struct Value *Param;
|
||||
struct Value **ParamArray;
|
||||
struct Value **ParamArray = NULL;
|
||||
int ArgCount;
|
||||
enum LexToken Token = LexGetToken(Parser, NULL, TRUE); /* open bracket */
|
||||
|
||||
|
|
2
heap.c
2
heap.c
|
@ -164,7 +164,7 @@ void *HeapAlloc(int Size)
|
|||
NewMem->Size = AllocSize;
|
||||
}
|
||||
|
||||
memset(&NewMem->NextFree, '\0', AllocSize-sizeof(NewMem->Size));
|
||||
memset((void *)&NewMem->NextFree, '\0', AllocSize-sizeof(NewMem->Size));
|
||||
#ifdef DEBUG_HEAP
|
||||
printf(" = %lx\n", (unsigned long)&NewMem->NextFree);
|
||||
#endif
|
||||
|
|
8
lex.c
8
lex.c
|
@ -429,7 +429,7 @@ void *LexTokenise(struct LexState *Lexer, int *TokenLen)
|
|||
ValueSize = LexTokenSize(Token);
|
||||
if (ValueSize > 0)
|
||||
{ /* store a value as well */
|
||||
memcpy(TokenPos, GotValue->Val, ValueSize);
|
||||
memcpy(TokenPos, (void *)GotValue->Val, ValueSize);
|
||||
TokenPos += ValueSize;
|
||||
MemUsed += ValueSize;
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ enum LexToken LexGetToken(struct ParseState *Parser, struct Value **Value, int I
|
|||
default: break;
|
||||
}
|
||||
|
||||
memcpy(LexValue.Val, Parser->Pos+1, ValueSize);
|
||||
memcpy((void *)LexValue.Val, (void *)Parser->Pos+1, ValueSize);
|
||||
LexValue.ValOnHeap = FALSE;
|
||||
LexValue.ValOnStack = FALSE;
|
||||
LexValue.IsLValue = FALSE;
|
||||
|
@ -617,7 +617,7 @@ void *LexCopyTokens(struct ParseState *StartParser, struct ParseState *EndParser
|
|||
{ /* non-interactive mode - copy the tokens */
|
||||
MemSize = EndParser->Pos - StartParser->Pos;
|
||||
NewTokens = VariableAlloc(StartParser, MemSize + 1, TRUE);
|
||||
memcpy(NewTokens, StartParser->Pos, MemSize);
|
||||
memcpy(NewTokens, (void *)StartParser->Pos, MemSize);
|
||||
}
|
||||
else
|
||||
{ /* we're in interactive mode - add up line by line */
|
||||
|
@ -628,7 +628,7 @@ void *LexCopyTokens(struct ParseState *StartParser, struct ParseState *EndParser
|
|||
{ /* all on a single line */
|
||||
MemSize = EndParser->Pos - StartParser->Pos;
|
||||
NewTokens = VariableAlloc(StartParser, MemSize + 1, TRUE);
|
||||
memcpy(NewTokens, StartParser->Pos, MemSize);
|
||||
memcpy(NewTokens, (void *)StartParser->Pos, MemSize);
|
||||
}
|
||||
else
|
||||
{ /* it's spread across multiple lines */
|
||||
|
|
2
parse.c
2
parse.c
|
@ -464,7 +464,7 @@ int ParseStatement(struct ParseState *Parser)
|
|||
|
||||
// XXX - make assignment a separate function
|
||||
// XXX - also arrays need cleverer assignment
|
||||
memcpy(TopStackFrame->ReturnValue->Val, CValue->Val, TypeSizeValue(CValue));
|
||||
memcpy((void *)TopStackFrame->ReturnValue->Val, (void *)CValue->Val, TypeSizeValue(CValue));
|
||||
Parser->Mode = RunModeReturn;
|
||||
}
|
||||
else
|
||||
|
|
8
picoc.c
8
picoc.c
|
@ -54,8 +54,6 @@ int main(int argc, char **argv)
|
|||
}
|
||||
#else
|
||||
# ifdef SURVEYOR_HOST
|
||||
int errjmp[41];
|
||||
|
||||
int picoc(char *SourceStr)
|
||||
{
|
||||
int ix;
|
||||
|
@ -68,9 +66,9 @@ int picoc(char *SourceStr)
|
|||
printf("%s\n\r", SourceStr); // display program source
|
||||
printf("=====================\n");
|
||||
}
|
||||
errjmp[40] = 0;
|
||||
setjmp(errjmp);
|
||||
if (errjmp[40]) {
|
||||
ExitBuf[40] = 0;
|
||||
PlatformSetExitPoint();
|
||||
if (ExitBuf[40]) {
|
||||
printf("leaving picoC\n\r");
|
||||
Cleanup();
|
||||
return 1;
|
||||
|
|
|
@ -70,6 +70,9 @@ extern jmp_buf ExitBuf;
|
|||
# define INTERACTIVE_PROMPT_LINE "- "
|
||||
# endif
|
||||
# endif
|
||||
|
||||
extern int ExitBuf[];
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* PLATFORM_H */
|
||||
|
|
|
@ -43,12 +43,13 @@ int PlatformGetCharacter()
|
|||
return getch();
|
||||
}
|
||||
|
||||
/* exit the program */
|
||||
extern int errjmp[];
|
||||
/* mark where to end the program for platforms which require this */
|
||||
int ExitBuf[41];
|
||||
|
||||
/* exit the program */
|
||||
void PlatformExit()
|
||||
{
|
||||
errjmp[40] = 1;
|
||||
longjmp(errjmp, 1);
|
||||
ExitBuf[40] = 1;
|
||||
longjmp(ExitBuf, 1);
|
||||
}
|
||||
|
||||
|
|
8
table.c
8
table.c
|
@ -35,7 +35,7 @@ void TableInitTable(struct Table *Tbl, struct TableEntry **HashTable, int Size,
|
|||
Tbl->Size = Size;
|
||||
Tbl->OnHeap = OnHeap;
|
||||
Tbl->HashTable = HashTable;
|
||||
memset(HashTable, '\0', sizeof(struct TableEntry *) * Size);
|
||||
memset((void *)HashTable, '\0', sizeof(struct TableEntry *) * Size);
|
||||
}
|
||||
|
||||
/* check a hash table entry for a key */
|
||||
|
@ -114,7 +114,7 @@ static struct TableEntry *TableSearchIdentifier(struct Table *Tbl, const char *K
|
|||
|
||||
for (Entry = Tbl->HashTable[HashValue]; Entry != NULL; Entry = Entry->Next)
|
||||
{
|
||||
if (strncmp(&Entry->p.Key[0], Key, Len) == 0 && Entry->p.Key[Len] == '\0')
|
||||
if (strncmp(&Entry->p.Key[0], (char *)Key, Len) == 0 && Entry->p.Key[Len] == '\0')
|
||||
return Entry; /* found */
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ char *TableSetIdentifier(struct Table *Tbl, const char *Ident, int IdentLen)
|
|||
if (NewEntry == NULL)
|
||||
ProgramFail(NULL, "out of memory");
|
||||
|
||||
strncpy((char *)&NewEntry->p.Key[0], Ident, IdentLen);
|
||||
strncpy((char *)&NewEntry->p.Key[0], (char *)Ident, IdentLen);
|
||||
NewEntry->p.Key[IdentLen] = '\0';
|
||||
NewEntry->Next = Tbl->HashTable[AddAt];
|
||||
Tbl->HashTable[AddAt] = NewEntry;
|
||||
|
@ -152,7 +152,7 @@ char *TableStrRegister2(const char *Str, int Len)
|
|||
|
||||
char *TableStrRegister(const char *Str)
|
||||
{
|
||||
return TableStrRegister2(Str, strlen(Str));
|
||||
return TableStrRegister2(Str, strlen((char *)Str));
|
||||
}
|
||||
|
||||
/* free all the strings */
|
||||
|
|
2
type.c
2
type.c
|
@ -237,7 +237,7 @@ void TypeParseEnum(struct ParseState *Parser, struct ValueType **Typ)
|
|||
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
(*Typ)->Members = &GlobalTable;
|
||||
memset(&InitValue, '\0', sizeof(struct Value));
|
||||
memset((void *)&InitValue, '\0', sizeof(struct Value));
|
||||
InitValue.Typ = &IntType;
|
||||
InitValue.Val = (union AnyValue *)&EnumValue;
|
||||
do {
|
||||
|
|
|
@ -120,7 +120,7 @@ struct Value *VariableAllocValueAndCopy(struct ParseState *Parser, struct Value
|
|||
int CopySize = TypeSizeValue(FromValue);
|
||||
struct Value *NewValue = VariableAllocValueAndData(Parser, CopySize, FromValue->IsLValue, FromValue->LValueFrom, OnHeap);
|
||||
NewValue->Typ = FromValue->Typ;
|
||||
memcpy(NewValue->Val, FromValue->Val, CopySize);
|
||||
memcpy((void *)NewValue->Val, (void *)FromValue->Val, CopySize);
|
||||
return NewValue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue