lib/nydp/builtin/ensuring.rb in nydp-0.5.1 vs lib/nydp/builtin/ensuring.rb in nydp-0.6.0

- old
+ new

@@ -1,28 +1,13 @@ -require "nydp/vm" +# require "nydp/vm" class Nydp::Builtin::Ensuring include Nydp::Helper, Nydp::Builtin::Base, Singleton - class InvokeProtection - include Nydp::VM::Finally - attr_reader :protection - - def initialize protection - @protection = protection + def builtin_call ensureme, tricky + begin + tricky.call + ensure + ensureme.call end - - def execute vm - protection.invoke vm, Nydp::NIL - end - end - - def builtin_invoke vm, args - fn_ensure = args.car - fn_tricky = args.cdr.car - - protection_instructions = Nydp::Pair.from_list [InvokeProtection.new(fn_ensure), Nydp::PopArg] - vm.push_ctx_instructions protection_instructions - - fn_tricky.invoke vm, Nydp::NIL end end