add the idea of a frame
This commit is contained in:
20
lib/virtual/frame.rb
Normal file
20
lib/virtual/frame.rb
Normal file
@ -0,0 +1,20 @@
|
||||
module Virtual
|
||||
# A frame, or activation frame, represents a function call during calling. So not the static definition of the function
|
||||
# but the dynamic invokation of it.
|
||||
#
|
||||
# In a minimal c world this would be just the return address, but with exceptions and continuations things get more
|
||||
# complicated. How much more we shall see
|
||||
#
|
||||
# The current list comprises
|
||||
# - next normal instruction
|
||||
# - next exception instruction
|
||||
# - self (me)
|
||||
# - argument mappings
|
||||
# - local variable mapping
|
||||
class Frame
|
||||
def initialize
|
||||
|
||||
end
|
||||
attr_reader :next_normal, :next_exception, :me, :argument_names
|
||||
end
|
||||
end
|
@ -7,8 +7,16 @@ module Virtual
|
||||
# It is actully the point of the virtual machine layer to express oo functionality in the set of instructions, thus
|
||||
# defining a minimal set of instructions needed to implement oo.
|
||||
|
||||
# This is partly because jumping over this layer and doing in straight in assember was too bi a step
|
||||
# This is partly because jumping over this layer and doing in straight in assember was too big a step
|
||||
class Instruction
|
||||
|
||||
end
|
||||
|
||||
# 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,
|
||||
# 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
|
||||
end
|
||||
|
@ -58,6 +58,7 @@ end
|
||||
|
||||
require_relative "list"
|
||||
require_relative "instruction"
|
||||
require_relative "frame"
|
||||
require_relative "value"
|
||||
require_relative "mystery"
|
||||
require_relative "object"
|
||||
|
Reference in New Issue
Block a user