path: root/eval.c
diff options
authortarui <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-15 17:15:31 (GMT)
committertarui <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-15 17:15:31 (GMT)
commit28a1c4f33e3349a98c04b8e068d9c674eb936064 (patch)
tree67534f26a7d3c996c75c558f80151eb28e35dc00 /eval.c
parent9e96b1edea5c52fba05a30fc602288bb100acea7 (diff)
* cont.c : Introdule ensure rollback mechanism. Please see below.
* internal.h (ruby_register_rollback_func_for_ensure): catch up above change. Add rollback mechanism API. * vm_core.h (typedef struct rb_vm_struct): catch up above change. Introdule ensure-rollback relation table. * vm_core.h (typedef struct rb_thread_struct): catch up above change. Introdule ensure stack. * eval.c (rb_ensure): catch up above change. Introdule ensure stack. * hash.c : New function for rollback ensure, and register it to ensure-rollback relation table. [ruby-dev:47803] [Bug #9105] Ensure Rollback Mechanism: A rollback's function is a function to rollback a state before ensure's function execution. When the jump of callcc is across the scope of rb_ensure, ensure's functions and rollback's functions are executed appropriately for keeping consistency. Current API is unstable, and only internal use. ruby_register_rollback_func_for_ensure(ensure_func,rollback_func) This API create relation ensure's function to rollback's function. By registered rollback's function, it is executed When jumpping into corresponding rb_ensure scope. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
1 files changed, 8 insertions, 2 deletions
diff --git a/eval.c b/eval.c
index 5b67e1a..15b0db2 100644
--- a/eval.c
+++ b/eval.c
@@ -840,7 +840,12 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
volatile VALUE result = Qnil;
volatile VALUE errinfo;
rb_thread_t *const th = GET_THREAD();
+ rb_ensure_list_t ensure_list;
+ ensure_list.entry.marker = 0;
+ ensure_list.entry.e_proc = e_proc;
+ ensure_list.entry.data2 = data2;
+ = th->ensure_list;
+ th->ensure_list = &ensure_list;
if ((state = EXEC_TAG()) == 0) {
result = (*b_proc) (data1);
@@ -849,7 +854,8 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
/* TODO: fix me */
/* retval = prot_tag ? prot_tag->retval : Qnil; */ /* save retval */
errinfo = th->errinfo;
- (*e_proc) (data2);
+ th->;
+ (*ensure_list.entry.e_proc)(ensure_list.entry.data2);
th->errinfo = errinfo;
if (state)