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);
|
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_FP
|
||||||
void ExpressionPushFP(struct ParseState *Parser, struct ExpressionStack **StackTop, double FPValue)
|
void ExpressionPushFP(struct ParseState *Parser, struct ExpressionStack **StackTop, double FPValue)
|
||||||
{
|
{
|
||||||
debugf("ExpressionPushFP()\n");
|
debugf("ExpressionPushFP()\n");
|
||||||
|
@ -187,6 +188,7 @@ void ExpressionPushFP(struct ParseState *Parser, struct ExpressionStack **StackT
|
||||||
ValueLoc->Val->FP = FPValue;
|
ValueLoc->Val->FP = FPValue;
|
||||||
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* evaluate a prefix operator */
|
/* evaluate a prefix operator */
|
||||||
void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack **StackTop, enum LexToken Op, struct Value *TopValue)
|
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))
|
if (IS_INTEGER_COERCIBLE(TopValue))
|
||||||
{
|
{
|
||||||
/* integer prefix arithmetic */
|
/* integer prefix arithmetic */
|
||||||
int ResultInt;
|
int ResultInt = 0;
|
||||||
int TopInt = COERCE_INTEGER(TopValue);
|
int TopInt = COERCE_INTEGER(TopValue);
|
||||||
switch (Op)
|
switch (Op)
|
||||||
{
|
{
|
||||||
|
@ -293,7 +295,7 @@ void ExpressionPostfixOperator(struct ParseState *Parser, struct ExpressionStack
|
||||||
debugf("ExpressionPostfixOperator()\n");
|
debugf("ExpressionPostfixOperator()\n");
|
||||||
if (IS_INTEGER_COERCIBLE(TopValue))
|
if (IS_INTEGER_COERCIBLE(TopValue))
|
||||||
{
|
{
|
||||||
int ResultInt;
|
int ResultInt = 0;
|
||||||
int TopInt = COERCE_INTEGER(TopValue);
|
int TopInt = COERCE_INTEGER(TopValue);
|
||||||
switch (Op)
|
switch (Op)
|
||||||
{
|
{
|
||||||
|
@ -311,8 +313,7 @@ void ExpressionPostfixOperator(struct ParseState *Parser, struct ExpressionStack
|
||||||
/* evaluate an infix operator */
|
/* evaluate an infix operator */
|
||||||
void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack **StackTop, enum LexToken Op, struct Value *BottomValue, struct Value *TopValue)
|
void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack **StackTop, enum LexToken Op, struct Value *BottomValue, struct Value *TopValue)
|
||||||
{
|
{
|
||||||
int ResultIsInt = FALSE;
|
int ResultInt = 0;
|
||||||
int ResultInt;
|
|
||||||
|
|
||||||
if (Parser->Mode != RunModeRun)
|
if (Parser->Mode != RunModeRun)
|
||||||
{
|
{
|
||||||
|
@ -354,7 +355,9 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
||||||
case TokenSubtractAssign: ASSIGN_INT(BottomValue, BottomInt - TopInt); break;
|
case TokenSubtractAssign: ASSIGN_INT(BottomValue, BottomInt - TopInt); break;
|
||||||
case TokenMultiplyAssign: ASSIGN_INT(BottomValue, BottomInt * TopInt); break;
|
case TokenMultiplyAssign: ASSIGN_INT(BottomValue, BottomInt * TopInt); break;
|
||||||
case TokenDivideAssign: 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;
|
case TokenModulusAssign: ASSIGN_INT(BottomValue, BottomInt % TopInt); break;
|
||||||
|
#endif
|
||||||
case TokenShiftLeftAssign: ASSIGN_INT(BottomValue, BottomInt << TopInt); break;
|
case TokenShiftLeftAssign: ASSIGN_INT(BottomValue, BottomInt << TopInt); break;
|
||||||
case TokenShiftRightAssign: ASSIGN_INT(BottomValue, BottomInt >> TopInt); break;
|
case TokenShiftRightAssign: ASSIGN_INT(BottomValue, BottomInt >> TopInt); break;
|
||||||
case TokenArithmeticAndAssign: 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 TokenMinus: ResultInt = BottomInt - TopInt; break;
|
||||||
case TokenAsterisk: ResultInt = BottomInt * TopInt; break;
|
case TokenAsterisk: ResultInt = BottomInt * TopInt; break;
|
||||||
case TokenSlash: ResultInt = BottomInt / TopInt; break;
|
case TokenSlash: ResultInt = BottomInt / TopInt; break;
|
||||||
|
#ifndef NO_MODULUS
|
||||||
case TokenModulus: ResultInt = BottomInt % TopInt; break;
|
case TokenModulus: ResultInt = BottomInt % TopInt; break;
|
||||||
|
#endif
|
||||||
default: ProgramFail(Parser, "invalid operation"); break;
|
default: ProgramFail(Parser, "invalid operation"); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +396,8 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
||||||
(IS_INTEGER_COERCIBLE(TopValue) && BottomValue->Typ == &FPType) )
|
(IS_INTEGER_COERCIBLE(TopValue) && BottomValue->Typ == &FPType) )
|
||||||
{
|
{
|
||||||
/* floating point infix arithmetic */
|
/* 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 TopFP = (TopValue->Typ == &FPType) ? TopValue->Val->FP : (double)COERCE_INTEGER(TopValue);
|
||||||
double BottomFP = (BottomValue->Typ == &FPType) ? BottomValue->Val->FP : (double)COERCE_INTEGER(BottomValue);
|
double BottomFP = (BottomValue->Typ == &FPType) ? BottomValue->Val->FP : (double)COERCE_INTEGER(BottomValue);
|
||||||
|
|
||||||
|
@ -456,7 +462,7 @@ XXX - finish this
|
||||||
if (BottomValue->Typ != TopValue->Typ)
|
if (BottomValue->Typ != TopValue->Typ)
|
||||||
ProgramFail(Parser, "can't assign to a different type of variable");
|
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);
|
ExpressionStackPushValue(Parser, StackTop, TopValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -794,7 +800,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
||||||
/* do a function call */
|
/* do a function call */
|
||||||
void ExpressionParseFunctionCall(struct ParseState *Parser, struct ExpressionStack **StackTop, const char *FuncName)
|
void ExpressionParseFunctionCall(struct ParseState *Parser, struct ExpressionStack **StackTop, const char *FuncName)
|
||||||
{
|
{
|
||||||
struct Value *ReturnValue;
|
struct Value *ReturnValue = NULL;
|
||||||
struct Value *FuncValue;
|
struct Value *FuncValue;
|
||||||
struct Value *Param;
|
struct Value *Param;
|
||||||
struct Value **ParamArray = NULL;
|
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 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 *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 *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
|
#else
|
||||||
static unsigned char HeapMemory[HEAP_SIZE]; /* all memory - stack and heap */
|
static unsigned char HeapMemory[HEAP_SIZE]; /* all memory - stack and heap */
|
||||||
static void *HeapBottom = &HeapMemory[HEAP_SIZE]; /* the bottom of the (downward-growing) heap */
|
static void *HeapBottom = &HeapMemory[HEAP_SIZE]; /* the bottom of the (downward-growing) heap */
|
||||||
|
|
|
@ -331,10 +331,20 @@ void Ccompass(struct ParseState *Parser, struct Value *ReturnValue, struct Value
|
||||||
delayMS(10);
|
delayMS(10);
|
||||||
i2c_data[0] = 0x41;
|
i2c_data[0] = 0x41;
|
||||||
i2cread(0x22, (unsigned char *)i2c_data, 2, SCCB_ON);
|
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;
|
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
|
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;
|
unsigned char i2c_data[3], device_id;
|
||||||
|
@ -698,6 +708,7 @@ struct LibraryFunction PlatformLibrary[] =
|
||||||
{ Cvblob, "int vblob(int, int)" },
|
{ Cvblob, "int vblob(int, int)" },
|
||||||
{ Ccompass, "int compass()" },
|
{ Ccompass, "int compass()" },
|
||||||
{ Canalog, "int analog(int)" },
|
{ Canalog, "int analog(int)" },
|
||||||
|
{ Ctilt, "int tilt(int)" },
|
||||||
{ Cgps, "void gps()" },
|
{ Cgps, "void gps()" },
|
||||||
{ Creadi2c, "int readi2c(int, int)" },
|
{ Creadi2c, "int readi2c(int, int)" },
|
||||||
{ Creadi2c2, "int readi2c2(int, int)" },
|
{ Creadi2c2, "int readi2c2(int, int)" },
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <memory.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -53,6 +53,7 @@ extern jmp_buf ExitBuf;
|
||||||
# define NO_FP
|
# define NO_FP
|
||||||
# define NO_CTYPE
|
# define NO_CTYPE
|
||||||
# define NO_HASH_INCLUDE
|
# define NO_HASH_INCLUDE
|
||||||
|
# define NO_MODULUS
|
||||||
# include <cdefBF537.h>
|
# include <cdefBF537.h>
|
||||||
# include "../string.h"
|
# include "../string.h"
|
||||||
# include "../print.h"
|
# include "../print.h"
|
||||||
|
|
Loading…
Reference in a new issue