def rewrite_resbody(exp)
result = s()
code = result
while exp and exp.first == :resbody do
code << exp.shift
list = exp.shift || s(:array)
body = exp.empty? ? nil : exp.shift
exp = exp.empty? ? nil : exp.shift
case body.first
when nil then
when :lasgn then
list << body
body = nil
when :block then
list << body.delete_at(1) if body[1].first == :lasgn
else
end if body
code << list << body
if exp then
code = s()
result << code
end
end
if $DEBUG or $TESTING then
structure = result.structure
raise "result structure wrong: #{structure[0..1].inspect}" unless
structure.flatten[0] == :resbody
raise "result structure wrong: #{structure[0..1].inspect}" unless
s(:array, :splat, :argscat).include? structure.flatten[1]
raise "result body wrong: #{structure[2].inspect}" unless
structure[2].nil? or not structure[2].empty?
end
result
end