From a24e96efbc1eab2c8348246e34016ae92b25fd48 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 29 Jun 2015 20:56:11 +0300 Subject: [PATCH] asserts to debug --- lib/register/instructions/get_slot.rb | 3 +++ lib/register/instructions/set_slot.rb | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/register/instructions/get_slot.rb b/lib/register/instructions/get_slot.rb index 0206418f..d2e3fda1 100644 --- a/lib/register/instructions/get_slot.rb +++ b/lib/register/instructions/get_slot.rb @@ -22,6 +22,9 @@ module Register @register = register @array = array @index = index + raise "not integer #{index}" unless index.is_a? Numeric + raise "Not register #{register}" unless Register::RegisterReference.look_like_reg(register) + raise "Not register #{array}" unless Register::RegisterReference.look_like_reg(array) end attr_accessor :register , :array , :index end diff --git a/lib/register/instructions/set_slot.rb b/lib/register/instructions/set_slot.rb index ac0a80ab..ef191210 100644 --- a/lib/register/instructions/set_slot.rb +++ b/lib/register/instructions/set_slot.rb @@ -16,11 +16,14 @@ module Register # If you had a c array and index offset # the instruction would do array[index] = register - # So SGetSlot means the register (first argument) moves to the slot (array and index) + # So SetSlot means the register (first argument) moves to the slot (array and index) def initialize register , array , index @register = register @array = array @index = index + raise "not integer #{index}" unless index.is_a? Numeric + raise "Not register #{register}" unless Register::RegisterReference.look_like_reg(register) + raise "Not register #{array}" unless Register::RegisterReference.look_like_reg(array) end attr_accessor :register , :array , :index end