bit of refactoring

This commit is contained in:
Torsten Ruger
2018-06-27 17:09:50 +03:00
parent f0ba863721
commit 2e086a78e2
6 changed files with 39 additions and 30 deletions

View File

@ -9,15 +9,9 @@ module Vool
end
def to_mom(clazz)
@clazz = clazz
raise "no class" unless clazz
method = Parfait::VoolMethod.new(name , make_type , make_frame , body )
@clazz.add_method( method )
typed_method = method.create_typed_method(clazz.instance_type)
head = @body.to_mom( typed_method )
compiler = Risc::MethodCompiler.new( typed_method )
compiler.add_mom(head)
head # return for testing
@clazz = clazz || raise( "no class in #{self}")
method = @clazz.add_method_for(name , make_arg_type , make_frame , body )
method.compile_to_risc(clazz.instance_type)
end
def each(&block)
@ -31,7 +25,7 @@ module Vool
private
def make_type( )
def make_arg_type( )
type_hash = {}
@args.each {|arg| type_hash[arg] = :Object }
Parfait::NamedList.type_for( type_hash )

View File

@ -5,7 +5,7 @@ module Vool
# Return a Name, and a possible rest that has a hoisted part of the statement
#
# eg if( @var % 5) is not normalized
# but if(tmp_123) is with tmp_123 = @var % 5 hoited above the if
# but if(tmp_123) is with tmp_123 = @var % 5 hoisted above the if
#
# also constants count, though they may not be so useful in ifs, but returns
def normalize_name( condition )