polish docs

and a bit of code style
This commit is contained in:
Torsten Ruger
2018-03-11 16:11:15 +05:30
parent d6a2ea4cfc
commit f7aac1d1a4
14 changed files with 65 additions and 72 deletions

View File

@ -4,7 +4,7 @@ module Common
# set the next instruction (also aliased as <<)
# throw an error if that is set, use insert for that use case
# return the instruction, so chaining works as one wants (not backwards)
def set_next nekst
def set_next( nekst )
raise "Next already set #{@next}" if @next
@next = nekst
nekst
@ -12,7 +12,7 @@ module Common
alias :<< :set_next
# during translation we replace one by one
def replace_next nekst
def replace_next( nekst )
old = @next
@next = nekst
@next.append old.next if old
@ -27,7 +27,7 @@ module Common
# set the give instruction as the next, while moving any existing
# instruction along to the given ones's next.
# ie insert into the linked list that the instructions form
def insert instruction
def insert( instruction )
instruction.set_next @next
@next = instruction
end
@ -41,11 +41,11 @@ module Common
# set next for the last (see last)
# so append the given code to the linked list at the end
def append code
def append( code )
last.set_next code
end
def length labels = []
def length( labels = [] )
ret = 1
ret += self.next.length( labels ) if self.next
ret

View File

@ -24,6 +24,9 @@ module Common
def [](i)
@statements[i]
end
def <<(o)
@statements << o
end
def collect(arr)
@statements.each { |s| s.collect(arr) }
super