diff --git a/lib/builtin/kernel.rb b/lib/builtin/kernel.rb index 7ff78568..54426efe 100644 --- a/lib/builtin/kernel.rb +++ b/lib/builtin/kernel.rb @@ -17,7 +17,7 @@ module Builtin me = Virtual::Self.new(Virtual::Reference) code = Virtual::Set.new(Virtual::Self.new(me.type), me) function.add_code(code) - function.add_code Register::FunctionCall.new(method) + function.add_code Virtual::MethodCall.new(method) return function end def putstring context diff --git a/lib/virtual/instructions/control.rb b/lib/virtual/instructions/control.rb index f7b3e690..6415a0fd 100644 --- a/lib/virtual/instructions/control.rb +++ b/lib/virtual/instructions/control.rb @@ -2,12 +2,22 @@ module Virtual # the first instruction we need is to stop. Off course in a real machine this would be a syscall, but that is just - # an implementation (in a programm it would be a function). But in a virtual machine, not only do we need this instruction, + # an implementation (in a programm it would be a function). + # But in a virtual machine, not only do we need this instruction, # it is indeed the first instruction as just this instruction is the smallest possible programm for the machine. # As such it is the next instruction for any first instruction that we generate. class Halt < Instruction end + # MethodCall involves shuffling some registers about and doing a machine call + class MethodCall < Instruction + def initialize method + @method = method + end + attr_reader :method + end + + # also the return shuffles our objects beck before actually transferring control class MethodReturn < Instruction end