Skip to content

Instantly share code, notes, and snippets.

@rue
Created August 30, 2008 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rue/8077 to your computer and use it in GitHub Desktop.
Save rue/8077 to your computer and use it in GitHub Desktop.
@offset = 0
@active_branches = [0]
@inactive_branches = {}
@max_stack = 0
stream.each {|inst|
case inst
when git, gif
@active_branches.each {|n| @inactive_branches[label.ip] = n}
when goto
unless label.ip < @offset
@active_branches.each {|n| @inactive_branches[label.ip] = n }
@active_branches = {}
end
when ret
@max = @active_branches.max if @active_branches.max > @max
@active_branches = []
else
inst.do_stuff
@active_branches.map {|n| n += inst.stack_change }
end
@inactive_branches.delete_if {|k,v| @active_branches << v if k == @offset }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment