PICOC_VERSION is now defined as a macro in picoc

git-svn-id: http://picoc.googlecode.com/svn/trunk@528 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2011-02-14 23:42:54 +00:00
parent ea6f2c006a
commit e17f6f955f
5 changed files with 31 additions and 6 deletions

View file

@ -16,11 +16,18 @@ all: depend $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
# rebuild the version number every time so we always have the
# correct subversion version
version.h:
echo "#define PICOC_SUBVERSION_VERSION \"`svnversion`\"" > version.h
.PHONY: version.h
test: all
(cd tests; make test)
clean:
rm -f $(TARGET) $(OBJS) *~
rm -f $(TARGET) $(OBJS) version.h *~
count:
@echo "Core:"
@ -30,6 +37,7 @@ count:
@cat $(SRCS) *.h */*.h | wc
depend:
touch version.h
$(CC) -MM $(SRCS) >.depend
-include .depend

View file

@ -1,7 +1,21 @@
#include "picoc.h"
#include "version.h"
/* initialise a library */
void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList)
/* the picoc version string */
#define PICOC_VERSION "v2.1 beta r" PICOC_SUBVERSION_VERSION
static const char *VersionString = NULL;
/* global initialisation for libraries */
void LibraryInit()
{
/* define the version number macro */
VersionString = TableStrRegister(PICOC_VERSION);
VariableDefinePlatformVar(NULL, "PICOC_VERSION", CharPtrType, (union AnyValue *)&VersionString, FALSE);
}
/* add a library */
void LibraryAdd(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList)
{
struct ParseState Parser;
int Count;
@ -11,6 +25,7 @@ void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct Libr
void *Tokens;
const char *IntrinsicName = TableStrRegister("c library");
/* read all the library definitions */
for (Count = 0; FuncList[Count].Prototype != NULL; Count++)
{
Tokens = LexAnalyse(IntrinsicName, FuncList[Count].Prototype, strlen((char *)FuncList[Count].Prototype), NULL);

View file

@ -95,7 +95,7 @@ void IncludeFile(char *FileName)
/* set up the library functions */
if (LInclude->FuncList != NULL)
LibraryInit(&GlobalTable, FileName, LInclude->FuncList);
LibraryAdd(&GlobalTable, FileName, LInclude->FuncList);
}
return;

View file

@ -17,8 +17,9 @@ void Initialise(int StackSize)
#ifndef NO_HASH_INCLUDE
IncludeInit();
#endif
LibraryInit();
#ifdef BUILTIN_MINI_STDLIB
LibraryInit(&GlobalTable, "c library", &CLibrary[0]);
LibraryAdd(&GlobalTable, "c library", &CLibrary[0]);
CLibraryInit();
#endif
PlatformLibraryInit();

View file

@ -408,7 +408,8 @@ void *VariableDereferencePointer(struct ParseState *Parser, struct Value *Pointe
/* clibrary.c */
void BasicIOInit();
void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList);
void LibraryInit();
void LibraryAdd(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList);
void CLibraryInit();
void PrintCh(char OutCh, IOFILE *Stream);
void PrintSimpleInt(long Num, IOFILE *Stream);