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

View file

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

View file

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