more machinery to the machine

This commit is contained in:
Torsten Ruger 2014-07-30 21:43:12 +03:00
parent 5add9c42f2
commit 8effcc866a
3 changed files with 20 additions and 7 deletions

2
lib/parfait/object.rb Normal file
View File

@ -0,0 +1,2 @@
class Object
end

View File

@ -42,13 +42,26 @@ module Virtual
def self.boot
machine = Machine.new
machine.boot
machine
end
def read string
syntax = @parser.parse_with_debug(string)
Parser::Transform.new.apply(syntax)
def boot
# read all the files needed for a minimal system at compile
classes = ["object"]
classes.each do |clazz|
bytes = File.read(File.join( File.dirname( __FILE__ ) , ".." , "parfait" , "#{clazz}.rb") )
# expression = compile_main(bytes)
end
end
def compile_main bytes
syntax = @parser.parse_with_debug(bytes)
parts = Parser::Transform.new.apply(syntax)
main = Virtual::MethodDefinition.main
expressions = parts.compile( main , self.message )
end
# run the instruction stream given. Instructions are a graph and executing means traversing it.
# If there is no next instruction the machine stops
def run instruction

View File

@ -8,10 +8,8 @@ module VirtualHelper
end
def check
machine = Virtual::Machine.new
parts = machine.read @string_input
main = Virtual::MethodDefinition.main
expressions = parts.compile( main, machine.message )
machine = Virtual::Machine.boot
expressions = machine.compile_main @string_input
should = YAML.load(@output.gsub("RETURN_MARKER" , "\n"))
assert_equal should , expressions , expressions.to_yaml.gsub("\n" , "RETURN_MARKER") + "\n" + expressions.to_yaml
end