Implemented the "address of" operator - working towards pointers

git-svn-id: http://picoc.googlecode.com/svn/trunk@71 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2009-02-10 11:19:48 +00:00
parent 7c9b3c1c8a
commit 2b1983b668

11
parse.c
View file

@ -131,9 +131,18 @@ int ParseValue(struct ParseState *Parser, struct Value **Result, int ResultOnHea
break;
case TokenAsterisk:
case TokenAmpersand:
ProgramFail(Parser, "not implemented");
case TokenAmpersand:
if (!ParseValue(Parser, Result, ResultOnHeap, &LocalLValue, RunIt) || LocalLValue == NULL)
ProgramFail(Parser, "can't get the address of this");
VariableStackPop(Parser, *Result);
*Result = VariableAllocValueFromType(Parser, Typ, TypeGetMatching(Parser, *Result, TypePointer, 0, StrEmpty));
(*Result)->Val->Pointer.Segment = LocalLValue;
(*Result)->Val->Pointer.Offset = 0;
break;
case TokenIdentifier:
if (LexGetToken(Parser, NULL, FALSE) == TokenOpenBracket)
ParseFunctionCall(Parser, Result, ResultOnHeap, LexValue->Val->String, RunIt);