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 HL-ZASM subtraction #55

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 7 additions & 3 deletions lua/wire/client/hlzasm/hc_expression.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

return { Constant = levelLeaf, CurrentPosition = self:CurrentSourcePosition() }
else
return self["Expression_Level"..level](self)

Check warning on line 25 in lua/wire/client/hlzasm/hc_expression.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
end
end

Expand Down Expand Up @@ -66,9 +66,9 @@
-- Parse arguments and push them to stack
local argumentCount = 0
local argumentExpression = {}
while not (self:PeekToken() == TOKEN.RPAREN) do

Check warning on line 69 in lua/wire/client/hlzasm/hc_expression.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary negation"

Silly negation. Use '~='
-- Parse argument
argumentExpression[#argumentExpression+1] = self:Expression()

Check warning on line 71 in lua/wire/client/hlzasm/hc_expression.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

-- Go to next one
argumentCount = argumentCount + 1
Expand All @@ -87,9 +87,9 @@
local pushLeaf
if argumentExpression[argNo].Memory then
if argumentExpression[argNo].Memory.CopySize then
for i=argumentExpression[argNo].Memory.CopySize-1,0,-1 do

Check warning on line 90 in lua/wire/client/hlzasm/hc_expression.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
pushLeaf = self:NewLeaf()
pushLeaf.Comment = " passing large variable, byte "..i

Check warning on line 92 in lua/wire/client/hlzasm/hc_expression.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
pushLeaf.Opcode = "push"
local a = argumentExpression[argNo]
local copiedArg = {
Expand All @@ -107,19 +107,19 @@
else
pushLeaf = self:NewLeaf()
pushLeaf.Opcode = "push"
pushLeaf.Operands[1] = argumentExpression[argNo]

Check warning on line 110 in lua/wire/client/hlzasm/hc_expression.lua

View workflow job for this annotation

GitHub Actions / lint

"Trailing whitespace"

Trailing whitespace
table.insert(genLeaves,pushLeaf)
end
else
pushLeaf = self:NewLeaf()
pushLeaf.Opcode = "push"
pushLeaf.Operands[1] = argumentExpression[argNo]

Check warning on line 116 in lua/wire/client/hlzasm/hc_expression.lua

View workflow job for this annotation

GitHub Actions / lint

"Trailing whitespace"

Trailing whitespace
table.insert(genLeaves,pushLeaf)
end

if functionEntry then
if functionEntry.Parameters[argNo] then
pushLeaf.Comment = label.Name.." arg #"..argNo.." ("..

Check warning on line 122 in lua/wire/client/hlzasm/hc_expression.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 122 in lua/wire/client/hlzasm/hc_expression.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 122 in lua/wire/client/hlzasm/hc_expression.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
string.lower(
self.TOKEN_TEXT["TYPE"][2][functionEntry.Parameters[argNo].Type] or
functionEntry.Parameters[argNo].Type)..
Expand Down Expand Up @@ -504,13 +504,17 @@
local leftLeaf = self:Expression_LevelLeaf(2)

local token = self:PeekToken()
if (token == self.TOKEN.PLUS) or
(token == self.TOKEN.MINUS) then -- +-
-- Treat "-" as negate instead of subtraction FIXME
if (token == self.TOKEN.PLUS) then
if token == self.TOKEN.PLUS then self:NextToken() end

local rightLeaf = self:Expression_LevelLeaf(0)
return self:NewOpcode("add",leftLeaf,rightLeaf)
elseif (token == self.TOKEN.MINUS) then

if token == self.TOKEN.MINUS then self:NextToken() end

local rightLeaf = self:Expression_LevelLeaf(0)
return self:NewOpcode("sub",leftLeaf,rightLeaf)
elseif (token == self.TOKEN.LAND) or
(token == self.TOKEN.LOR) then -- &&, ||
self:NextToken()
Expand Down
Loading