Baseline: tree as shared
This commit is contained in:
1679 files changed
+1024562
No files matched your search
@@ -0,0 +1,143 @@
|
||||
---
|
||||
title: "Rendered views"
|
||||
subtitle: "Programs beside the page, run while the page renders"
|
||||
---
|
||||
|
||||
Every view on this page was made by `quarto render`: the shortcode handed the files beside the page to Programming+'s own engines, ran them, and wrote what its views drew into the page. There is no iframe here and nothing to load. The views print, and they work offline. A program that stops printing what its `EXPECT` lines say fails the render (this site sets `pplus-strict: true`).
|
||||
|
||||
The programs are in the `programs/` folder beside this page, one file per notation: `count-base.pseudo`, `count-base.lingo`, `mean.tex` and the others. Each one starts with the lines the checker reads:
|
||||
|
||||
```pseudo
|
||||
// CALL: COUNT_BASE('A', "GATTACA")
|
||||
// EXPECT: COUNT_BASE returned 3
|
||||
```
|
||||
|
||||
## Run it
|
||||
|
||||
`pplus-run` runs the program and shows what it printed. When the program has `EXPECT` lines, the view checks the output against them.
|
||||
|
||||
```markdown
|
||||
{{{< pplus-run pseudo="programs/count-base.pseudo" code="1" >}}}
|
||||
```
|
||||
|
||||
{{< pplus-run pseudo="programs/count-base.pseudo" code="1" >}}
|
||||
|
||||
A Mojo file runs on the real `mojo` compiler when the machine that renders the page has one (inside `pixi`, the pinned one). Without one, Programming+'s interpreter runs it, and the view says which of the two printed the output.
|
||||
|
||||
```markdown
|
||||
{{{< pplus-run mojo="programs/count-base.mojo" >}}}
|
||||
```
|
||||
|
||||
{{< pplus-run mojo="programs/count-base.mojo" >}}
|
||||
|
||||
## Step through it
|
||||
|
||||
`pplus-steps` puts the listing beside a stepper. Each step shows the line it ran, what it wrote, and the values after it. The run happened at render time, so the page only moves through it: drag the slider, or click into the view and use ← and →.
|
||||
|
||||
```markdown
|
||||
{{{< pplus-steps pseudo="programs/count-base.pseudo" >}}}
|
||||
```
|
||||
|
||||
{{< pplus-steps pseudo="programs/count-base.pseudo" >}}
|
||||
|
||||
The same procedure in plain English. `lingo` runs as written, with the stepper on its own lines:
|
||||
|
||||
{{< pplus-steps lingo="programs/count-base.lingo" t="6" title="count_base, in lingo, parked at step 6" >}}
|
||||
|
||||
Down at the machine, the stepper follows the registers each instruction writes:
|
||||
|
||||
```markdown
|
||||
{{{< pplus-steps asm="programs/two-pointers.asm" setup="programs/two-pointers.setup" max="40" >}}}
|
||||
```
|
||||
|
||||
{{< pplus-steps asm="programs/two-pointers.asm" setup="programs/two-pointers.setup" max="40" >}}
|
||||
|
||||
## Pictures of the run
|
||||
|
||||
```markdown
|
||||
{{{< pplus-table pseudo="programs/count-base.pseudo" >}}}
|
||||
{{{< pplus-flow pseudo="programs/binary-search.pseudo" >}}}
|
||||
{{{< pplus-dataflow pseudo="programs/count-base.pseudo" >}}}
|
||||
```
|
||||
|
||||
The table of values is the one you would draw by hand: a column for each step that changed something, and a row for each name.
|
||||
|
||||
{{< pplus-table pseudo="programs/count-base.pseudo" >}}
|
||||
|
||||
The flowchart is drawn from the program's structure. Each box is shaded by how often its line ran, and each arrow is labeled with how often it was taken.
|
||||
|
||||
{{< pplus-flow pseudo="programs/binary-search.pseudo" caption="CONTAINS_SORTED([2, 5, 8, 13, 21], 13): three passes of the loop." >}}
|
||||
|
||||
The data-flow graph shows which names feed which:
|
||||
|
||||
{{< pplus-dataflow pseudo="programs/count-base.pseudo" >}}
|
||||
|
||||
Every rendered view can also go live. `live="click"` adds a button that swaps in the interactive view, so a reader can edit the program and run it again:
|
||||
|
||||
```markdown
|
||||
{{{< pplus-flow pseudo="programs/count-base.pseudo" live="click" >}}}
|
||||
```
|
||||
|
||||
{{< pplus-flow pseudo="programs/count-base.pseudo" live="click" >}}
|
||||
|
||||
## Mojo values, made and destroyed
|
||||
|
||||
`pplus-lifetimes` gives each value its own row. The row shows when the value is made, copied, moved and destroyed, as Programming+'s interpreter records it. The file's `# expect-stdout:` lines hold what the real compiler printed for it on Compiler Explorer, so the run below is checked against that.
|
||||
|
||||
{{< pplus-run mojo="programs/lifecycle.mojo" >}}
|
||||
|
||||
{{< pplus-lifetimes mojo="programs/lifecycle.mojo" >}}
|
||||
|
||||
## Say what must be true
|
||||
|
||||
`pplus-proof` checks the claims a specification makes: a pseudo program's `ENSURE` and `INVARIANT` lines, or a `.speco` file woven into it.
|
||||
|
||||
```markdown
|
||||
{{{< pplus-proof pseudo="programs/count-base.pseudo" speco="programs/count-base.speco" code="1" >}}}
|
||||
```
|
||||
|
||||
{{< pplus-proof pseudo="programs/count-base.pseudo" speco="programs/count-base.speco" code="1" >}}
|
||||
|
||||
`pplus-tests` shows the fuzzer's report for every routine. It lists the inputs it tried, the failures it found, and each failure shrunk to the smallest input that still fails.
|
||||
|
||||
{{< pplus-tests pseudo="programs/match-off-by-one.pseudo" >}}
|
||||
|
||||
## What the checker says
|
||||
|
||||
`pplus-check` lists what Programming+ finds in each file before anything runs, on the file's own line numbers:
|
||||
|
||||
```markdown
|
||||
{{{< pplus-check pseudo="programs/five-bugs.pseudo" code="1" numbers="1" >}}}
|
||||
```
|
||||
|
||||
{{< pplus-check pseudo="programs/five-bugs.pseudo" code="1" numbers="1" >}}
|
||||
|
||||
## One procedure, every notation
|
||||
|
||||
`pplus-translate` takes one file and writes the procedure in every notation it can be written in. The Mojo is generated from the pseudo and labeled as generated. With one equation:
|
||||
|
||||
```markdown
|
||||
{{{< pplus-translate matho="programs/mean.tex" >}}}
|
||||
```
|
||||
|
||||
{{< pplus-translate matho="programs/mean.tex" >}}
|
||||
|
||||
`layout="grid"` shows the same panes side by side, highlighted the way the app highlights them:
|
||||
|
||||
{{< pplus-translate lingo="programs/count-base.lingo" layout="grid" to="lingo,pseudo,mojo" >}}
|
||||
|
||||
## The machine
|
||||
|
||||
`pplus-machine` runs the x86-64 on the model machine and counts what it cost: instructions, cycles on two kinds of core, cache misses and branches.
|
||||
|
||||
{{< pplus-machine asm="programs/two-pointers.asm" setup="programs/two-pointers.setup" >}}
|
||||
|
||||
## Every view by name
|
||||
|
||||
`pplus-view` takes the view as an option, for templates that choose it:
|
||||
|
||||
```markdown
|
||||
{{{< pplus-view view="table" lingo="programs/count-base.lingo" >}}}
|
||||
```
|
||||
|
||||
{{< pplus-view view="table" lingo="programs/count-base.lingo" >}}
|
||||
Reference in new issue
Block a user