-
Notifications
You must be signed in to change notification settings - Fork 7
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
1 parent
80a407a
commit c3ac820
Showing
4 changed files
with
41 additions
and
3 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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
"use @hop/hiphop"; | ||
"use hopscript"; | ||
|
||
import * as hh from "@hop/hiphop"; | ||
import { format } from "util"; | ||
|
||
|
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,29 @@ | ||
import * as hh from "@hop/hiphop"; | ||
import { format } from "util"; | ||
|
||
const Instruments = [ "violin", "piano", "trumpet", "sax" ]; | ||
|
||
function makeAwait(instruments) { | ||
return hiphop fork ${ instruments.map(val => hiphop { | ||
await (this[`${val}IN`].nowval); | ||
emit ${`${val}OUT`}(${val}); | ||
}) } | ||
} | ||
|
||
hiphop module prg() { | ||
in ... ${ Instruments.map(i => `${i}IN`) }; | ||
out ... ${ Instruments.map(i => `${i}OUT`) }; | ||
|
||
${ makeAwait(Instruments) } | ||
} | ||
|
||
export const mach = new hh.ReactiveMachine(prg); | ||
mach.outbuf = ""; | ||
mach.debug_emitted_func = emitted => { | ||
mach.outbuf += format(emitted) + "\n"; | ||
} | ||
|
||
mach.react(); | ||
mach.react({ violinIN: true, saxIN: true }); | ||
mach.react({ pianoIN: true }); | ||
mach.react() |
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 @@ | ||
[] | ||
[ 'violinOUT("violin")', 'saxOUT("sax")' ] | ||
[ 'pianoOUT("piano")' ] | ||
[] |