{
int breakcheck_count = 0;
typval_T *tv;
+ int ret = FAIL;
+ int save_trylevel_at_start = ectx->ec_trylevel_at_start;
// Start execution at the first instruction.
ectx->ec_iidx = 0;
// Turn CTRL-C into an exception.
got_int = FALSE;
if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) == FAIL)
- return FAIL;
+ goto theend;
did_throw = TRUE;
}
// Turn an error message into an exception.
did_emsg = FALSE;
if (throw_exception(*msg_list, ET_ERROR, NULL) == FAIL)
- return FAIL;
+ goto theend;
did_throw = TRUE;
*msg_list = NULL;
}
// Not inside try or need to return from current functions.
// Push a dummy return value.
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
tv = STACK_TV_BOT(0);
tv->v_type = VAR_NUMBER;
tv->vval.v_number = 0;
// At the toplevel we are done.
need_rethrow = TRUE;
if (handle_closure_in_use(ectx, FALSE) == FAIL)
- return FAIL;
+ goto theend;
goto done;
}
if (func_return(ectx) == FAIL)
- return FAIL;
+ goto theend;
}
continue;
}
int save_flags = cmdmod.cmod_flags;
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
tv = STACK_TV_BOT(0);
init_tv(tv);
cmdmod.cmod_flags |= CMOD_LEGACY;
case ISN_INSTR:
{
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
tv = STACK_TV_BOT(0);
tv->vval.v_instr = ALLOC_ONE(instr_T);
if (tv->vval.v_instr == NULL)
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
{
vim_free(res);
- return FAIL;
+ goto theend;
}
tv = STACK_TV_BOT(0);
tv->v_type = VAR_STRING;
{
cmd = alloc(len + 1);
if (cmd == NULL)
- return FAIL;
+ goto theend;
len = 0;
}
}
// load local variable or argument
case ISN_LOAD:
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
copy_tv(STACK_TV_VAR(iptr->isn_arg.number), STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
break;
// load v: variable
case ISN_LOADV:
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
copy_tv(get_vim_var_tv(iptr->isn_arg.number), STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
break;
sv = get_script_svar(sref, ectx);
if (sv == NULL)
- return FAIL;
+ goto theend;
allocate_if_null(sv->sv_tv);
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
copy_tv(sv->sv_tv, STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
}
else
{
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
copy_tv(&di->di_tv, STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
}
namespace = 't';
break;
default: // Cannot reach here
- return FAIL;
+ goto theend;
}
di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE);
else
{
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
copy_tv(&di->di_tv, STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
}
char_u *name = iptr->isn_arg.string;
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
SOURCING_LNUM = iptr->isn_lnum;
if (eval_variable(name, (int)STRLEN(name),
STACK_TV_BOT(0), NULL, EVAL_VAR_VERBOSE) == FAIL)
case ISN_LOADWDICT: d = curwin->w_vars; break;
case ISN_LOADTDICT: d = curtab->tp_vars; break;
default: // Cannot reach here
- return FAIL;
+ goto theend;
}
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
tv = STACK_TV_BOT(0);
tv->v_type = VAR_DICT;
tv->v_lock = 0;
// This is not expected to fail, name is checked during
// compilation: don't set SOURCING_LNUM.
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
if (eval_option(&name, &optval, TRUE) == FAIL)
- return FAIL;
+ goto theend;
*STACK_TV_BOT(0) = optval;
++ectx->ec_stack.ga_len;
}
char_u *name = iptr->isn_arg.string;
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
// name is always valid, checked when compiling
(void)eval_env_var(&name, &optval, TRUE);
*STACK_TV_BOT(0) = optval;
// load @register
case ISN_LOADREG:
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
tv = STACK_TV_BOT(0);
tv->v_type = VAR_STRING;
tv->v_lock = 0;
sv = get_script_svar(sref, ectx);
if (sv == NULL)
- return FAIL;
+ goto theend;
--ectx->ec_stack.ga_len;
// "const" and "final" are checked at compile time, locking
ht = &curtab->tp_vars->dv_hashtab;
break;
default: // Cannot reach here
- return FAIL;
+ goto theend;
}
--ectx->ec_stack.ga_len;
goto on_error;
// append to list, only fails when out of memory
if (list_append_tv(list, tv) == FAIL)
- return FAIL;
+ goto theend;
clear_tv(tv);
}
}
goto on_error;
// add to dict, only fails when out of memory
if (dict_add_tv(dict, (char *)key, tv) == FAIL)
- return FAIL;
+ goto theend;
clear_tv(tv);
}
}
{
SOURCING_LNUM = iptr->isn_lnum;
iemsg("LOADOUTER depth more than scope levels");
- return FAIL;
+ goto theend;
}
tv = ((typval_T *)outer->out_stack->ga_data)
+ outer->out_frame_idx + STACK_FRAME_SIZE
if (iptr->isn_type == ISN_LOADOUTER)
{
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
copy_tv(tv, STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
}
case ISN_PUSHCHANNEL:
case ISN_PUSHJOB:
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
tv = STACK_TV_BOT(0);
tv->v_lock = 0;
++ectx->ec_stack.ga_len;
// for the list header and the items
case ISN_NEWLIST:
if (exe_newlist(iptr->isn_arg.number, ectx) == FAIL)
- return FAIL;
+ goto theend;
break;
// create a dict from items on the stack
int idx;
if (dict == NULL)
- return FAIL;
+ goto theend;
for (idx = 0; idx < count; ++idx)
{
// have already checked key type is VAR_STRING
if (item == NULL)
{
dict_unref(dict);
- return FAIL;
+ goto theend;
}
item->di_tv = *STACK_TV_BOT(2 * (idx - count) + 1);
item->di_tv.v_lock = 0;
{
// can this ever happen?
dict_unref(dict);
- return FAIL;
+ goto theend;
}
}
if (count > 0)
ectx->ec_stack.ga_len -= 2 * count - 1;
else if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
else
++ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(-1);
// return from a :def function call
case ISN_RETURN_ZERO:
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
tv = STACK_TV_BOT(0);
++ectx->ec_stack.ga_len;
tv->v_type = VAR_NUMBER;
+ iptr->isn_arg.funcref.fr_func;
if (pt == NULL)
- return FAIL;
+ goto theend;
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
{
vim_free(pt);
- return FAIL;
+ goto theend;
}
if (fill_partial_and_closure(pt, pt_dfunc->df_ufunc,
ectx) == FAIL)
- return FAIL;
+ goto theend;
tv = STACK_TV_BOT(0);
++ectx->ec_stack.ga_len;
if (copy_func(newfunc->nf_lambda, newfunc->nf_global,
ectx) == FAIL)
- return FAIL;
+ goto theend;
}
break;
STACK_TV_VAR(iptr->isn_arg.forloop.for_idx);
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
if (ltv->v_type == VAR_LIST)
{
list_T *list = ltv->vval.v_list;
{
semsg(_(e_for_loop_on_str_not_supported),
vartype_name(ltv->v_type));
- return FAIL;
+ goto theend;
}
}
break;
trycmd_T *trycmd = NULL;
if (GA_GROW(&ectx->ec_trystack, 1) == FAIL)
- return FAIL;
+ goto theend;
trycmd = ((trycmd_T *)ectx->ec_trystack.ga_data)
+ ectx->ec_trystack.ga_len;
++ectx->ec_trystack.ga_len;
{
SOURCING_LNUM = iptr->isn_lnum;
iemsg("Evaluating catch while current_exception is NULL");
- return FAIL;
+ goto theend;
}
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
tv = STACK_TV_BOT(0);
++ectx->ec_stack.ga_len;
tv->v_type = VAR_STRING;
{
siemsg("TRYCONT: expected %d levels, found %d",
trycont->tct_levels, trystack->ga_len);
- return FAIL;
+ goto theend;
}
// Make :endtry jump to any outer try block and the last
// :endtry inside the loop to the loop start.
vim_free(tv->vval.v_string);
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_throw_with_empty_string));
- return FAIL;
+ goto theend;
}
// Inside a "catch" we need to first discard the caught
== FAIL)
{
vim_free(tv->vval.v_string);
- return FAIL;
+ goto theend;
}
did_throw = TRUE;
}
goto on_error;
}
if (list_append_tv(l, tv2) == FAIL)
- return FAIL;
+ goto theend;
clear_tv(tv2);
--ectx->ec_stack.ga_len;
}
li = list_find(tv->vval.v_list, index);
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
++ectx->ec_stack.ga_len;
copy_tv(&li->li_tv, STACK_TV_BOT(-1));
goto on_error;
if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
- return FAIL;
+ goto theend;
++ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(-1);
tv->v_type = VAR_NUMBER;
CHECK_LIST_MATERIALIZE(l);
if (GA_GROW(&ectx->ec_stack, count - 1) == FAIL)
- return FAIL;
+ goto theend;
ectx->ec_stack.ga_len += count - 1;
// Variable after semicolon gets a list with the remaining
list_alloc_with_items(l->lv_len - count + 1);
if (rem_list == NULL)
- return FAIL;
+ goto theend;
tv = STACK_TV_BOT(-count);
tv->vval.v_list = rem_list;
++rem_list->lv_refcount;
if (func_return(ectx) == FAIL)
// only fails when out of memory
- return FAIL;
+ goto theend;
continue;
on_error:
// Jump here for an error that messes up the stack.
// If we are not inside a try-catch started here, abort execution.
if (trylevel <= ectx->ec_trylevel_at_start)
- return FAIL;
+ goto theend;
}
done:
- return OK;
+ ret = OK;
+theend:
+ ectx->ec_trylevel_at_start = save_trylevel_at_start;
+ return ret;
}
/*