From aaaef6e3d783bbe302662ff5217d9766e9dfe321 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 16 Oct 2015 18:16:39 +0300 Subject: [PATCH] there go the slots addressing them now directly in get/set slot idea is still valid, but express objects not needed/used anymore --- lib/phisol/compiler/class_field.rb | 2 +- lib/virtual.rb | 1 - lib/virtual/slots/frame_slot.rb | 22 ----------- lib/virtual/slots/message_slot.rb | 54 --------------------------- lib/virtual/slots/new_message_slot.rb | 50 ------------------------- lib/virtual/slots/selfs_slot.rb | 26 ------------- {lib/virtual/slots => stash}/slot.rb | 26 ------------- 7 files changed, 1 insertion(+), 180 deletions(-) delete mode 100644 lib/virtual/slots/frame_slot.rb delete mode 100644 lib/virtual/slots/message_slot.rb delete mode 100644 lib/virtual/slots/new_message_slot.rb delete mode 100644 lib/virtual/slots/selfs_slot.rb rename {lib/virtual/slots => stash}/slot.rb (54%) diff --git a/lib/phisol/compiler/class_field.rb b/lib/phisol/compiler/class_field.rb index 49b93359..42a66c15 100644 --- a/lib/phisol/compiler/class_field.rb +++ b/lib/phisol/compiler/class_field.rb @@ -17,7 +17,7 @@ module Phisol raise "value #{value}" #tbc end - Virtual::Return.new( index ) + return nil # statements don't reurn values, only expressions end end end diff --git a/lib/virtual.rb b/lib/virtual.rb index 2e5be85e..980f24bc 100644 --- a/lib/virtual.rb +++ b/lib/virtual.rb @@ -8,7 +8,6 @@ require "virtual/parfait_adapter" require "phisol/compiler" require "virtual/instruction" require "virtual/method_source" -require "virtual/slots/slot" # the passes _are_ order dependant require "virtual/passes/minimizer" require "virtual/passes/collector" diff --git a/lib/virtual/slots/frame_slot.rb b/lib/virtual/slots/frame_slot.rb deleted file mode 100644 index 17a915d0..00000000 --- a/lib/virtual/slots/frame_slot.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Virtual - - # Slots in the Frame a re represented by instances of FrameSlot - - # Slots in the Frame are local or temporary variables in a message - class FrameSlot < Slot - def initialize index , type , value = nil - super(type, value) - @index = index - end - attr_reader :index - - def to_s - "#{self.class.name}.new(#{index} , #{type}, #{value})" - end - - def object_name - return :frame - end - end - -end diff --git a/lib/virtual/slots/message_slot.rb b/lib/virtual/slots/message_slot.rb deleted file mode 100644 index 3989bb3d..00000000 --- a/lib/virtual/slots/message_slot.rb +++ /dev/null @@ -1,54 +0,0 @@ -module Virtual - - # The current Message is one of four objects the virtual machine knows - # - # Slots represent instance variables of objects, so MessageSlots - # represent instance variables of Message objects. - # The Message has a layout as per the constant above - - class MessageSlot < Slot - def initialize type , value = nil - super(type , value ) - end - def object_name - :message - end - end - - # named classes exist for slots that often accessed - - # Return is the return of MessageSlot - class Return < MessageSlot - def initialize type , value = nil - super( type , value ) - end - end - - # Self is the self in MessageSlot - class Self < MessageSlot - def initialize type , value = nil - super( type , value ) - end - end - - # MessageName of the current message - class MessageName < MessageSlot - def initialize type , value = nil - super( type , value ) - end - end - - # NewMessageName of the next message - class ArgSlot < MessageSlot - def initialize index , type , value = nil - @index = index - super( type , value ) - end - attr_reader :index - def to_s - "#{self.class.name}.new(#{index} , #{type}, #{value})" - end - end - - -end diff --git a/lib/virtual/slots/new_message_slot.rb b/lib/virtual/slots/new_message_slot.rb deleted file mode 100644 index 761203c9..00000000 --- a/lib/virtual/slots/new_message_slot.rb +++ /dev/null @@ -1,50 +0,0 @@ -module Virtual - - # The next Message is one of four objects the virtual machine knows - # - # Slots represent instance variables of objects, so NewMessageSlots - # represent instance variables of NewMessage objects. - # The Message has a layout as per the constant above - - class NewMessageSlot < Slot - def initialize type , value = nil - super( type , value ) - end - def object_name - :new_message - end - end - - # named classes exist for slots that often accessed - - # NewReturn is the return of NewMessageSlot - class NewReturn < NewMessageSlot - def initialize type , value = nil - super( type , value ) - end - end - - # NewSelf is the self of NewMessageSlot - class NewSelf < NewMessageSlot - def initialize type , value = nil - super( type , value ) - end - end - - # NewMessageName of the next message - class NewMessageName < NewMessageSlot - def initialize type , value = nil - super( type , value ) - end - end - - # NewMessageName of the next message - class NewArgSlot < NewMessageSlot - def initialize index , type , value = nil - @index = index - super( type , value ) - end - attr_reader :index - end - -end diff --git a/lib/virtual/slots/selfs_slot.rb b/lib/virtual/slots/selfs_slot.rb deleted file mode 100644 index 1fe9252d..00000000 --- a/lib/virtual/slots/selfs_slot.rb +++ /dev/null @@ -1,26 +0,0 @@ -module Virtual - - # Self (the receiver of the current message) is a Slot in the Message. - # The current self in the current message and if the current message - # want to send a message it puts the new self into the next_message. - # - # The slot in the Message is represented by instances of class Self - # (and slots in the next_message by instances of NewSelf) - # - # Additionally the current Self is represented as it's own top-level object. - # If self is an Object one can refer to it's instance variables as Slots in SelfsSlot - # - # In Summary: class Self represents the self object and SelfsSlot instances variables of - # that object - # - class SelfsSlot < Slot - def initialize index , type , value = nil - @index = index - super( type , value ) - end - attr_reader :index - def object_name - :self - end - end -end diff --git a/lib/virtual/slots/slot.rb b/stash/slot.rb similarity index 54% rename from lib/virtual/slots/slot.rb rename to stash/slot.rb index ba809638..27ee108a 100644 --- a/lib/virtual/slots/slot.rb +++ b/stash/slot.rb @@ -16,31 +16,5 @@ module Virtual # Slot has a lot of small subclasses # Names for the slots avoid indexes - class Slot < Object - - # the name of the object of a slot is a symbol that represents what the class name describes - # ie it is one of :message , :self , :frame , :new_message - # one of the objects the machine works on. - def object_name - raise "abstract called #{self}" - end - - attr_accessor :type , :value - - def to_s - "#{self.class.name}.new(#{type}, #{value})" - end - private #abstract base class - - def initialize type , value - @type = type - @value = value - end - end end - -require_relative "message_slot" -require_relative "selfs_slot" -require_relative "frame_slot" -require_relative "new_message_slot"