return ctx->eval.stack + --ctx->eval.size;
}
-static inline ILStackDesc *
-stack_top (VerifyContext *ctx)
+static ILStackDesc *
+stack_push_stack_val (VerifyContext *ctx, ILStackDesc *value)
{
- return ctx->eval.stack + (ctx->eval.size - 1);
+ ILStackDesc *top = stack_push (ctx);
+ copy_stack_value (top, value);
+ return top;
}
/* Returns the MonoType associated with the token, or NULL if it is invalid.
static void
push_arg (VerifyContext *ctx, unsigned int arg, int take_addr)
{
+ ILStackDesc *top;
+
if (arg >= ctx->max_args) {
if (take_addr)
ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Method doesn't have argument %d", arg + 1));
check_unverifiable_type (ctx, ctx->params [arg]);
if (ctx->params [arg]->byref && take_addr)
CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("ByRef of ByRef at 0x%04x", ctx->ip_offset));
- if (!set_stack_value (ctx, stack_push (ctx), ctx->params [arg], take_addr))
+ top = stack_push (ctx);
+ if (!set_stack_value (ctx, top, ctx->params [arg], take_addr))
return;
if (arg == 0 && !(ctx->method->flags & METHOD_ATTRIBUTE_STATIC)) {
if (take_addr)
ctx->has_this_store = TRUE;
else
- stack_top (ctx)->stype |= THIS_POINTER_MASK;
+ top->stype |= THIS_POINTER_MASK;
}
}
}
if (!check_underflow (ctx, 1))
return;
- value = stack_top (ctx);
+ value = stack_pop (ctx);
/*box is a nop for reference types*/
if (stack_slot_get_underlying_type (value) == TYPE_COMPLEX && MONO_TYPE_IS_REFERENCE (value->type) && MONO_TYPE_IS_REFERENCE (type)) {
- value->stype |= BOXED_MASK;
+ stack_push_stack_val (ctx, value)->stype |= BOXED_MASK;
return;
}
- value = stack_pop (ctx);
if (!verify_stack_type_compatibility (ctx, type, value))
CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Invalid type at stack for boxing operation at 0x%04x", ctx->ip_offset));
ILStackDesc *value;
if (!check_underflow (ctx, 1))
return;
- value = stack_top (ctx);
+ value = stack_pop (ctx);
switch (stack_slot_get_type (value)) {
case TYPE_I4:
case TYPE_I8:
default:
CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Invalid type at stack for unary not at 0x%04x", ctx->ip_offset));
}
+ stack_push_stack_val (ctx, value);
}
static void
static void
do_localloc (VerifyContext *ctx)
{
+ ILStackDesc *top;
+
if (ctx->eval.size != 1) {
ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Stack must have only size item in localloc at 0x%04x", ctx->ip_offset));
return;
return;
}
- set_stack_value (ctx, stack_top (ctx), &mono_defaults.int_class->byval_arg, FALSE);
+ /*TODO verify top type*/
+ top = stack_pop (ctx);
+
+ set_stack_value (ctx, stack_push (ctx), &mono_defaults.int_class->byval_arg, FALSE);
CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Instruction localloc in never verifiable at 0x%04x", ctx->ip_offset));
}
if (!check_underflow (ctx, 1))
return;
- top = stack_top (ctx);
+ top = stack_pop (ctx);
if (stack_slot_get_underlying_type (top) != TYPE_R8)
ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Expected float32 or float64 on stack for ckfinit but found %s at 0x%04x", stack_slot_get_name (top), ctx->ip_offset));
+ stack_push_stack_val (ctx, top);
}
/*
* merge_stacks: