Working on enum issue
git-svn-id: http://picoc.googlecode.com/svn/trunk@552 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
9b0bd8c4dc
commit
33985ad161
|
@ -670,7 +670,7 @@ void StdioSetupFunc(void)
|
|||
StructFileType = TypeCreateOpaqueStruct(NULL, TableStrRegister("__FILEStruct"), sizeof(FILE));
|
||||
|
||||
/* get a FILE * type */
|
||||
FilePtrType = TypeGetMatching(NULL, StructFileType, TypePointer, 0, StrEmpty);
|
||||
FilePtrType = TypeGetMatching(NULL, StructFileType, TypePointer, 0, StrEmpty, TRUE);
|
||||
|
||||
/* make a "struct __va_listStruct" which is the same size as our struct StdVararg */
|
||||
TypeCreateOpaqueStruct(NULL, TableStrRegister("__va_listStruct"), sizeof(FILE));
|
||||
|
|
|
@ -453,7 +453,7 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
ProgramFail(Parser, "can't get the address of this");
|
||||
|
||||
ValPtr = TopValue->Val;
|
||||
Result = VariableAllocValueFromType(Parser, TypeGetMatching(Parser, TopValue->Typ, TypePointer, 0, StrEmpty), FALSE, NULL, FALSE);
|
||||
Result = VariableAllocValueFromType(Parser, TypeGetMatching(Parser, TopValue->Typ, TypePointer, 0, StrEmpty, TRUE), FALSE, NULL, FALSE);
|
||||
Result->Val->Pointer = (void *)ValPtr;
|
||||
ExpressionStackPushValueNode(Parser, StackTop, Result);
|
||||
break;
|
||||
|
|
13
type.c
13
type.c
|
@ -46,7 +46,7 @@ struct ValueType *TypeAdd(struct ParseState *Parser, struct ValueType *ParentTyp
|
|||
}
|
||||
|
||||
/* given a parent type, get a matching derived type and make one if necessary */
|
||||
struct ValueType *TypeGetMatching(struct ParseState *Parser, struct ValueType *ParentType, enum BaseType Base, int ArraySize, const char *Identifier)
|
||||
struct ValueType *TypeGetMatching(struct ParseState *Parser, struct ValueType *ParentType, enum BaseType Base, int ArraySize, const char *Identifier, int AllowDuplicates)
|
||||
{
|
||||
int Sizeof;
|
||||
int AlignBytes;
|
||||
|
@ -55,7 +55,12 @@ struct ValueType *TypeGetMatching(struct ParseState *Parser, struct ValueType *P
|
|||
ThisType = ThisType->Next;
|
||||
|
||||
if (ThisType != NULL)
|
||||
return ThisType;
|
||||
{
|
||||
if (AllowDuplicates)
|
||||
return ThisType;
|
||||
else
|
||||
ProgramFail(Parser, "data type '%s' is already defined", Identifier);
|
||||
}
|
||||
|
||||
switch (Base)
|
||||
{
|
||||
|
@ -433,7 +438,7 @@ struct ValueType *TypeParseBack(struct ParseState *Parser, struct ValueType *Fro
|
|||
if (LexGetToken(Parser, NULL, TRUE) != TokenRightSquareBracket)
|
||||
ProgramFail(Parser, "']' expected");
|
||||
|
||||
return TypeGetMatching(Parser, TypeParseBack(Parser, FromType), TypeArray, ArraySize, StrEmpty);
|
||||
return TypeGetMatching(Parser, TypeParseBack(Parser, FromType), TypeArray, ArraySize, StrEmpty, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -472,7 +477,7 @@ void TypeParseIdentPart(struct ParseState *Parser, struct ValueType *BasicTyp, s
|
|||
if (*Typ == NULL)
|
||||
ProgramFail(Parser, "bad type declaration");
|
||||
|
||||
*Typ = TypeGetMatching(Parser, *Typ, TypePointer, 0, StrEmpty);
|
||||
*Typ = TypeGetMatching(Parser, *Typ, TypePointer, 0, StrEmpty, TRUE);
|
||||
break;
|
||||
|
||||
case TokenIdentifier:
|
||||
|
|
Loading…
Reference in a new issue