~lbnz/xr0

3ee240d5adac1120867c724bedf4d2746dbb4787 — Xr0 Team 5 months ago 7ec2874
functional parity but stack is aware of scope
2 files changed, 6 insertions(+), 4 deletions(-)

M src/0v/state/location.c
M src/0v/state/state.c
M src/0v/state/location.c => src/0v/state/location.c +5 -3
@@ 62,7 62,6 @@ location_create_automatic(int frame, int block, struct ast_expr *offset)
void
location_destroy(struct location *loc)
{
	/* TODO: leaks */
	ast_expr_destroy(loc->offset);
	free(loc);
}


@@ 147,8 146,11 @@ location_with_offset(struct location *loc, struct ast_expr *offset)
	/* TODO: arithemtically recompute offset */
	assert(offsetzero(loc));

	loc->offset = ast_expr_copy(offset);
	return loc;
	struct location *copy = location_copy(loc);
	copy->offset = ast_expr_copy(offset);

	/* XXX: leaks */
	return copy;
}

bool

M src/0v/state/state.c => src/0v/state/state.c +1 -1
@@ 244,7 244,7 @@ state_deref(struct state *state, struct value *ptr_val, struct ast_expr *index)
	/* `*(ptr+offset)` */
	struct location *deref = location_with_offset(deref_base, index);
	struct object *res = state_get(state, deref, true);
	location_destroy(deref);
	/*location_destroy(deref);*/
	return res;
}