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:
parent
61e93e4774
commit
16922d2e73
|
@ -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 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
picoc.c
2
picoc.c
|
@ -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 */
|
||||||
|
|
1
picoc.h
1
picoc.h
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue