starting on ruby send

This commit is contained in:
Torsten Ruger 2017-01-15 20:30:47 +02:00
parent cf0a123866
commit 96f19d18c0
5 changed files with 19 additions and 5 deletions

View File

@ -27,6 +27,20 @@ module Melon
w
end
def on_send( statement )
receiver , name , args = *statement
w = Vm::Tree::CallSite.new()
puts "receiver #{statement}"
w.name = process(receiver)
w.arguments = process(args)
w.receiver = nil
w
end
def on_str( string )
Vm::Tree::StringExpression.new(string.children.first)
end
def on_int( expression)
Vm::Tree::IntegerExpression.new(expression.children.first)
end

View File

@ -40,7 +40,6 @@ module Melon
def compile_methods(clazz , methods)
methods.each do |method|
typed_method = method.create_vm_method(clazz.instance_type)
raise "NIL" unless method
code = Compilers::MethodCompiler.new(method).get_code
Vm::MethodCompiler.new( typed_method ).init_method.process( code)
end

View File

@ -12,7 +12,7 @@ module Vm
type = get_my_type(me)
method = type.get_method(statement.name)
raise "Method not implemented #{type.inspect}.#{statement.name}" unless method
raise "Method not implementedfor me#{type} #{type.inspect}.#{statement.name}" unless method
# move our receiver there
add_reg_to_slot( statement , me , :new_message , :receiver)

View File

@ -4,7 +4,8 @@ require "parser/ruby22"
module Melon
module MelonTests
include CompilerHelper
def setup
Register.machine.boot
end

View File

@ -6,9 +6,9 @@ module Melon
def test_ruby_hello
@string_input = 'puts "Hello there"'
@string_input = in_Space 'def puts(str) ; str.putstring; end ; def main; putstring "Hello there"; end'
assert !check
# assert_equal "Hello there" , @interpreter.stdout
assert_equal "Hello there" , @interpreter.stdout
end
end