starting on ruby send
This commit is contained in:
parent
cf0a123866
commit
96f19d18c0
@ -27,6 +27,20 @@ module Melon
|
|||||||
w
|
w
|
||||||
end
|
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)
|
def on_int( expression)
|
||||||
Vm::Tree::IntegerExpression.new(expression.children.first)
|
Vm::Tree::IntegerExpression.new(expression.children.first)
|
||||||
end
|
end
|
||||||
|
@ -40,7 +40,6 @@ module Melon
|
|||||||
def compile_methods(clazz , methods)
|
def compile_methods(clazz , methods)
|
||||||
methods.each do |method|
|
methods.each do |method|
|
||||||
typed_method = method.create_vm_method(clazz.instance_type)
|
typed_method = method.create_vm_method(clazz.instance_type)
|
||||||
raise "NIL" unless method
|
|
||||||
code = Compilers::MethodCompiler.new(method).get_code
|
code = Compilers::MethodCompiler.new(method).get_code
|
||||||
Vm::MethodCompiler.new( typed_method ).init_method.process( code)
|
Vm::MethodCompiler.new( typed_method ).init_method.process( code)
|
||||||
end
|
end
|
||||||
|
@ -12,7 +12,7 @@ module Vm
|
|||||||
type = get_my_type(me)
|
type = get_my_type(me)
|
||||||
|
|
||||||
method = type.get_method(statement.name)
|
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
|
# move our receiver there
|
||||||
add_reg_to_slot( statement , me , :new_message , :receiver)
|
add_reg_to_slot( statement , me , :new_message , :receiver)
|
||||||
|
@ -4,6 +4,7 @@ require "parser/ruby22"
|
|||||||
|
|
||||||
module Melon
|
module Melon
|
||||||
module MelonTests
|
module MelonTests
|
||||||
|
include CompilerHelper
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Register.machine.boot
|
Register.machine.boot
|
||||||
|
@ -6,9 +6,9 @@ module Melon
|
|||||||
|
|
||||||
|
|
||||||
def test_ruby_hello
|
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 !check
|
||||||
# assert_equal "Hello there" , @interpreter.stdout
|
assert_equal "Hello there" , @interpreter.stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user