lib/instructions/infrastructure.rb in nudge-0.1.3 vs lib/instructions/infrastructure.rb in nudge-0.2.0
- old
+ new
@@ -26,10 +26,14 @@
end
class MissingInstructionError < RuntimeError
end
+ class CodeOversizeError < ArgumentError
+ end
+
+
def initialize(context)
@context = context
end
@@ -49,10 +53,13 @@
return true
end
def pushes(stackName, literal)
+ if (stackName.to_s == "code") && (literal.value.length > self.context.code_char_limit)
+ raise(CodeOversizeError, ":code cannot have more than #{self.context.code_char_limit} chars")
+ end
@context.stacks[stackName].push literal
end
def go
@@ -60,10 +67,10 @@
self.setup
self.derive
self.cleanup
end
rescue NotEnoughStackItems, MissingInstructionError,
- InstructionMethodError, NaNResultError, FloatDomainError => exc
+ InstructionMethodError, NaNResultError, FloatDomainError, CodeOversizeError => exc
msg = ValuePoint.new("error", exc.message)
pushes :error, msg
end