-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComposeOptions } from "../compose/compose" | ||
import { composeNode } from "../compose/composeNode" | ||
import { Env } from "../env" | ||
import { formatValue } from "../value" | ||
|
||
export function compose(env: Env, options: ComposeOptions): void { | ||
const value = env.stack.pop() | ||
if (value === undefined) { | ||
throw new Error(`[@apply] I expect a value on the stack.`) | ||
} | ||
|
||
if (value["@kind"] !== "Node") { | ||
throw new Error( | ||
[ | ||
`[@apply] I expect the value on top of the stack to be a Node.`, | ||
``, | ||
` node: ${formatValue(value)}`, | ||
].join("\n"), | ||
) | ||
} | ||
|
||
composeNode(env, value, options) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
type Nat -- @Type end | ||
node zero -- Nat :value! end | ||
node add1 Nat :prev -- Nat :value! end | ||
|
||
(zero) @apply @inspect | ||
(add1) @apply @inspect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
net_from_port (zero₀)-value! end | ||
net_from_port (add1₀)-value! | ||
(add1₀)-prev value-(zero₀) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters