Removed redundant "struct ArrayValue"
git-svn-id: http://picoc.googlecode.com/svn/trunk@369 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
18acb6dc1a
commit
f1aeadb077
|
@ -245,7 +245,7 @@ void GenericPrintf(struct ParseState *Parser, struct Value *ReturnValue, struct
|
|||
if (NextArg->Typ->Base == TypePointer)
|
||||
Str = NextArg->Val->NativePointer;
|
||||
else
|
||||
Str = NextArg->Val->Array.Data;
|
||||
Str = NextArg->Val->ArrayData;
|
||||
|
||||
if (Str == NULL)
|
||||
PrintStr("NULL", Stream);
|
||||
|
@ -304,7 +304,7 @@ void LibSPrintf(struct ParseState *Parser, struct Value *ReturnValue, struct Val
|
|||
void LibGets(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
struct Value *CharArray = (struct Value *)(Param[0]->Val->NativePointer);
|
||||
char *ReadBuffer = CharArray->Val->Array.Data;
|
||||
char *ReadBuffer = CharArray->Val->ArrayData;
|
||||
char *Result;
|
||||
|
||||
ReturnValue->Val->NativePointer = NULL;
|
||||
|
|
|
@ -98,7 +98,7 @@ void ExpressionStackShow(struct ExpressionStack *StackTop)
|
|||
if (StackTop->Val->Val->Pointer.Segment == NULL)
|
||||
printf("ptr(NULL)");
|
||||
else if (StackTop->Val->Typ->FromType->Base == TypeChar)
|
||||
printf("\"%s\":string", (char *)StackTop->Val->Val->Pointer.Segment->Val->Array.Data + StackTop->Val->Val->Pointer.Offset);
|
||||
printf("\"%s\":string", (char *)StackTop->Val->Val->Pointer.Segment->Val->ArrayData + StackTop->Val->Val->Pointer.Offset);
|
||||
else
|
||||
printf("ptr(0x%lx,%d)", (long)StackTop->Val->Val->Pointer.Segment, StackTop->Val->Val->Pointer.Offset);
|
||||
break;
|
||||
|
@ -287,7 +287,7 @@ void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue,
|
|||
else if (FromValue->Typ->Base == TypeArray && PointedToType == FromValue->Typ->FromType)
|
||||
{
|
||||
/* the form is: blah *x = array of blah */
|
||||
ToValue->Val->NativePointer = FromValue->Val->Array.Data;
|
||||
ToValue->Val->NativePointer = FromValue->Val->ArrayData;
|
||||
}
|
||||
else if (FromValue->Typ->Base == TypePointer && FromValue->Typ->FromType->Base == TypeArray && PointedToType == FromValue->Typ->FromType->FromType)
|
||||
{
|
||||
|
@ -345,7 +345,7 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, struct
|
|||
if (DestValue->Typ->ArraySize != SourceValue->Typ->ArraySize)
|
||||
AssignFail(Parser, "from an array of size %d to one of size %d", NULL, NULL, DestValue->Typ->ArraySize, SourceValue->Typ->ArraySize, FuncName, ParamNo);
|
||||
|
||||
memcpy((void *)DestValue->Val->Array.Data, (void *)SourceValue->Val->Array.Data, DestValue->Typ->ArraySize);
|
||||
memcpy((void *)DestValue->Val->ArrayData, (void *)SourceValue->Val->ArrayData, DestValue->Typ->ArraySize);
|
||||
break;
|
||||
|
||||
case TypeStruct:
|
||||
|
@ -553,7 +553,7 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
/* make the array element result */
|
||||
switch (BottomValue->Typ->Base)
|
||||
{
|
||||
case TypeArray: Result = VariableAllocValueFromExistingData(Parser, BottomValue->Typ->FromType, (union AnyValue *)((char *)BottomValue->Val->Array.Data + TypeSize(BottomValue->Typ->FromType, 0, TRUE) * ArrayIndex), BottomValue->IsLValue, BottomValue->LValueFrom); break;
|
||||
case TypeArray: Result = VariableAllocValueFromExistingData(Parser, BottomValue->Typ->FromType, (union AnyValue *)((char *)BottomValue->Val->ArrayData + TypeSize(BottomValue->Typ->FromType, 0, TRUE) * ArrayIndex), BottomValue->IsLValue, BottomValue->LValueFrom); break;
|
||||
case TypePointer: Result = VariableAllocValueFromExistingData(Parser, BottomValue->Typ->FromType, (union AnyValue *)((char *)BottomValue->Val->NativePointer + TypeSize(BottomValue->Typ->FromType, 0, TRUE) * ArrayIndex), BottomValue->IsLValue, BottomValue->LValueFrom); break;
|
||||
default: ProgramFail(Parser, "this %t is not an array", BottomValue->Typ);
|
||||
}
|
||||
|
|
4
lex.c
4
lex.c
|
@ -306,9 +306,9 @@ enum LexToken LexGetStringConstant(struct LexState *Lexer, struct Value *Value)
|
|||
if (ArrayValue == NULL)
|
||||
{
|
||||
/* create and store this string literal */
|
||||
ArrayValue = VariableAllocValueAndData(NULL, sizeof(struct ArrayValue), FALSE, NULL, TRUE);
|
||||
ArrayValue = VariableAllocValueAndData(NULL, sizeof(void *), FALSE, NULL, TRUE);
|
||||
ArrayValue->Typ = CharArrayType;
|
||||
ArrayValue->Val->Array.Data = RegString;
|
||||
ArrayValue->Val->ArrayData = RegString;
|
||||
VariableStringLiteralDefine(RegString, ArrayValue);
|
||||
}
|
||||
|
||||
|
|
9
picoc.h
9
picoc.h
|
@ -159,21 +159,16 @@ struct FuncDef
|
|||
};
|
||||
|
||||
/* values */
|
||||
struct ArrayValue
|
||||
{
|
||||
void *Data; /* pointer to the array data */
|
||||
};
|
||||
|
||||
union AnyValue
|
||||
{
|
||||
char Character;
|
||||
unsigned char Character;
|
||||
short ShortInteger;
|
||||
int Integer;
|
||||
unsigned char UnsignedCharacter;
|
||||
unsigned short UnsignedShortInteger;
|
||||
unsigned int UnsignedInteger;
|
||||
char *Identifier;
|
||||
struct ArrayValue Array;
|
||||
void *ArrayData;
|
||||
struct ParseState Parser;
|
||||
struct ValueType *Typ;
|
||||
struct FuncDef FuncDef;
|
||||
|
|
6
type.c
6
type.c
|
@ -53,7 +53,7 @@ struct ValueType *TypeGetMatching(struct ParseState *Parser, struct ValueType *P
|
|||
switch (Base)
|
||||
{
|
||||
case TypePointer: Sizeof = sizeof(void *); break;
|
||||
case TypeArray: Sizeof = sizeof(struct ArrayValue) + ArraySize * ParentType->Sizeof; break;
|
||||
case TypeArray: Sizeof = sizeof(void *) + ArraySize * ParentType->Sizeof; break;
|
||||
case TypeEnum: Sizeof = sizeof(int); break;
|
||||
default: Sizeof = 0; break; /* structs and unions will get bigger when we add members to them */
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ int TypeSizeValue(struct Value *Val)
|
|||
else if (Val->Typ->Base != TypeArray)
|
||||
return Val->Typ->Sizeof;
|
||||
else
|
||||
return sizeof(struct ArrayValue) + Val->Typ->FromType->Sizeof * Val->Typ->ArraySize;
|
||||
return sizeof(void *) + Val->Typ->FromType->Sizeof * Val->Typ->ArraySize;
|
||||
}
|
||||
|
||||
/* memory used by a variable given its type and array size */
|
||||
|
@ -89,7 +89,7 @@ int TypeSize(struct ValueType *Typ, int ArraySize, int Compact)
|
|||
else if (Typ->Base != TypeArray)
|
||||
return Typ->Sizeof;
|
||||
else
|
||||
return sizeof(struct ArrayValue) + Typ->FromType->Sizeof * ArraySize;
|
||||
return sizeof(void *) + Typ->FromType->Sizeof * ArraySize;
|
||||
}
|
||||
|
||||
/* memory used by the base (non-array) type of a type. This is used for alignment. */
|
||||
|
|
|
@ -106,7 +106,7 @@ struct Value *VariableAllocValueFromType(struct ParseState *Parser, struct Value
|
|||
assert(Size > 0 || Typ == &VoidType);
|
||||
NewValue->Typ = Typ;
|
||||
if (Typ->Base == TypeArray)
|
||||
NewValue->Val->Array.Data = (void *)((char *)NewValue->Val + sizeof(struct ArrayValue));
|
||||
NewValue->Val->ArrayData = (void *)((char *)NewValue->Val + sizeof(void *));
|
||||
|
||||
return NewValue;
|
||||
}
|
||||
|
@ -187,12 +187,12 @@ void VariableGet(struct ParseState *Parser, const char *Ident, struct Value **LV
|
|||
/* define a global variable shared with a platform global. Ident will be registered */
|
||||
void VariableDefinePlatformVar(struct ParseState *Parser, char *Ident, struct ValueType *Typ, union AnyValue *FromValue, int IsWritable)
|
||||
{
|
||||
struct Value *SomeValue = VariableAllocValueAndData(NULL, (Typ->Base == TypeArray) ? sizeof(struct ArrayValue) : 0, IsWritable, NULL, TRUE);
|
||||
struct Value *SomeValue = VariableAllocValueAndData(NULL, (Typ->Base == TypeArray) ? sizeof(void *) : 0, IsWritable, NULL, TRUE);
|
||||
SomeValue->Typ = Typ;
|
||||
if (Typ->Base != TypeArray)
|
||||
SomeValue->Val = FromValue;
|
||||
else
|
||||
SomeValue->Val->Array.Data = FromValue;
|
||||
SomeValue->Val->ArrayData = FromValue;
|
||||
|
||||
if (!TableSet((TopStackFrame == NULL) ? &GlobalTable : &TopStackFrame->LocalTable, TableStrRegister(Ident), SomeValue))
|
||||
ProgramFail(Parser, "'%s' is already defined", Ident);
|
||||
|
|
Loading…
Reference in a new issue