From bd9cb90e022c474c6ff412540762dee1b4abe1d6 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Mon, 4 May 2009 12:02:16 +0000 Subject: [PATCH] Added the beginnings of flying fox platform support. Removed some annoying debug. Made it easier to compile unmodified on non-UNIX systems. git-svn-id: http://picoc.googlecode.com/svn/trunk@274 21eae674-98b7-11dd-bd71-f92a316d2d60 --- Makefile | 2 +- expression.c | 3 --- heap.c | 2 -- lex.c | 2 +- library_ffox.c | 12 ++++++++++++ platform.h | 17 ++++++++++++++--- platform_ffox.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 79 insertions(+), 10 deletions(-) create mode 100644 library_ffox.c create mode 100644 platform_ffox.c diff --git a/Makefile b/Makefile index 1bbf515..5ea242c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC=gcc -CFLAGS=-Wall -g +CFLAGS=-Wall -g -DUNIX_HOST LIBS=-lm TARGET = picoc diff --git a/expression.c b/expression.c index fa50d35..6cd035e 100644 --- a/expression.c +++ b/expression.c @@ -794,9 +794,6 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result) (Token == TokenCloseBracket && BracketPrecedence != 0)) && (Token != TokenColon || TernaryDepth != 0) ) { - if (Token == TokenColon) - printf("It's a colon\n"); - /* it's an operator with precedence */ if (PrefixState) { diff --git a/heap.c b/heap.c index f2b49e1..2fd6627 100644 --- a/heap.c +++ b/heap.c @@ -69,8 +69,6 @@ int HeapPopStack(void *Addr, int Size) return FALSE; HeapStackTop -= ToLose; - if (HeapStackTop != Addr) - printf("fail\n"); assert(HeapStackTop == Addr); return TRUE; diff --git a/lex.c b/lex.c index 6a71331..b09a2c0 100644 --- a/lex.c +++ b/lex.c @@ -501,7 +501,7 @@ void LexInitParser(struct ParseState *Parser, void *TokenSource, const char *Fil /* get the next token given a parser state */ enum LexToken LexGetToken(struct ParseState *Parser, struct Value **Value, int IncPos) { - enum LexToken Token; + enum LexToken Token = TokenNone; int ValueSize; do diff --git a/library_ffox.c b/library_ffox.c new file mode 100644 index 0000000..403fef6 --- /dev/null +++ b/library_ffox.c @@ -0,0 +1,12 @@ +#include "picoc.h" + +void PlatformLibraryInit() +{ +} + +/* list of all library functions and their prototypes */ +struct LibraryFunction PlatformLibrary[] = +{ + { NULL, NULL } +}; + diff --git a/platform.h b/platform.h index 01f8d23..2a07d67 100644 --- a/platform.h +++ b/platform.h @@ -3,9 +3,11 @@ #define PLATFORM_H /* configurable options */ -#define UNIX_HOST /* select your host type */ -#undef FLYINGFOX_HOST -#undef SURVEYOR_HOST +/* select your host type (or do it in the Makefile): + * #define UNIX_HOST + * #define FLYINGFOX_HOST + * #define SURVEYOR_HOST + */ #ifndef SURVEYOR_HOST #define HEAP_SIZE 16384 /* space for the heap and the stack */ @@ -47,6 +49,15 @@ extern jmp_buf ExitBuf; #else # ifdef FLYINGFOX_HOST +# define NO_HASH_INCLUDE +# include +# include +# include +# include +# include +# include +# include +# define assert(x) # else # ifdef SURVEYOR_HOST diff --git a/platform_ffox.c b/platform_ffox.c new file mode 100644 index 0000000..86079da --- /dev/null +++ b/platform_ffox.c @@ -0,0 +1,51 @@ +#include "picoc.h" + +/* deallocate any storage */ +void PlatformCleanup() +{ +} + +/* get a line of interactive input */ +char *PlatformGetLine(char *Buf, int MaxLen) +{ + // XXX - unimplemented so far + return NULL; +} + +/* get a character of interactive input */ +int PlatformGetCharacter() +{ + // XXX - unimplemented so far + return 0; +} + +/* write a character to the console */ +void PlatformPutc(unsigned char OutCh, union OutputStreamInfo *Stream) +{ + // XXX - unimplemented so far +} + +/* read a file into memory */ +char *PlatformReadFile(const char *FileName) +{ + // XXX - unimplemented so far + return NULL; +} + +/* read and scan a file for definitions */ +void PlatformScanFile(const char *FileName) +{ + char *SourceStr = PlatformReadFile(FileName); + Parse(FileName, SourceStr, strlen(SourceStr), TRUE); + //free(SourceStr); +} + +/* mark where to end the program for platforms which require this */ +jmp_buf ExitBuf; + +/* exit the program */ +void PlatformExit() +{ + longjmp(ExitBuf, 1); +} +