Compare commits
6 Commits
ee90351c17
...
eac1151616
Author | SHA1 | Date | |
---|---|---|---|
eac1151616 | |||
f7a7100fea | |||
c207d1dfcf | |||
df051fd643 | |||
419ab937b6 | |||
7ff919c31b |
|
@ -1,3 +1,2 @@
|
|||
defn main = { sum 320 6 }
|
||||
defn sum x y = { x + y }
|
||||
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
defn main = { sum 320 6 }
|
||||
defn sum x y = { x + y }
|
||||
|
||||
|
|
|
@ -334,10 +334,10 @@ code for the global function:
|
|||
|
||||
{{< gmachine "Unwind-Global" >}}
|
||||
{{< gmachine_inner "Before">}}
|
||||
\( \text{Unwind} : i \quad a, a_0, a_1, ..., a_n : s \quad d \quad h[\substack{a : \text{NGlobal} \; n \; c \\ a_k : \text{NApp} \; a_{k-1} \; a_k'}] \quad m \)
|
||||
\( \text{Unwind} : i \quad a, a_0, a_1, ..., a_{n-1} : s \quad d \quad h[\substack{a : \text{NGlobal} \; n \; c \\ a_k : \text{NApp} \; a_{k-1} \; a_k'}] \quad m \)
|
||||
{{< /gmachine_inner >}}
|
||||
{{< gmachine_inner "After" >}}
|
||||
\( c \quad a_0', a_1', ..., a_n', a_n : s \quad d \quad h[\substack{a : \text{NGlobal} \; n \; c \\ a_k : \text{NApp} \; a_{k-1} \; a_k'}] \quad m \)
|
||||
\( c \quad a_0', a_1', ..., a_{n-1}', a_{n-1} : s \quad d \quad h[\substack{a : \text{NGlobal} \; n \; c \\ a_k : \text{NApp} \; a_{k-1} \; a_k'}] \quad m \)
|
||||
{{< /gmachine_inner >}}
|
||||
{{< gmachine_inner "Description" >}}
|
||||
Call a global function.
|
||||
|
@ -345,12 +345,12 @@ code for the global function:
|
|||
{{< /gmachine >}}
|
||||
|
||||
In this rule, we used a general rule for \\(a\_k\\), in which \\(k\\) is any number
|
||||
between 0 and \\(n\\). We also expect the `NGlobal` node to contain two parameters,
|
||||
between 1 and \\(n-1\\). We also expect the `NGlobal` node to contain two parameters,
|
||||
\\(n\\) and \\(c\\). \\(n\\) is the arity of the function (the number of arguments
|
||||
it expects), and \\(c\\) are the instructions to construct the function's tree.
|
||||
|
||||
The attentive reader will have noticed a catch: we kept \\(a\_n\\) on the stack!
|
||||
This once again goes back to replacing a node in-place. \\(a\_n\\) is the address of the "root" of the
|
||||
The attentive reader will have noticed a catch: we kept \\(a\_{n-1}\\) on the stack!
|
||||
This once again goes back to replacing a node in-place. \\(a\_{n-1}\\) is the address of the "root" of the
|
||||
whole expression we're simplifying. Thus, to replace the value at this address, we need to keep
|
||||
the address until we have something to replace it with.
|
||||
|
||||
|
|
|
@ -408,10 +408,10 @@ looks as follows for `definition_defn`:
|
|||
|
||||
{{< codelines "C++" "compiler/06/definition.cpp" 44 52 >}}
|
||||
|
||||
Notice that we terminate the function with Update and Pop. This
|
||||
Notice that we terminate the function with Update and Pop. Update
|
||||
will turn the `ast_app` node that served as the "root"
|
||||
of the application into an indirection to the value that we have computed.
|
||||
Doing so will also remove all "scratch work" from the stack.
|
||||
After this, Pop will remove all "scratch work" from the stack.
|
||||
In essense, this is how we can lazily evaluate expressions.
|
||||
|
||||
Finally, we make a function in our `main.cpp` file to compile
|
||||
|
|
|
@ -128,7 +128,7 @@ there's another way.
|
|||
We clean up after ourselves.
|
||||
|
||||
### Towards a Cleaner Stack
|
||||
Simon Peyton Jones wrote his G-machine semantics in a particular way. Every time
|
||||
The G-machine compilation rules Simon Peyton Jones presents are written in a particular way. Every time
|
||||
that a function is called, all it leaves behind on the stack is the graph node
|
||||
that represents the function's output. Our own internal functions, however, have been less
|
||||
careful. Consider, for instance, the "binary operator" function I showed you.
|
||||
|
|
39
themes/vanilla/layouts/rss.xml
Normal file
39
themes/vanilla/layouts/rss.xml
Normal file
|
@ -0,0 +1,39 @@
|
|||
{{- $pctx := . -}}
|
||||
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
|
||||
{{- $pages := slice -}}
|
||||
{{- if or $.IsHome $.IsSection -}}
|
||||
{{- $pages = $pctx.RegularPages -}}
|
||||
{{- else -}}
|
||||
{{- $pages = $pctx.Pages -}}
|
||||
{{- end -}}
|
||||
{{- $limit := .Site.Config.Services.RSS.Limit -}}
|
||||
{{- if ge $limit 1 -}}
|
||||
{{- $pages = $pages | first $limit -}}
|
||||
{{- end -}}
|
||||
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
|
||||
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
|
||||
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
|
||||
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
|
||||
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
|
||||
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
|
||||
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
|
||||
{{ with .OutputFormats.Get "RSS" }}
|
||||
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
|
||||
{{ end }}
|
||||
{{ range $pages }}
|
||||
<item>
|
||||
<title>{{ .Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
|
||||
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
|
||||
<guid>{{ .Permalink }}</guid>
|
||||
<description>{{ .Content | html }}</description>
|
||||
</item>
|
||||
{{ end }}
|
||||
</channel>
|
||||
</rss>
|
Loading…
Reference in New Issue
Block a user