opal/corelib/proc.rb in opal-0.9.4 vs opal/corelib/proc.rb in opal-0.10.0.beta1
- old
+ new
@@ -14,20 +14,35 @@
%x{
if (block !== nil) {
self.$$p = block;
}
- var result;
+ var result, $brk = self.$$brk;
- if (self.$$is_lambda) {
- result = self.apply(null, args);
+ if ($brk) {
+ try {
+ if (self.$$is_lambda) {
+ result = self.apply(null, args);
+ }
+ else {
+ result = Opal.yieldX(self, args);
+ }
+ } catch (err) {
+ if (err === $brk) {
+ return $brk.$v
+ }
+ else {
+ throw err
+ }
+ }
}
else {
- result = Opal.yieldX(self, args);
- }
-
- if (result === $breaker) {
- return $breaker.$v;
+ if (self.$$is_lambda) {
+ result = self.apply(null, args);
+ }
+ else {
+ result = Opal.yieldX(self, args);
+ }
}
return result;
}
end