symbols and keywords now have a hash value
This commit is contained in:
+16
-12
@@ -6,9 +6,10 @@ proc visualize_lisp_machine() -> void {
|
||||
int height;
|
||||
};
|
||||
|
||||
fprintf(stderr, "Drawing visualization...");
|
||||
log_message(Log_Level::Info, "Drawing visualization...");
|
||||
|
||||
defer {
|
||||
fprintf(stderr, "Done!\n");
|
||||
log_message(Log_Level::Info, "Done drawing visualization!");
|
||||
};
|
||||
|
||||
const int padding = 40;
|
||||
@@ -20,15 +21,14 @@ proc visualize_lisp_machine() -> void {
|
||||
|
||||
|
||||
FILE *f = fopen("visualization.svg", "w");
|
||||
defer {
|
||||
fclose(f);
|
||||
};
|
||||
|
||||
if (f == NULL) {
|
||||
create_generic_error("The file for writing the visualization"
|
||||
if (!f) {
|
||||
create_generic_error("The file for writing the visualization "
|
||||
"could not be opened for writing");
|
||||
return;
|
||||
}
|
||||
defer {
|
||||
fclose(f);
|
||||
};
|
||||
|
||||
int max_x = 0,
|
||||
max_y = 0,
|
||||
@@ -170,7 +170,7 @@ proc visualize_lisp_machine() -> void {
|
||||
case Lisp_Object_Type::Keyword: {
|
||||
Drawn_Area colon = draw_text(":", "#c61b6e");
|
||||
write_x += colon.width;
|
||||
Drawn_Area text = draw_text(&obj->value.identifier->data, "#c61b6e");
|
||||
Drawn_Area text = draw_text(&obj->value.symbol.identifier->data, "#c61b6e");
|
||||
write_x -= colon.width;
|
||||
return {
|
||||
colon.x,
|
||||
@@ -179,8 +179,12 @@ proc visualize_lisp_machine() -> void {
|
||||
colon.height
|
||||
};
|
||||
}
|
||||
case Lisp_Object_Type::String: return draw_text(&obj->value.string->data, "#2aa198", true, 20);
|
||||
default: return {0};
|
||||
case Lisp_Object_Type::String: return draw_text(&obj->value.string->data, "#2aa198", true, 20);
|
||||
case Lisp_Object_Type::Function: return draw_text("Function", "#aa1100");
|
||||
case Lisp_Object_Type::CFunction: return draw_text("CFunction", "#11aa00");
|
||||
default:
|
||||
fprintf(stderr, "Do not know hot to visualize type %d\n", Memory::get_type(obj));
|
||||
return {0};
|
||||
}
|
||||
};
|
||||
draw_pair = [&](Lisp_Object* pair) -> Drawn_Area {
|
||||
@@ -439,7 +443,7 @@ proc visualize_lisp_machine() -> void {
|
||||
draw_new_line();
|
||||
write_x = start_x;
|
||||
|
||||
draw_text(&symbols->data[i]->value.identifier->data);
|
||||
draw_text(&symbols->data[i]->value.symbol.identifier->data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user