From 6366ede8ee3ad71adab93cb20a170b45dd2c27d1 Mon Sep 17 00:00:00 2001 From: Torsten Date: Tue, 17 Mar 2020 11:00:03 +0200 Subject: [PATCH] check for correct operator was getting passed sol constants --- lib/slot_machine/macro/comparison.rb | 10 ++++++++-- lib/sol/statement.rb | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/slot_machine/macro/comparison.rb b/lib/slot_machine/macro/comparison.rb index 69b0e66d..7b387824 100644 --- a/lib/slot_machine/macro/comparison.rb +++ b/lib/slot_machine/macro/comparison.rb @@ -1,10 +1,16 @@ module SlotMachine class Comparison < Macro + + def self.operators + [:<, :>, :>=, :<=] + end + attr_reader :operator + def initialize(name , operator) super(name) - #TODO check operator to be in valid range - @operator = operator.value + raise "unsuported operator :#{operator}:#{operator.class}:" unless self.class.operators.include?(operator) + @operator = operator end # basically use subtract to subtract left from right (or right from left) diff --git a/lib/sol/statement.rb b/lib/sol/statement.rb index d68ac84f..408334aa 100644 --- a/lib/sol/statement.rb +++ b/lib/sol/statement.rb @@ -73,7 +73,7 @@ module Sol # for loading into a slot, return the "slot_definition" that can be passed to # SlotLoad. def to_slot(compiler) - raise "not iplemented in #{self}" + raise "not implemented in #{self}:#{self.class}" end end