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++)
|
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);
|
LexInitParser(&Parser, Tokens, IntrinsicName, Count+1, TRUE);
|
||||||
TypeParse(&Parser, &ReturnType, &Identifier);
|
TypeParse(&Parser, &ReturnType, &Identifier);
|
||||||
NewValue = ParseFunctionDefinition(&Parser, ReturnType, Identifier, TRUE);
|
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");
|
ProgramFail(Parser, "can't assign incompatible types");
|
||||||
|
|
||||||
if (TotalValue->Typ->Base != TypeArray)
|
if (TotalValue->Typ->Base != TypeArray)
|
||||||
memcpy(TotalValue->Val, CurrentValue->Val, TotalValue->Typ->Sizeof);
|
memcpy((void *)TotalValue->Val, (void *)CurrentValue->Val, TotalValue->Typ->Sizeof);
|
||||||
else
|
else
|
||||||
{ /* array assignment */
|
{ /* array assignment */
|
||||||
if (TotalValue->Val->Array.Size != CurrentValue->Val->Array.Size)
|
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 TokenAmpersand: IntResult = IntX & IntY; break;
|
||||||
case TokenArithmeticOr: IntResult = IntX | IntY; break;
|
case TokenArithmeticOr: IntResult = IntX | IntY; break;
|
||||||
case TokenArithmeticExor: IntResult = IntX ^ IntY; break;
|
case TokenArithmeticExor: IntResult = IntX ^ IntY; break;
|
||||||
default: break;
|
default: IntResult = 0; break;
|
||||||
}
|
}
|
||||||
TotalValue = ParsePushInt(Parser, IntResult);
|
TotalValue = ParsePushInt(Parser, IntResult);
|
||||||
}
|
}
|
||||||
|
@ -954,7 +954,7 @@ void ExpressionParseFunctionCall(struct ParseState *Parser, struct Value **Resul
|
||||||
{
|
{
|
||||||
struct Value *FuncValue;
|
struct Value *FuncValue;
|
||||||
struct Value *Param;
|
struct Value *Param;
|
||||||
struct Value **ParamArray;
|
struct Value **ParamArray = NULL;
|
||||||
int ArgCount;
|
int ArgCount;
|
||||||
enum LexToken Token = LexGetToken(Parser, NULL, TRUE); /* open bracket */
|
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;
|
NewMem->Size = AllocSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&NewMem->NextFree, '\0', AllocSize-sizeof(NewMem->Size));
|
memset((void *)&NewMem->NextFree, '\0', AllocSize-sizeof(NewMem->Size));
|
||||||
#ifdef DEBUG_HEAP
|
#ifdef DEBUG_HEAP
|
||||||
printf(" = %lx\n", (unsigned long)&NewMem->NextFree);
|
printf(" = %lx\n", (unsigned long)&NewMem->NextFree);
|
||||||
#endif
|
#endif
|
||||||
|
|
8
lex.c
8
lex.c
|
@ -429,7 +429,7 @@ void *LexTokenise(struct LexState *Lexer, int *TokenLen)
|
||||||
ValueSize = LexTokenSize(Token);
|
ValueSize = LexTokenSize(Token);
|
||||||
if (ValueSize > 0)
|
if (ValueSize > 0)
|
||||||
{ /* store a value as well */
|
{ /* store a value as well */
|
||||||
memcpy(TokenPos, GotValue->Val, ValueSize);
|
memcpy(TokenPos, (void *)GotValue->Val, ValueSize);
|
||||||
TokenPos += ValueSize;
|
TokenPos += ValueSize;
|
||||||
MemUsed += ValueSize;
|
MemUsed += ValueSize;
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,7 @@ enum LexToken LexGetToken(struct ParseState *Parser, struct Value **Value, int I
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(LexValue.Val, Parser->Pos+1, ValueSize);
|
memcpy((void *)LexValue.Val, (void *)Parser->Pos+1, ValueSize);
|
||||||
LexValue.ValOnHeap = FALSE;
|
LexValue.ValOnHeap = FALSE;
|
||||||
LexValue.ValOnStack = FALSE;
|
LexValue.ValOnStack = FALSE;
|
||||||
LexValue.IsLValue = FALSE;
|
LexValue.IsLValue = FALSE;
|
||||||
|
@ -617,7 +617,7 @@ void *LexCopyTokens(struct ParseState *StartParser, struct ParseState *EndParser
|
||||||
{ /* non-interactive mode - copy the tokens */
|
{ /* non-interactive mode - copy the tokens */
|
||||||
MemSize = EndParser->Pos - StartParser->Pos;
|
MemSize = EndParser->Pos - StartParser->Pos;
|
||||||
NewTokens = VariableAlloc(StartParser, MemSize + 1, TRUE);
|
NewTokens = VariableAlloc(StartParser, MemSize + 1, TRUE);
|
||||||
memcpy(NewTokens, StartParser->Pos, MemSize);
|
memcpy(NewTokens, (void *)StartParser->Pos, MemSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* we're in interactive mode - add up line by line */
|
{ /* 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 */
|
{ /* all on a single line */
|
||||||
MemSize = EndParser->Pos - StartParser->Pos;
|
MemSize = EndParser->Pos - StartParser->Pos;
|
||||||
NewTokens = VariableAlloc(StartParser, MemSize + 1, TRUE);
|
NewTokens = VariableAlloc(StartParser, MemSize + 1, TRUE);
|
||||||
memcpy(NewTokens, StartParser->Pos, MemSize);
|
memcpy(NewTokens, (void *)StartParser->Pos, MemSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* it's spread across multiple lines */
|
{ /* 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 - make assignment a separate function
|
||||||
// XXX - also arrays need cleverer assignment
|
// 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;
|
Parser->Mode = RunModeReturn;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
8
picoc.c
8
picoc.c
|
@ -54,8 +54,6 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# ifdef SURVEYOR_HOST
|
# ifdef SURVEYOR_HOST
|
||||||
int errjmp[41];
|
|
||||||
|
|
||||||
int picoc(char *SourceStr)
|
int picoc(char *SourceStr)
|
||||||
{
|
{
|
||||||
int ix;
|
int ix;
|
||||||
|
@ -68,9 +66,9 @@ int picoc(char *SourceStr)
|
||||||
printf("%s\n\r", SourceStr); // display program source
|
printf("%s\n\r", SourceStr); // display program source
|
||||||
printf("=====================\n");
|
printf("=====================\n");
|
||||||
}
|
}
|
||||||
errjmp[40] = 0;
|
ExitBuf[40] = 0;
|
||||||
setjmp(errjmp);
|
PlatformSetExitPoint();
|
||||||
if (errjmp[40]) {
|
if (ExitBuf[40]) {
|
||||||
printf("leaving picoC\n\r");
|
printf("leaving picoC\n\r");
|
||||||
Cleanup();
|
Cleanup();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -70,6 +70,9 @@ extern jmp_buf ExitBuf;
|
||||||
# define INTERACTIVE_PROMPT_LINE "- "
|
# define INTERACTIVE_PROMPT_LINE "- "
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
extern int ExitBuf[];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* PLATFORM_H */
|
#endif /* PLATFORM_H */
|
||||||
|
|
|
@ -43,12 +43,13 @@ int PlatformGetCharacter()
|
||||||
return getch();
|
return getch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exit the program */
|
/* mark where to end the program for platforms which require this */
|
||||||
extern int errjmp[];
|
int ExitBuf[41];
|
||||||
|
|
||||||
|
/* exit the program */
|
||||||
void PlatformExit()
|
void PlatformExit()
|
||||||
{
|
{
|
||||||
errjmp[40] = 1;
|
ExitBuf[40] = 1;
|
||||||
longjmp(errjmp, 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->Size = Size;
|
||||||
Tbl->OnHeap = OnHeap;
|
Tbl->OnHeap = OnHeap;
|
||||||
Tbl->HashTable = HashTable;
|
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 */
|
/* 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)
|
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 */
|
return Entry; /* found */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ char *TableSetIdentifier(struct Table *Tbl, const char *Ident, int IdentLen)
|
||||||
if (NewEntry == NULL)
|
if (NewEntry == NULL)
|
||||||
ProgramFail(NULL, "out of memory");
|
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->p.Key[IdentLen] = '\0';
|
||||||
NewEntry->Next = Tbl->HashTable[AddAt];
|
NewEntry->Next = Tbl->HashTable[AddAt];
|
||||||
Tbl->HashTable[AddAt] = NewEntry;
|
Tbl->HashTable[AddAt] = NewEntry;
|
||||||
|
@ -152,7 +152,7 @@ char *TableStrRegister2(const char *Str, int Len)
|
||||||
|
|
||||||
char *TableStrRegister(const char *Str)
|
char *TableStrRegister(const char *Str)
|
||||||
{
|
{
|
||||||
return TableStrRegister2(Str, strlen(Str));
|
return TableStrRegister2(Str, strlen((char *)Str));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free all the strings */
|
/* 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);
|
LexGetToken(Parser, NULL, TRUE);
|
||||||
(*Typ)->Members = &GlobalTable;
|
(*Typ)->Members = &GlobalTable;
|
||||||
memset(&InitValue, '\0', sizeof(struct Value));
|
memset((void *)&InitValue, '\0', sizeof(struct Value));
|
||||||
InitValue.Typ = &IntType;
|
InitValue.Typ = &IntType;
|
||||||
InitValue.Val = (union AnyValue *)&EnumValue;
|
InitValue.Val = (union AnyValue *)&EnumValue;
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -120,7 +120,7 @@ struct Value *VariableAllocValueAndCopy(struct ParseState *Parser, struct Value
|
||||||
int CopySize = TypeSizeValue(FromValue);
|
int CopySize = TypeSizeValue(FromValue);
|
||||||
struct Value *NewValue = VariableAllocValueAndData(Parser, CopySize, FromValue->IsLValue, FromValue->LValueFrom, OnHeap);
|
struct Value *NewValue = VariableAllocValueAndData(Parser, CopySize, FromValue->IsLValue, FromValue->LValueFrom, OnHeap);
|
||||||
NewValue->Typ = FromValue->Typ;
|
NewValue->Typ = FromValue->Typ;
|
||||||
memcpy(NewValue->Val, FromValue->Val, CopySize);
|
memcpy((void *)NewValue->Val, (void *)FromValue->Val, CopySize);
|
||||||
return NewValue;
|
return NewValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue