orosmatthew / hydrogen-cpp

A hobby programming language 🔥
MIT License
391 stars 38 forks source link

Exit Exits twice #27

Open ApplePieCodes opened 2 months ago

ApplePieCodes commented 2 months ago

the code exit(12) produces the following ASM global _start _start: ;; exit mov rax, 12 push rax mov rax, 60 pop rdi syscall ;; /exit mov rax, 60 mov rdi, 0 syscall

the program exits twice.

andriemc commented 1 month ago

I believe he's intentionally adding an exit at the end of a program (even if you didnt add it yourself), which would mean that this isn't a bug (and you can't really exit twice, it exists and the second one isnt executed)

andriemc commented 1 month ago

I believe he's intentionally adding an exit at the end of a program (even if you didnt add it yourself), which would mean that this isn't a bug (and you can't really exit twice, it exists and the second one isnt executed)

This seems to be the case (check Line 247 of generation.hpp)

ApplePieCodes commented 1 month ago

Ok. I would change it to only add an exit if there is no exit declared in the program

andriemc commented 1 month ago

Ok. I would change it to only add an exit if there is no exit declared in the program

Personally I'd just leave it as is.