From 1e866ae0ae5a65e642196d227d4242a354f95268 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 30 Jun 2014 14:56:58 +0300 Subject: [PATCH] minor --- lib/virtual/integer.rb | 45 +++------------------------------------- lib/virtual/object.rb | 6 +++--- lib/virtual/reference.rb | 2 +- 3 files changed, 7 insertions(+), 46 deletions(-) diff --git a/lib/virtual/integer.rb b/lib/virtual/integer.rb index de0b876c..6279503d 100644 --- a/lib/virtual/integer.rb +++ b/lib/virtual/integer.rb @@ -1,47 +1,8 @@ module Vm - class Integer + class Integer < Value - def less_or_equal block , right - block.cmp( self , right ) - Virtual::BranchCondition.new :le - end - def greater_or_equal block , right - block.cmp( self , right ) - Virtual::BranchCondition.new :ge - end - def greater_than block , right - block.cmp( self , right ) - Virtual::BranchCondition.new :gt - end - def less_than block , right - block.cmp( self , right ) - Virtual::BranchCondition.new :lt - end - def plus block , first , right - block.add( self , left , right ) - self - end - def minus block , left , right - block.sub( self , left , right ) - self - end - def left_shift block , left , right - block.mov( self , left , shift_lsr: right ) - self - end - def equals block , right - block.cmp( self , right ) - Virtual::BranchCondition.new :eq + def initialize end - def is_true? function - function.cmp( self , 0 ) - Virtual::BranchCondition.new :ne - end - - def move block , right - block.mov( self , right ) - self - end end -end \ No newline at end of file +end diff --git a/lib/virtual/object.rb b/lib/virtual/object.rb index e52db691..eda1b388 100644 --- a/lib/virtual/object.rb +++ b/lib/virtual/object.rb @@ -6,10 +6,10 @@ module Virtual # functions on these classes express their functionality as function objects class Object def initialize - @layout = Layout.new([:layout]) + @layout = Layout.new( attributes ) end def attributes - raise "abstract #{self}" + [:layout] end def == other return false unless other.class == self.class @@ -28,7 +28,7 @@ module Virtual @members = members end def attributes - [:members] + super << :members end end diff --git a/lib/virtual/reference.rb b/lib/virtual/reference.rb index 1c7d5974..97730d28 100644 --- a/lib/virtual/reference.rb +++ b/lib/virtual/reference.rb @@ -1,5 +1,5 @@ module Vm - class Reference + class Reference < Value def initialize clazz = nil @clazz = clazz