Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix returning ptr types from functions #35

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lua/wire/client/hlzasm/hc_syntax.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@
COLOR = { {"x","r"},{"y","g"},{"z","b"},{"w","a"} },
MATRIX = {},
}
for i=0,15 do VectorSyntax.MATRIX[i+1] = {tostring(i)} end

Check warning on line 24 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 24 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 24 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 24 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator




--------------------------------------------------------------------------------
-- Compile an opcode (called after if self:MatchToken(TOKEN.OPCODE))
function HCOMP:Opcode() local TOKEN,TOKENSET = self.TOKEN,self.TOKENSET

Check warning on line 31 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: TOKENSET

Check warning on line 31 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: TOKENSET
local opcodeName = self.TokenData
local opcodeNo = self.OpcodeNumber[self.TokenData]
local operandCount = self.OperandCount[opcodeNo]

-- Check if opcode is obsolete or old
if self.OpcodeObsolete[opcodeName] then
self:Warning("Instruction \""..opcodeName.."\" is obsolete")

Check warning on line 38 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 38 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 38 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 38 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
end
if self.OpcodeOld[opcodeName] then
self:Warning("Mnemonic \""..opcodeName.."\" is an old mnemonic for this instruction. Please use the newer mnemonic \""..self.OpcodeOld[opcodeName].."\".")

Check warning on line 41 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 41 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 41 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 41 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 41 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 41 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 41 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 41 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
end

-- Create leaf
Expand All @@ -47,7 +47,7 @@
opcodeLeaf.ExplictAssign = true

-- Parse operands
for i=1,operandCount do

Check warning on line 50 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 50 in lua/wire/client/hlzasm/hc_syntax.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
local segmentOffset,constantValue,expressionLeaf
local isMemoryReference,useSpecialMemorySyntax

Expand Down Expand Up @@ -529,13 +529,24 @@
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
Expand Down
Loading