From 2b1983b668cf83bdb9725c9db8ba33ac15fd7088 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Tue, 10 Feb 2009 11:19:48 +0000 Subject: [PATCH] Implemented the "address of" operator - working towards pointers git-svn-id: http://picoc.googlecode.com/svn/trunk@71 21eae674-98b7-11dd-bd71-f92a316d2d60 --- parse.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/parse.c b/parse.c index c1a0971..cb78360 100644 --- a/parse.c +++ b/parse.c @@ -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);