diff --git a/TODO b/TODO index cfe1f2e..6ab7c06 100644 --- a/TODO +++ b/TODO @@ -10,4 +10,4 @@ TODO Also: * Do we really need OnHeap? Isn't every value on the stack anyway? * Remove Var parameter from HeapPopStack() once we're certain it all works - +* Clean up the two types of stack frame diff --git a/parse.c b/parse.c index 0f474e9..b08106c 100644 --- a/parse.c +++ b/parse.c @@ -209,7 +209,7 @@ int ParseValue(struct ParseState *Parser, struct Value **Result, int ResultOnHea ProgramFail(Parser, "illegal array index"); VariableStackPop(Parser, *Result); - LocalLValue = VariableAllocValueFromExistingData(Parser, (*Result)->Typ->FromType, (union AnyValue *)((void *)(&(*Result)->Val) + (*Result)->Typ->FromType->Sizeof * IntValue), TRUE, ResultOnHeap); + *Result = VariableAllocValueFromExistingData(Parser, (*Result)->Typ->FromType, (union AnyValue *)((void *)(*Result)->Val + (*Result)->Typ->FromType->Sizeof * IntValue), TRUE, ResultOnHeap); } } } diff --git a/picoc.h b/picoc.h index 5a9c16d..39a7409 100644 --- a/picoc.h +++ b/picoc.h @@ -150,11 +150,11 @@ union AnyValue struct Value { - struct ValueType *Typ; - union AnyValue *Val; - char ValOnHeap; - char ValOnStack; - char IsLValue; + struct ValueType *Typ; /* the type of this value */ + union AnyValue *Val; /* pointer to the AnyValue which holds the actual content */ + char ValOnHeap; /* the AnyValue is on the heap (but this Value is on the stack) */ + char ValOnStack; /* the AnyValue is on the stack along with this Value */ + char IsLValue; /* is modifiable and is allocated somewhere we can usefully modify it */ }; /* hash table data structure */