Skip to content

Instantly share code, notes, and snippets.

View bakkdoor's full-sized avatar

Christopher Bertels bakkdoor

View GitHub Profile
# asm.rb
def hello(name)
Rubinius.asm(name) do |name|
push :self
run name
string_dup
push_literal "hello, "
string_dup
string_append
send :p, 1, true
def map: block {
"Returns a new @Array@ with the results of calling a given block for every element"
coll = []
each: |x| {
if: (block argcount == 0) then: {
coll << (block call_with_receiver: x) # <- had to add this part..
} else: {
coll << (block call: [x])
}
@bakkdoor
bakkdoor / simple_irc_bot.fy
Created November 24, 2010 13:21
A sample of how the FancyIRC lib could work.
bot = FancyIRC Client new: {
configuration: {
nickname: "fancy_irc"
server: "irc.freenode.net"
port: 6667
channels: ["#fancy"]
}
on: 'channel pattern: /^hello/ do: |msg| {
msg reply: $ "Hello to you too, " ++ (msg author) ++ "?"
bakkdoor:~/projekte/fancy/fancy-lang[master*]> diff boot/.wootstrap/compiler/ast/message_send.fyc boot/compiler/compiler/ast/message_send.fyc
846c846
< 27
---
> 29
883a884,887
> 29
> I
> e
> I
@bakkdoor
bakkdoor / rakefile.patch
Created November 17, 2010 16:55
Slow as hell but seems to work ... -_-
diff --git a/Rakefile b/Rakefile
index 2fd6050..c94ec50 100644
--- a/Rakefile
+++ b/Rakefile
@@ -81,13 +81,19 @@ namespace :compiler do
cmd << "--"
cmd << "--batch" if RakeFileUtils.verbose_flag == true
- source_dirs = ["lib", "lib/parser", "lib/compiler", "lib/compiler/ast",
- "lib/rbx", "lib/package", "boot"]
bakkdoor@bakkdoor-thinkpad:~/Desktop$ rvm use rbx-head
Using /home/bakkdoor/.rvm/gems/rbx-head
bakkdoor@bakkdoor-thinkpad:~/Desktop$ git clone git://github.com/bakkdoor/fancy
Initialized empty Git repository in /home/bakkdoor/Desktop/fancy/.git/
remote: Counting objects: 12377, done.
remote: Compressing objects: 100% (3910/3910), done.
remote: Total 12377 (delta 9187), reused 11243 (delta 8350)
Receiving objects: 100% (12377/12377), 2.86 MiB | 1.05 MiB/s, done.
Resolving deltas: 100% (9187/9187), done.
bakkdoor@bakkdoor-thinkpad:~/Desktop$ cd fancy
bakkdoor@bakkdoor-thinkpad:~/Desktop/fancy$ rvm use rbx-head
Using /home/bakkdoor/.rvm/gems/rbx-head
bakkdoor@bakkdoor-thinkpad:~/Desktop/fancy$
bakkdoor@bakkdoor-thinkpad:~/Desktop/fancy$ rake bootstrap
(in /home/bakkdoor/Desktop/fancy)
rbx /home/bakkdoor/Desktop/fancy/lib/parser/ext/extconf.rb
checking for main() in -lfl... yes
creating Makefile
make -C /home/bakkdoor/Desktop/fancy/lib/parser/ext
make: Gehe in Verzeichnis '/home/bakkdoor/Desktop/fancy/lib/parser/ext'
@bakkdoor
bakkdoor / Fresh rake bootstrap
Created November 17, 2010 02:39
On a fresh ubuntu 10.10 (x64) installation, via rvm rbx-head...
bakkdoor@bakkdoor-thinkpad:~/Desktop/fancy$ rake bootstrap
(in /home/bakkdoor/Desktop/fancy)
rbx /home/bakkdoor/Desktop/fancy/lib/parser/ext/extconf.rb
checking for main() in -lfl... yes
creating Makefile
make -C /home/bakkdoor/Desktop/fancy/lib/parser/ext
make: Gehe in Verzeichnis '/home/bakkdoor/Desktop/fancy/lib/parser/ext'
gcc -I. -I. -I/home/bakkdoor/.rvm/rubies/rbx-head/include -I/home/bakkdoor/Desktop/fancy/lib/parser/ext -fPIC -ggdb3 -O2 -fPIC -c parser.c
gcc -I. -I. -I/home/bakkdoor/.rvm/rubies/rbx-head/include -I/home/bakkdoor/Desktop/fancy/lib/parser/ext -fPIC -ggdb3 -O2 -fPIC -c ext.c
gcc -I. -I. -I/home/bakkdoor/.rvm/rubies/rbx-head/include -I/home/bakkdoor/Desktop/fancy/lib/parser/ext -fPIC -ggdb3 -O2 -fPIC -c lexer.c
bakkdoor:~/Desktop/fancy[bootstrap*]> rake bootstrap -v
(in /home/bakkdoor/Desktop/fancy)
make -C /home/bakkdoor/Desktop/fancy/lib/parser/ext
make: Gehe in Verzeichnis '/home/bakkdoor/Desktop/fancy/lib/parser/ext'
gcc -I. -I. -I/home/bakkdoor/projekte/ruby/rubinius/vm/capi/include -I/home/bakkdoor/Desktop/fancy/lib/parser/ext -fPIC -ggdb3 -O2 -fPIC -c ext.c
gcc -I. -I. -I/home/bakkdoor/projekte/ruby/rubinius/vm/capi/include -I/home/bakkdoor/Desktop/fancy/lib/parser/ext -fPIC -ggdb3 -O2 -fPIC -c parser.c
gcc -I. -I. -I/home/bakkdoor/projekte/ruby/rubinius/vm/capi/include -I/home/bakkdoor/Desktop/fancy/lib/parser/ext -fPIC -ggdb3 -O2 -fPIC -c lexer.c
cc -shared -o fancy_parser.so ext.o parser.o lexer.o -L. -L/home/bakkdoor/projekte/ruby/rubinius/lib -lfl
make: Verlasse Verzeichnis '/home/bakkdoor/Desktop/fancy/lib/parser/ext'
mkdir -p /home/bakkdoor/Desktop/fancy/boot/compiler/parser/ext
@bakkdoor
bakkdoor / 2
Created November 17, 2010 00:55
1
bakkdoor:~/Desktop/fancy[bootstrap*]> rbx /home/bakkdoor/Desktop/fancy/boot/load.rb /home/bakkdoor/Desktop/fancy/boot/compiler/boot.fyc /home/bakkdoor/Desktop/fancy/boot/compiler/compiler.fyc /home/bakkdoor/Desktop/fancy/boot/compiler/compiler/command.fyc /home/bakkdoor/Desktop/fancy/boot/compiler/compile.fyc -- lib/**/*.fy --batch
Compiling lib/compiler/ast.fy
Compiling lib/compiler/command.fy
Compiling lib/compiler/compiler.fy
Compiling lib/compiler/stages.fy
Compiling lib/package/dependency.fy
Compiling lib/package/installer.fy
Compiling lib/package/specification.fy
Compiling lib/package/uninstaller.fy
Compiling lib/parser/methods.fy