Implicit returns for class methods
gets us parsing of parfaits second file data_object
This commit is contained in:
@ -2,7 +2,8 @@ module Ruby
|
||||
class ClassMethodStatement < MethodStatement
|
||||
|
||||
def to_vool
|
||||
Vool::ClassMethodExpression.new( @name , @args.dup , @body.to_vool)
|
||||
body = normalized_body
|
||||
Vool::ClassMethodExpression.new( @name , @args.dup , body.to_vool)
|
||||
end
|
||||
|
||||
def to_s(depth = 0)
|
||||
|
@ -8,13 +8,17 @@ module Ruby
|
||||
@clazz = clazz
|
||||
end
|
||||
|
||||
# At the moment normalizing means creating implicit returns for some cases
|
||||
# see replace_return for details.
|
||||
def normalized_body
|
||||
return replace_return( @body ) unless @body.is_a?(Statements)
|
||||
body = Statements.new( @body.statements.dup )
|
||||
body << replace_return( body.pop )
|
||||
end
|
||||
|
||||
def to_vool
|
||||
if @body.is_a?(Statements)
|
||||
@body << replace_return( @body.pop )
|
||||
else
|
||||
@body = replace_return( @body )
|
||||
end
|
||||
Vool::MethodExpression.new( @name , @args.dup , @body.to_vool)
|
||||
body = normalized_body
|
||||
Vool::MethodExpression.new( @name , @args.dup , body.to_vool)
|
||||
end
|
||||
|
||||
def replace_return(statement)
|
||||
|
Reference in New Issue
Block a user