moving vool_method to parfait
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
# VOOL
|
||||
|
||||
Virtual Object Oriented Language
|
||||
--------------------------------
|
||||
|
||||
in other words, ruby without the fluff.
|
||||
|
||||
@ -11,7 +12,7 @@ Possibly later other languages can compile to this level, eg by running in the s
|
||||
Vool is the layer of concrete syntax tree. The Parser gem is used to parse ruby. It creates
|
||||
an abstract syntax tree which is then transformed.
|
||||
|
||||
The next layer down is the Vom, Virtual object Machine, which uses an instruction tree.
|
||||
The next layer down is the Mom, Minimal object Machine, which uses an instruction tree.
|
||||
That is on the way down we create instructions, but stay in tree format. Only the next step
|
||||
down to the Risc layer moves to an instruction stream.
|
||||
|
||||
|
@ -31,9 +31,16 @@ module Vool
|
||||
def create_objects
|
||||
args_type = make_type
|
||||
locals_type = make_locals
|
||||
method = Vool::VoolMethod.new(name , args_type , locals_type , body )
|
||||
method = Parfait::VoolMethod.new(name , args_type , locals_type , body )
|
||||
@clazz.add_method( method )
|
||||
# compile_methods(clazz,methods)
|
||||
end
|
||||
|
||||
def compile_methods(clazz , methods)
|
||||
methods.each do |method|
|
||||
code = Passes::MethodCompiler.new(method).get_code
|
||||
typed_method = method.create_parfait_method(clazz.instance_type)
|
||||
Vm::MethodCompiler.new( typed_method ).init_method.process( code )
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
@ -52,23 +59,5 @@ module Vool
|
||||
Parfait::NamedList.type_for( type_hash )
|
||||
end
|
||||
|
||||
def create_methods(clazz , body)
|
||||
methods = Passes::MethodCollector.new.collect(body)
|
||||
methods.each do |method|
|
||||
clazz.add_method( method )
|
||||
normalizer = Passes::Normalizer.new(method)
|
||||
method.normalize_source { |sourc| normalizer.process( sourc ) }
|
||||
end
|
||||
methods
|
||||
end
|
||||
|
||||
def compile_methods(clazz , methods)
|
||||
methods.each do |method|
|
||||
code = Passes::MethodCompiler.new(method).get_code
|
||||
typed_method = method.create_parfait_method(clazz.instance_type)
|
||||
Vm::MethodCompiler.new( typed_method ).init_method.process( code )
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -1,29 +0,0 @@
|
||||
module Vool
|
||||
|
||||
class VoolMethod
|
||||
|
||||
attr_reader :name , :args_type , :locals_type , :source
|
||||
|
||||
def initialize(name , args_type , locals_type , source )
|
||||
@name , @args_type , @locals_type , @source = name , args_type, locals_type , source
|
||||
raise "Name must be symbol" unless name.is_a?(Symbol)
|
||||
raise "args_type must be type" unless args_type.is_a?(Parfait::Type)
|
||||
raise "locals_type must be type" unless locals_type.is_a?(Parfait::Type)
|
||||
end
|
||||
|
||||
def normalize_source
|
||||
@source = yield @source
|
||||
end
|
||||
|
||||
def create_parfait_method( type )
|
||||
raise "create_method #{type.inspect} is not a Type" unless type.is_a? Parfait::Type
|
||||
type.create_method( @name , @args_type )#FIXME, @locals_type)
|
||||
end
|
||||
|
||||
def create_tmp
|
||||
tmp_name = "tmp_#{@locals_type.instance_length}".to_sym
|
||||
@locals_type = @locals_type.add_instance_variable( tmp_name , :Object )
|
||||
tmp_name
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user