library struct example for Howard

git-svn-id: http://picoc.googlecode.com/svn/trunk@219 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2009-04-07 10:48:46 +00:00
parent 61e93e4774
commit 16922d2e73
3 changed files with 4 additions and 7 deletions

View file

@ -2,7 +2,6 @@
void PlatformLibraryInit()
{
#if 0
struct ParseState Parser;
char *Identifier;
struct ValueType *ParsedType;
@ -15,12 +14,10 @@ void PlatformLibraryInit()
LexInitParser(&Parser, Tokens, IntrinsicName, 1, TRUE);
TypeParse(&Parser, &ParsedType, &Identifier);
HeapFree(Tokens);
#endif
}
void ShowComplex(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
{
#if 0
struct Value *ComplexVal = Param[0]->Val->Pointer.Segment; /* dereferences the pointer */
struct Value *RealOffset;
struct Value *ComplexOffset;
@ -29,7 +26,7 @@ void ShowComplex(struct ParseState *Parser, struct Value *ReturnValue, struct Va
struct ValueType *StructComplexType;
/* find the type */
StructComplexType = TypeGetMatching(Parser, NULL, TypeStruct, 0, TableStrRegister("complex"));
StructComplexType = TypeGetMatching(Parser, &UberType, TypeStruct, 0, TableStrRegister("complex"));
/* get the real and complex members */
TableGet(StructComplexType->Members, TableStrRegister("i"), &RealOffset);
@ -42,13 +39,12 @@ void ShowComplex(struct ParseState *Parser, struct Value *ReturnValue, struct Va
PrintInt(RealPart, PlatformPutc);
PlatformPutc(',');
PrintInt(ComplexPart, PlatformPutc);
#endif
}
/* list of all library functions and their prototypes */
struct LibraryFunction PlatformLibrary[] =
{
// { ShowComplex, "void ShowComplex(struct complex *)" },
{ ShowComplex, "void ShowComplex(struct complex *)" },
{ NULL, NULL }
};

View file

@ -9,8 +9,8 @@ void Initialise()
LexInit();
TypeInit();
LibraryInit(&GlobalTable, "c library", &CLibrary);
LibraryInit(&GlobalTable, "platform library", &PlatformLibrary);
PlatformLibraryInit();
LibraryInit(&GlobalTable, "platform library", &PlatformLibrary);
}
/* free memory */

View file

@ -228,6 +228,7 @@ typedef void CharWriter(unsigned char);
/* globals */
extern struct Table GlobalTable;
extern struct StackFrame *TopStackFrame;
extern struct ValueType UberType;
extern struct ValueType IntType;
extern struct ValueType CharType;
#ifndef NO_FP