Skip to content

Conversation

@katsyoshi
Copy link
Owner

No description provided.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 160 to 164
type = node.type
center = case type
when :LIT, :INTEGER
output.puts " push 0x#{node.children.last.to_s(16)}"
output.puts " mov rax, 0x#{node.children.last.to_s(16)}"
return

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep literal values on stack for consumers

The :LIT/:INTEGER branch now only emits mov rax, … and returns without pushing the value, but the rest of the generator still pops its operands from the stack (e.g., call_method and binary ops immediately pop arguments and conditions). Any expression or method call that uses a literal will now execute pop against an empty/uncorrelated stack, corrupting RSP and producing wrong results—1+2 or foo(1) will pop garbage instead of the literal.

Useful? React with 👍 / 👎.

Comment on lines 33 to 35
prologue_methods(output)
output.puts " .globl main" unless @shared
to_asm(@ast, output)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Emit epilogue when compiling with methods

When any methods are defined, the compile branch now writes the prologue and calls to_asm but never emits the epilogue; unlike the no-methods branch, main is generated without stack restoration or an exit syscall. Programs that define methods now fall through after top-level code instead of returning/terminating cleanly, so execution continues into whatever bytes follow the generated main.

Useful? React with 👍 / 👎.

@katsyoshi katsyoshi merged commit 1934a34 into main Dec 21, 2025
1 check passed
@katsyoshi katsyoshi deleted the implements-jump-in-elf branch December 21, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants