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
import arduino | |
# Pin 13 has an LED connected to it on most Arduino boards | |
var led_pin = arduino.gpio[13] | |
# Time we'll wait between toggling the LED | |
var delay = arduino.delay.milliseconds(1000) | |
# Configure the LED pin as an output | |
led_pin.set_direction(OUTPUT) |
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
import max1234 | |
part MAX1 is max1234 | |
interface I2C: | |
pin DATA | |
pin CLOCK | |
interface SPIBus: |
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
import time | |
import coll | |
enum HourType: | |
#: A 12-hour time in the morning. | |
AM | |
#: A 12-hour time in the afternoon/evening. | |
PM | |
#: A 24-hour time |
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
#include <stdio.h> | |
// we'd generate one of these for each distinct function signature | |
typedef struct { | |
void (*func)(); | |
void *env; | |
} Callable; | |
// we'd generate an environment struct for each function that needs one |
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
all: blink.bin | |
blink.bc: blink.ll | |
opt-3.4 blink.ll -o blink.bc -basiccg -domtree -reg2mem -inline -constprop -die -adce -mem2reg | |
blink.s: blink.bc | |
llc-3.4 -march=thumb blink.bc -o blink.s | |
%.o: %.s | |
arm-none-eabi-as $< -o $@ |
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
all: blink.bin | |
blink.ll: genblink.py | |
python genblink.py >blink.ll | |
blink.bc: blink.ll | |
opt-3.4 blink.ll -o blink.bc | |
blink.s: blink.bc | |
llc-3.4 -march=thumb blink.bc -o blink.s |
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
// Example of aggregating channel values into sets based on a key. | |
// In this case, we aggregate strings by their first letter. | |
// Aggregated groups are emitted as slices when one of the following is true: | |
// - the buffer capacity is reached (set to 2 in this demo so we can hit it easily with the test data) | |
// - no new items have shown up for that group for two seconds | |
// - the source channel is closed | |
// | |
// The primary use case for this sort of thing is in forming higher-level transactions from an event stream, | |
// such as aggregating a log of actions by userid into a set of events that represents a session. |
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 generates tree.h by packing a set of strings into a Radix Tree structure. | |
words = [ | |
"martin", | |
"martina", | |
"mark", | |
"matthew", | |
"adriana", | |
"adrian", |
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
libfoo.so: foo.o | |
gcc foo.o -shared -o libfoo.so | |
foo.o: foo.ll | |
llc-3.3 -filetype=obj -relocation-model=pic foo.ll | |
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
protothread: protothread.o | |
gcc protothread.o -o protothread | |
protothread.o: protothread.s | |
as protothread.s -o protothread.o | |
protothread.s: protothread.ll | |
llc-3.4 protothread.ll |
OlderNewer