Skip to content

Commit

Permalink
add type .blank-frame
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahsonder committed Jun 5, 2024
1 parent 10634d8 commit 9990e4d
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Changed the `name` attribute to `type` when drawing objects.
- Removed the `isClass` and `stack_frame` attributes and embedded them as the types `.class` and `.frame`.
- Renamed the input for blank objects from `BLANK` to `.blank`.
- Created new type `.blank-frame` to draw blank stack frames.

### ✨ Enhancements

Expand Down
3 changes: 1 addition & 2 deletions demo/src/sample/blanks/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"value": { "lst1": 82, "lst2": 84, "p": 99, "d": 10, "t": 11 }
},
{
"type": ".frame",
"name": ".blank",
"type": ".blank-frame",
"width": 100,
"height": 200
},
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/02-object_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ must contain the following attributes:
"value": {"age": 12, "name": 17}
}

{"type": ".frame", "name": ".blank", "width": 100, "height": 200}
{"type": ".blank-frame", "width": 100, "height": 200}

{"type": "list", "id": 82, "value": [19, 43, 28, 49]}

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/03-automation_algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ also provided a width and a height attribute corresponding to the desired
width and height of the blank space. If such dimensions have not been provided,
a related warning is printed and the object is skipped (no blank space is
recorded). Note that if a blank stack frame is being drawn, the input should
have `type=".frame"` and `name=".blank"`.
have `type=".blank-frame"`.

## Summary

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const listOfObjs = [
id: null,
value: { lst1: 82, lst2: 84, p: 99, d: 10, t: 11 },
},
{ type: ".frame", name: ".blank", width: 100, height: 200 },
{ type: ".frame", width: 100, height: 200 },
{
type: ".frame",
name: "func",
Expand Down
6 changes: 3 additions & 3 deletions memory-viz/src/automate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function drawAutomatedStackFrames(stack_frames, configuration) {
let width;
let height;

if (stack_frame.name !== ".blank") {
if (stack_frame.type !== ".blank-frame") {
const size = getSize(stack_frame);
height = size.height;
width = size.width;
Expand All @@ -87,7 +87,7 @@ function drawAutomatedStackFrames(stack_frames, configuration) {
required_width = width;
}

if (stack_frame.name !== ".blank") {
if (stack_frame.type !== ".blank-frame") {
stack_frame.x = configuration.left_margin;
stack_frame.y = min_required_height;
draw_stack_frames.push(stack_frame);
Expand Down Expand Up @@ -262,7 +262,7 @@ function separateObjects(objects) {
"(either the width or the height is missing). This object will be omitted in the memory model" +
" diagram."
);
} else if (item.type === ".frame") {
} else if (item.type.includes("frame")) {
stackFrames.push(item);
} else {
otherItems.push(item);
Expand Down
5 changes: 3 additions & 2 deletions memory-viz/src/memory_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,9 @@ export class MemoryModel {

obj.style = populateStyleObject(obj, this.seed);

if (obj.type === ".class" || obj.type === ".frame") {
let is_frame = obj.type === ".frame";
let non_objects = [".class", ".frame", ".blank-frame"];
if (non_objects.includes(obj.type)) {
let is_frame = obj.type.includes("frame");

const size = this.drawClass(
obj.x,
Expand Down
2 changes: 1 addition & 1 deletion memory-viz/src/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function populateStyleObject(object, seed) {
object_type = "primitive";
} else if (collections.includes(object.type)) {
object_type = "collection";
} else if (object.type === ".frame") {
} else if (object.type.includes("frame")) {
object_type = "stackframe";
} else {
object_type = "class";
Expand Down
2 changes: 1 addition & 1 deletion memory-viz/src/tests/draw.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ describe("draw function", () => {

it("renders a blank stack frame", () => {
const objects: Array<Object> = [
{ type: ".frame", name: ".blank", width: 100, height: 200 },
{ type: ".blank-frame", width: 100, height: 200 },
{ type: "list", id: 82, value: [19, 43, 28, 49] },
];
const m: InstanceType<typeof MemoryModel> = draw(objects, true, {
Expand Down

0 comments on commit 9990e4d

Please sign in to comment.