From 8647cba901d450f72f76a74283d860e13b68571f Mon Sep 17 00:00:00 2001 From: DerelictDrone Date: Tue, 5 Dec 2023 17:40:04 -0600 Subject: [PATCH] Fix returning ptr types from functions --- lua/wire/client/hlzasm/hc_syntax.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/wire/client/hlzasm/hc_syntax.lua b/lua/wire/client/hlzasm/hc_syntax.lua index e238152..9318e00 100644 --- a/lua/wire/client/hlzasm/hc_syntax.lua +++ b/lua/wire/client/hlzasm/hc_syntax.lua @@ -529,13 +529,24 @@ function HCOMP:DefineVariable(isFunctionParam,isForwardDecl,isRegisterDecl,isStr self:PreviousToken() -- LPAREN self:PreviousToken() -- Func Name self:PreviousToken() -- Type Name + local ptrlevel = 0 + if self:MatchToken(TOKEN.TIMES) then + -- skip back until we're done with the ptr + self:PreviousToken() + while self:MatchToken(TOKEN.TIMES) do + ptrlevel = ptrlevel + 1; + self:PreviousToken() + self:PreviousToken() + end + end if not self:MatchToken(TOKEN.IDENT) then self:MatchToken(TOKEN.TYPE) -- If it's not an IDENT (struct/user defined) it should be a generic type end local returnType = self.TokenData + self.CurrentToken = self.CurrentToken + ptrlevel -- return to present. self:MatchToken(TOKEN.IDENT) local funcName = self.TokenData - self.CurFunction = {Name = funcName, ReturnType = returnType} + self.CurFunction = {Name = funcName, ReturnType = returnType, ReturnPtrLevel = ptrlevel} self:NextToken() label.Type = "Pointer" label.Defined = true