Fixes for a clean surveyor compile
git-svn-id: http://picoc.googlecode.com/svn/trunk@253 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
a07c3ed286
commit
7c2ce7290a
20
expression.c
20
expression.c
|
@ -180,6 +180,7 @@ void ExpressionPushInt(struct ParseState *Parser, struct ExpressionStack **Stack
|
|||
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
||||
}
|
||||
|
||||
#ifndef NO_FP
|
||||
void ExpressionPushFP(struct ParseState *Parser, struct ExpressionStack **StackTop, double FPValue)
|
||||
{
|
||||
debugf("ExpressionPushFP()\n");
|
||||
|
@ -187,6 +188,7 @@ void ExpressionPushFP(struct ParseState *Parser, struct ExpressionStack **StackT
|
|||
ValueLoc->Val->FP = FPValue;
|
||||
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* evaluate a prefix operator */
|
||||
void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack **StackTop, enum LexToken Op, struct Value *TopValue)
|
||||
|
@ -240,7 +242,7 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
if (IS_INTEGER_COERCIBLE(TopValue))
|
||||
{
|
||||
/* integer prefix arithmetic */
|
||||
int ResultInt;
|
||||
int ResultInt = 0;
|
||||
int TopInt = COERCE_INTEGER(TopValue);
|
||||
switch (Op)
|
||||
{
|
||||
|
@ -293,7 +295,7 @@ void ExpressionPostfixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
debugf("ExpressionPostfixOperator()\n");
|
||||
if (IS_INTEGER_COERCIBLE(TopValue))
|
||||
{
|
||||
int ResultInt;
|
||||
int ResultInt = 0;
|
||||
int TopInt = COERCE_INTEGER(TopValue);
|
||||
switch (Op)
|
||||
{
|
||||
|
@ -311,8 +313,7 @@ void ExpressionPostfixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
/* evaluate an infix operator */
|
||||
void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack **StackTop, enum LexToken Op, struct Value *BottomValue, struct Value *TopValue)
|
||||
{
|
||||
int ResultIsInt = FALSE;
|
||||
int ResultInt;
|
||||
int ResultInt = 0;
|
||||
|
||||
if (Parser->Mode != RunModeRun)
|
||||
{
|
||||
|
@ -354,7 +355,9 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
case TokenSubtractAssign: ASSIGN_INT(BottomValue, BottomInt - TopInt); break;
|
||||
case TokenMultiplyAssign: ASSIGN_INT(BottomValue, BottomInt * TopInt); break;
|
||||
case TokenDivideAssign: ASSIGN_INT(BottomValue, BottomInt / TopInt); break;
|
||||
#ifndef NO_MODULUS
|
||||
case TokenModulusAssign: ASSIGN_INT(BottomValue, BottomInt % TopInt); break;
|
||||
#endif
|
||||
case TokenShiftLeftAssign: ASSIGN_INT(BottomValue, BottomInt << TopInt); break;
|
||||
case TokenShiftRightAssign: ASSIGN_INT(BottomValue, BottomInt >> TopInt); break;
|
||||
case TokenArithmeticAndAssign: ASSIGN_INT(BottomValue, BottomInt & TopInt); break;
|
||||
|
@ -379,7 +382,9 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
case TokenMinus: ResultInt = BottomInt - TopInt; break;
|
||||
case TokenAsterisk: ResultInt = BottomInt * TopInt; break;
|
||||
case TokenSlash: ResultInt = BottomInt / TopInt; break;
|
||||
#ifndef NO_MODULUS
|
||||
case TokenModulus: ResultInt = BottomInt % TopInt; break;
|
||||
#endif
|
||||
default: ProgramFail(Parser, "invalid operation"); break;
|
||||
}
|
||||
|
||||
|
@ -391,7 +396,8 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
(IS_INTEGER_COERCIBLE(TopValue) && BottomValue->Typ == &FPType) )
|
||||
{
|
||||
/* floating point infix arithmetic */
|
||||
double ResultFP;
|
||||
int ResultIsInt = FALSE;
|
||||
double ResultFP = 0.0;
|
||||
double TopFP = (TopValue->Typ == &FPType) ? TopValue->Val->FP : (double)COERCE_INTEGER(TopValue);
|
||||
double BottomFP = (BottomValue->Typ == &FPType) ? BottomValue->Val->FP : (double)COERCE_INTEGER(BottomValue);
|
||||
|
||||
|
@ -456,7 +462,7 @@ XXX - finish this
|
|||
if (BottomValue->Typ != TopValue->Typ)
|
||||
ProgramFail(Parser, "can't assign to a different type of variable");
|
||||
|
||||
memcpy(BottomValue->Val, TopValue->Val, TypeSizeValue(TopValue));
|
||||
memcpy((void *)BottomValue->Val, (void *)TopValue->Val, TypeSizeValue(TopValue)); // XXX - need to handle arrays
|
||||
ExpressionStackPushValue(Parser, StackTop, TopValue);
|
||||
}
|
||||
else
|
||||
|
@ -794,7 +800,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
/* do a function call */
|
||||
void ExpressionParseFunctionCall(struct ParseState *Parser, struct ExpressionStack **StackTop, const char *FuncName)
|
||||
{
|
||||
struct Value *ReturnValue;
|
||||
struct Value *ReturnValue = NULL;
|
||||
struct Value *FuncValue;
|
||||
struct Value *Param;
|
||||
struct Value **ParamArray = NULL;
|
||||
|
|
2
heap.c
2
heap.c
|
@ -9,7 +9,7 @@
|
|||
static unsigned char *HeapMemory = (unsigned char *)C_HEAPSTART; /* all memory - stack and heap */
|
||||
static void *HeapBottom = (void *)C_HEAPSTART + HEAP_SIZE; /* the bottom of the (downward-growing) heap */
|
||||
static void *StackFrame = (void *)C_HEAPSTART; /* the current stack frame */
|
||||
static void *HeapStackTop = (void *)C_HEAPSTART; /* the top of the stack */
|
||||
void *HeapStackTop = (void *)C_HEAPSTART; /* the top of the stack */
|
||||
#else
|
||||
static unsigned char HeapMemory[HEAP_SIZE]; /* all memory - stack and heap */
|
||||
static void *HeapBottom = &HeapMemory[HEAP_SIZE]; /* the bottom of the (downward-growing) heap */
|
||||
|
|
|
@ -283,18 +283,18 @@ void Cvpix(struct ParseState *Parser, struct Value *ReturnValue, struct Value **
|
|||
x = Param[0]->Val->Integer;
|
||||
y = Param[1]->Val->Integer;
|
||||
ix = vpix((unsigned char *)FRAME_BUF, x, y);
|
||||
Iy1 = ((ix>>16) & 0x000000FF); // Y1
|
||||
Iu1 = ((ix>>24) & 0x000000FF); // U
|
||||
Iv1 = ((ix>>8) & 0x000000FF); // V
|
||||
Iy1 = ((ix>>16) & 0x000000FF); // Y1
|
||||
Iu1 = ((ix>>24) & 0x000000FF); // U
|
||||
Iv1 = ((ix>>8) & 0x000000FF); // V
|
||||
}
|
||||
|
||||
void Cvmean(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
vmean((unsigned char *)FRAME_BUF);
|
||||
vmean((unsigned char *)FRAME_BUF);
|
||||
Iy1 = mean[0];
|
||||
Iu1 = mean[1];
|
||||
Iv1 = mean[2];
|
||||
}
|
||||
}
|
||||
|
||||
// search for blob by color, index; return center point X,Y and width Z
|
||||
void Cvblob(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
|
@ -331,10 +331,20 @@ void Ccompass(struct ParseState *Parser, struct Value *ReturnValue, struct Value
|
|||
delayMS(10);
|
||||
i2c_data[0] = 0x41;
|
||||
i2cread(0x22, (unsigned char *)i2c_data, 2, SCCB_ON);
|
||||
ix = ((i2c_data[0] << 8) + i2c_data[1]) / 10;
|
||||
ix = ((unsigned int)(i2c_data[0] << 8) + i2c_data[1]) / 10;
|
||||
ReturnValue->Val->Integer = ix;
|
||||
}
|
||||
|
||||
void Ctilt(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) // return reading from HMC6352 I2C compass
|
||||
{
|
||||
unsigned int ix;
|
||||
|
||||
ix = (unsigned int)Param[0]->Val->Integer;
|
||||
if ((ix<1) || (ix>3))
|
||||
ProgramFail(NULL, "tilt(): invalid channel");
|
||||
ReturnValue->Val->Integer = tilt(ix);
|
||||
}
|
||||
|
||||
void Canalog(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) // return reading from HMC6352 I2C compass
|
||||
{
|
||||
unsigned char i2c_data[3], device_id;
|
||||
|
@ -666,7 +676,7 @@ void Cnnlearnblob (struct ParseState *Parser, struct Value *ReturnValue, struct
|
|||
bloby1[0], bloby2[0], imgWidth, imgHeight);
|
||||
nnpack8x8(ix);
|
||||
nndisplay(ix);
|
||||
}
|
||||
}
|
||||
|
||||
/* list of all library functions and their prototypes */
|
||||
struct LibraryFunction PlatformLibrary[] =
|
||||
|
@ -698,6 +708,7 @@ struct LibraryFunction PlatformLibrary[] =
|
|||
{ Cvblob, "int vblob(int, int)" },
|
||||
{ Ccompass, "int compass()" },
|
||||
{ Canalog, "int analog(int)" },
|
||||
{ Ctilt, "int tilt(int)" },
|
||||
{ Cgps, "void gps()" },
|
||||
{ Creadi2c, "int readi2c(int, int)" },
|
||||
{ Creadi2c2, "int readi2c2(int, int)" },
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -53,6 +53,7 @@ extern jmp_buf ExitBuf;
|
|||
# define NO_FP
|
||||
# define NO_CTYPE
|
||||
# define NO_HASH_INCLUDE
|
||||
# define NO_MODULUS
|
||||
# include <cdefBF537.h>
|
||||
# include "../string.h"
|
||||
# include "../print.h"
|
||||
|
|
Loading…
Reference in a new issue