~lbnz/xr0

533b9f8dc13b6879254c5d5ddc94de19b0dfe40a — Amisi Kiarie 2 months ago 5a9330f
checkpoint
2 files changed, 14 insertions(+), 13 deletions(-)

M src/state/stack.c
M src/state/state.c
M src/state/stack.c => src/state/stack.c +9 -8
@@ 217,10 217,14 @@ stack_str(struct stack *stack, struct state *state)
	struct map *m = stack->varmap;
	for (int i = 0; i < m->n; i++) {
		struct entry e = m->entry[i];
		char *var = variable_str((struct variable *) e.value, stack, state);
		strbuilder_printf(b, "\t%s: %s", e.key, var);
		free(var);
		strbuilder_putc(b, '\n');
		struct variable *v = (struct variable *) e.value;
		char *s = variable_str(v, stack, state);
		strbuilder_printf(b, "\t%d: %s (%s", i, s, e.key);
		if (variable_isparam(v)) {
			strbuilder_printf(b, ", π");
		}
		strbuilder_printf(b, ")\n");
		free(s);
	}
	strbuilder_printf(b, "\t");
	/* TODO: fix length of line */


@@ 615,12 619,9 @@ variable_str(struct variable *var, struct stack *stack, struct state *state)

	struct strbuilder *b = strbuilder_create();
	char *type = ast_type_str(var->type);
	char *loc = location_str(var->loc);
	char *isparam = var->isparam ? "param " : "";
	char *obj_str = object_or_nothing_str(var->loc, stack, state);
	strbuilder_printf(b, "{%s%s := %s} @ %s", isparam, type, obj_str, loc);
	strbuilder_printf(b, "{%s := %s}", type, obj_str);
	free(obj_str);
	free(loc);
	free(type);
	return strbuilder_build(b);
}

M src/state/state.c => src/state/state.c +5 -5
@@ 104,16 104,16 @@ state_str(struct state *state)
		strbuilder_printf(b, "static:\n%s\n", static_mem);
	}
	free(static_mem);
	char *props = props_str(state->props, "\t");
	if (strlen(props) > 0) {
		strbuilder_printf(b, "assume:\n%s\n", props);
	}
	free(props);
	char *vconst = vconst_str(state->vconst, "\t");
	if (strlen(vconst) > 0) {
		strbuilder_printf(b, "rconst:\n%s\n", vconst);
	}
	free(vconst);
	char *props = props_str(state->props, "\t");
	if (strlen(props) > 0) {
		strbuilder_printf(b, "assume:\n%s\n", props);
	}
	free(props);
	char *clump = clump_str(state->clump, "\t");
	if (strlen(clump) > 0) {
		strbuilder_printf(b, "clump:\n%s\n", clump);