so close i can smell it, checkpoint

This commit is contained in:
Torsten Ruger
2014-05-03 22:18:04 +03:00
parent 5608c411bf
commit a61170942f
14 changed files with 245 additions and 69 deletions

View File

@@ -1,16 +1,11 @@
require_relative "code"
require "support/hash_attributes"
module Vm
# Instruction represent the actions that affect change on Values
# In an OO way of thinking the Value is data, Instruction the functionality
# But to allow flexibility, the value api bounces back to the machine api, so machines instantiate
# intructions.
# When Instructions are instantiated the create a linked list of Values and Instructions.
# So Value links to Instruction and Instruction links to Value
# Also, because the idea of what one instruction does, does not always map one to one to real machine
# Because the idea of what one instruction does, does not always map one to one to real machine
# instructions, and instruction may link to another instruction thus creating an arbitrary list
# to get the job (the original instruciton) done
# Admittately it would be simpler just to create the (abstract) instructions and let the machine
# encode them into what-ever is neccessary, but this approach leaves more possibility to
# optimize the actual instruction stream (not just the crystal instruction stream). Makes sense?
@@ -25,10 +20,14 @@ module Vm
# - Call
# Instruction derives from Code, for the assembly api
class Code ; end
class Instruction < Code
# Make hash attributes to object attributes
include Support::HashAttributes
def initialize options
@options = options
end
end
class StackInstruction < Instruction