Skip to content

Commit

Permalink
Protect %eax and fix up stack for splat calls
Browse files Browse the repository at this point in the history
  • Loading branch information
vidarh committed Aug 17, 2013
1 parent bcb7668 commit 8802ce5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,14 @@ def compile_callm_args(scope, ob, args)
end

if splat
@e.pushl(:eax)
reg = compile_eval_arg(scope,:numargs)
@e.subl(args.size,reg)
@e.sall(2,reg)
@e.addl(reg,:esp)
# We assume :ebx has been trashed at this point anyway
@e.movl(reg,:ebx)
@e.popl(:eax)
@e.addl(:ebx,:esp)
end
end

Expand Down
11 changes: 11 additions & 0 deletions features/inputs/splatreturn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

def foo(a)
"Hey!"
end

def splat *args
foo(*args)
end

puts(splat(1))

0 comments on commit 8802ce5

Please sign in to comment.