Some docs and to_s testing
somewhat code_climate inspired
This commit is contained in:
@ -1,6 +1,15 @@
|
||||
require_relative "normalizer"
|
||||
|
||||
module Ruby
|
||||
# The if must have condition and a true branch, the false is optional
|
||||
#
|
||||
# It maps pretty much one to one to a Vool, except for "hoisting"
|
||||
#
|
||||
# Ruby may have super complex expressions as the condition, whereas
|
||||
# Vool may not. Ie of a Statement list all but the last are hoisted to before
|
||||
# the vool if. This is equivalent, just easier to compile later
|
||||
#
|
||||
# The hoisintg code is in Normalizer, as it is also useed in return and while
|
||||
class IfStatement < Statement
|
||||
include Normalizer
|
||||
|
||||
@ -28,8 +37,8 @@ module Ruby
|
||||
end
|
||||
|
||||
def to_s(depth = 0)
|
||||
parts = ["if (#{@condition})" , @body.to_s(depth + 1) ]
|
||||
parts += ["else" , "@if_false.to_s(depth + 1)"] if(@false)
|
||||
parts = ["if(#{@condition})" , @if_true.to_s(depth + 1) ]
|
||||
parts += ["else" , @if_false.to_s(depth + 1)] if(@if_false)
|
||||
parts << "end"
|
||||
at_depth(depth , *parts )
|
||||
end
|
||||
|
Reference in New Issue
Block a user