bring class methods down to mom

not functionally correct, still compiling into class, not metaclass
part of #24
This commit is contained in:
Torsten Ruger
2019-02-16 17:54:45 +02:00
parent 40581494de
commit 2fbea82039
5 changed files with 65 additions and 11 deletions

View File

@ -20,15 +20,9 @@ module Vool
@body.each(&block)
end
def has_yield?
each{|statement| return true if statement.is_a?(YieldStatement)}
return false
end
def make_arg_type( )
type_hash = {}
@args.each {|arg| type_hash[arg] = :Object }
type_hash[:implicit_block] = :Block if has_yield?
Parfait::NamedList.type_for( type_hash )
end
@ -42,10 +36,6 @@ module Vool
def make_frame
nodes = []
@body.each { |node| nodes << node }
nodes.dup.each do |node|
next unless node.is_a?(BlockStatement)
node.each {|block_scope| nodes.delete(block_scope)}
end
type_hash = {}
nodes.each do |node|
next unless node.is_a?(LocalVariable) or node.is_a?(LocalAssignment)

View File

@ -20,7 +20,9 @@ module Vool
def to_mom( _ )
create_class_object
method_compilers = body.statements.collect do |node|
raise "Only methods for now #{node}" unless node.is_a?(MethodStatement)
unless node.is_a?(MethodStatement) or node.is_a?(ClassMethodStatement)
raise "Only methods for now #{node.class}:#{node}"
end
node.to_mom(@clazz)
end
Mom::MomCompiler.new(method_compilers)

View File

@ -39,5 +39,14 @@ module Vool
class ModuleName < Expression
include Named
def ct_type
get_named_class.instance_type
end
def slot_definition(_)
return Mom::SlotDefinition.new( get_named_class, [])
end
def get_named_class
Parfait.object_space.get_class_by_name(self.name)
end
end
end