Fixes for Surveyor SRV-1 platform
git-svn-id: http://picoc.googlecode.com/svn/trunk@398 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
83ded6eb54
commit
d09e156558
12
clibrary.c
12
clibrary.c
|
@ -425,15 +425,19 @@ void LibMalloc(struct ParseState *Parser, struct Value *ReturnValue, struct Valu
|
||||||
ReturnValue->Val->NativePointer = malloc(Param[0]->Val->Integer);
|
ReturnValue->Val->NativePointer = malloc(Param[0]->Val->Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_CALLOC
|
||||||
void LibCalloc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibCalloc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->NativePointer = calloc(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
ReturnValue->Val->NativePointer = calloc(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_REALLOC
|
||||||
void LibRealloc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibRealloc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->NativePointer = realloc(Param[0]->Val->NativePointer, Param[1]->Val->Integer);
|
ReturnValue->Val->NativePointer = realloc(Param[0]->Val->NativePointer, Param[1]->Val->Integer);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void LibFree(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibFree(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
|
@ -603,11 +607,15 @@ struct LibraryFunction CLibrary[] =
|
||||||
{ LibCeil, "float ceil(float)" },
|
{ LibCeil, "float ceil(float)" },
|
||||||
{ LibFloor, "float floor(float)" },
|
{ LibFloor, "float floor(float)" },
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_STRING_FUNCTIONS
|
|
||||||
{ LibMalloc, "void *malloc(int)" },
|
{ LibMalloc, "void *malloc(int)" },
|
||||||
|
#ifndef NO_CALLOC
|
||||||
{ LibCalloc, "void *calloc(int,int)" },
|
{ LibCalloc, "void *calloc(int,int)" },
|
||||||
{ LibCalloc, "void *realloc(void *,int)" },
|
#endif
|
||||||
|
#ifndef NO_REALLOC
|
||||||
|
{ LibRealloc, "void *realloc(void *,int)" },
|
||||||
|
#endif
|
||||||
{ LibFree, "void free(void *)" },
|
{ LibFree, "void free(void *)" },
|
||||||
|
#ifndef NO_STRING_FUNCTIONS
|
||||||
{ LibStrcpy, "void strcpy(char *,char *)" },
|
{ LibStrcpy, "void strcpy(char *,char *)" },
|
||||||
{ LibStrncpy, "void strncpy(char *,char *,int)" },
|
{ LibStrncpy, "void strncpy(char *,char *,int)" },
|
||||||
{ LibStrcmp, "int strcmp(char *,char *)" },
|
{ LibStrcmp, "int strcmp(char *,char *)" },
|
||||||
|
|
26
expression.c
26
expression.c
|
@ -171,8 +171,26 @@ unsigned long ExpressionCoerceUnsignedInteger(struct Value *Val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_FP
|
||||||
double ExpressionCoerceFP(struct Value *Val)
|
double ExpressionCoerceFP(struct Value *Val)
|
||||||
{
|
{
|
||||||
|
#ifndef BROKEN_FLOAT_CASTS
|
||||||
|
int IntVal;
|
||||||
|
unsigned UnsignedVal;
|
||||||
|
|
||||||
|
switch (Val->Typ->Base)
|
||||||
|
{
|
||||||
|
case TypeInt: IntVal = Val->Val->Integer; return (double)IntVal;
|
||||||
|
case TypeChar: IntVal = Val->Val->Character; return (double)IntVal;
|
||||||
|
case TypeShort: IntVal = Val->Val->ShortInteger; return (double)IntVal;
|
||||||
|
case TypeLong: IntVal = Val->Val->LongInteger; return (double)IntVal;
|
||||||
|
case TypeUnsignedInt: UnsignedVal = Val->Val->UnsignedInteger; return (double)UnsignedVal;
|
||||||
|
case TypeUnsignedShort: UnsignedVal = Val->Val->UnsignedShortInteger; return (double)UnsignedVal;
|
||||||
|
case TypeUnsignedLong: UnsignedVal = Val->Val->UnsignedLongInteger; return (double)UnsignedVal;
|
||||||
|
case TypeFP: return Val->Val->FP;
|
||||||
|
default: return 0.0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
switch (Val->Typ->Base)
|
switch (Val->Typ->Base)
|
||||||
{
|
{
|
||||||
case TypeInt: return (double)Val->Val->Integer;
|
case TypeInt: return (double)Val->Val->Integer;
|
||||||
|
@ -182,12 +200,12 @@ double ExpressionCoerceFP(struct Value *Val)
|
||||||
case TypeUnsignedInt: return (double)Val->Val->UnsignedInteger;
|
case TypeUnsignedInt: return (double)Val->Val->UnsignedInteger;
|
||||||
case TypeUnsignedShort: return (double)Val->Val->UnsignedShortInteger;
|
case TypeUnsignedShort: return (double)Val->Val->UnsignedShortInteger;
|
||||||
case TypeUnsignedLong: return (double)Val->Val->UnsignedLongInteger;
|
case TypeUnsignedLong: return (double)Val->Val->UnsignedLongInteger;
|
||||||
#ifndef NO_FP
|
|
||||||
case TypeFP: return (double)Val->Val->FP;
|
case TypeFP: return (double)Val->Val->FP;
|
||||||
#endif
|
default: return 0.0;
|
||||||
default: return 0;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* assign an integer value */
|
/* assign an integer value */
|
||||||
long ExpressionAssignInt(struct ParseState *Parser, struct Value *DestValue, long FromInt, int After)
|
long ExpressionAssignInt(struct ParseState *Parser, struct Value *DestValue, long FromInt, int After)
|
||||||
|
@ -574,7 +592,7 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
||||||
{
|
{
|
||||||
/* array index */
|
/* array index */
|
||||||
int ArrayIndex;
|
int ArrayIndex;
|
||||||
struct Value *Result;
|
struct Value *Result = NULL;
|
||||||
|
|
||||||
if (!IS_NUMERIC_COERCIBLE(TopValue))
|
if (!IS_NUMERIC_COERCIBLE(TopValue))
|
||||||
ProgramFail(Parser, "array index must be an integer");
|
ProgramFail(Parser, "array index must be an integer");
|
||||||
|
|
2
heap.c
2
heap.c
|
@ -65,7 +65,7 @@ void *HeapAllocStack(int Size)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
HeapStackTop = (void *)NewTop;
|
HeapStackTop = (void *)NewTop;
|
||||||
memset(NewMem, '\0', Size);
|
memset((void *)NewMem, '\0', Size);
|
||||||
return NewMem;
|
return NewMem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
lex.c
2
lex.c
|
@ -482,7 +482,7 @@ void *LexTokenise(struct LexState *Lexer, int *TokenLen)
|
||||||
if (ValueSize > 0)
|
if (ValueSize > 0)
|
||||||
{
|
{
|
||||||
/* store a value as well */
|
/* store a value as well */
|
||||||
memcpy(TokenPos, (void *)GotValue->Val, ValueSize);
|
memcpy((void *)TokenPos, (void *)GotValue->Val, ValueSize);
|
||||||
TokenPos += ValueSize;
|
TokenPos += ValueSize;
|
||||||
MemUsed += ValueSize;
|
MemUsed += ValueSize;
|
||||||
}
|
}
|
||||||
|
|
4
parse.c
4
parse.c
|
@ -123,7 +123,7 @@ void ParseDeclarationAssignment(struct ParseState *Parser, struct Value *NewVari
|
||||||
|
|
||||||
for (ArrayIndex = 0; ArrayIndex < NewVariable->Typ->ArraySize; ArrayIndex++)
|
for (ArrayIndex = 0; ArrayIndex < NewVariable->Typ->ArraySize; ArrayIndex++)
|
||||||
{
|
{
|
||||||
struct Value *ArrayElement;
|
struct Value *ArrayElement = NULL;
|
||||||
|
|
||||||
if (Token != TokenComma)
|
if (Token != TokenComma)
|
||||||
ProgramFail(Parser, "comma expected");
|
ProgramFail(Parser, "comma expected");
|
||||||
|
@ -170,7 +170,7 @@ int ParseDeclaration(struct ParseState *Parser, enum LexToken Token)
|
||||||
char *Identifier;
|
char *Identifier;
|
||||||
struct ValueType *BasicType;
|
struct ValueType *BasicType;
|
||||||
struct ValueType *Typ;
|
struct ValueType *Typ;
|
||||||
struct Value *NewVariable;
|
struct Value *NewVariable = NULL;
|
||||||
|
|
||||||
TypeParseFront(Parser, &BasicType);
|
TypeParseFront(Parser, &BasicType);
|
||||||
do
|
do
|
||||||
|
|
|
@ -93,12 +93,16 @@ extern jmp_buf ExitBuf;
|
||||||
# include "../gps.h"
|
# include "../gps.h"
|
||||||
# include "../i2c.h"
|
# include "../i2c.h"
|
||||||
# include "../jpeg.h"
|
# include "../jpeg.h"
|
||||||
|
# include "../malloc.h"
|
||||||
# define assert(x)
|
# define assert(x)
|
||||||
# undef INTERACTIVE_PROMPT_STATEMENT
|
# undef INTERACTIVE_PROMPT_STATEMENT
|
||||||
# undef INTERACTIVE_PROMPT_LINE
|
# undef INTERACTIVE_PROMPT_LINE
|
||||||
# define INTERACTIVE_PROMPT_STATEMENT "> "
|
# define INTERACTIVE_PROMPT_STATEMENT "> "
|
||||||
# define INTERACTIVE_PROMPT_LINE "- "
|
# define INTERACTIVE_PROMPT_LINE "- "
|
||||||
# undef BIG_ENDIAN
|
# undef BIG_ENDIAN
|
||||||
|
# define NO_CALLOC
|
||||||
|
# define NO_REALLOC
|
||||||
|
# define BROKEN_FLOAT_CASTS
|
||||||
# else
|
# else
|
||||||
# ifdef UMON_HOST
|
# ifdef UMON_HOST
|
||||||
# define HEAP_SIZE (128*1024) /* space for the heap and the stack */
|
# define HEAP_SIZE (128*1024) /* space for the heap and the stack */
|
||||||
|
|
Loading…
Reference in a new issue