make block replace take array or single instruction

This commit is contained in:
Torsten Ruger
2014-08-30 16:57:56 +03:00
parent 48b33e5f9d
commit 6d67c03cc9
5 changed files with 13 additions and 6 deletions

View File

@ -38,7 +38,11 @@ module Virtual
index = @codes.index code
raise "Code not found #{code} in #{self}" unless index
@codes.delete_at(index)
@codes.insert(index , *new_codes)
if( new_codes.is_a? Array)
new_codes.reverse.each {|c| @codes.insert(index , c)}
else
@codes.insert(index , new_codes)
end
end
# returns if this is a block that ends in a call (and thus needs local variable handling)
@ -53,6 +57,10 @@ module Virtual
# Note: this will have to change for plocks and maybe anyway. back to oo, no more visitors
def set_position at
@position = at
@codes.each do |code|
code.position = at
at += code.length
end
end
def length