Skip to content

Instantly share code, notes, and snippets.

View bakkdoor's full-sized avatar

Christopher Bertels bakkdoor

View GitHub Profile
@bakkdoor
bakkdoor / fiber.fy
Created March 7, 2011 01:42
Running fiber.fy in fancy (with JIT on)
# define some additional methods
class Fiber {
def sleep: seconds {
@sleep_end = Time now + seconds
}
def asleep? {
if: @sleep_end then: {
Time now < @sleep_end
}
backtype ~/projects/rubinius[master] $ rbx
irb(main):001:0> require "rubygems"
=> true
irb(main):002:0> require "fancy"
=> true
irb(main):004:0> r = Range.fy :new, 0, :to, 100
=> 0..100
irb(main):005:0> r.fy :each, Proc.new{|i| i.fy :println}
0
1
require("rubygems")
require("sinatra")
gives me:
An exception occurred running /Users/backtype/projects/fancy/bin/fancy
invalid identifier if_nil: (NameError)
Backtrace:
{ } in Object#DelegateClass at /Users/backtype/projects/rubinius/lib
require("rubygems")
require("sinatra")
get("/") {
"Hello, Sinatra, from Fancy!"
}
Sinatra Application run!()
@bakkdoor
bakkdoor / methods.diff
Created May 4, 2011 07:57
false/nil/true -> methods
diff --git a/lib/compiler/ast/identifier.fy b/lib/compiler/ast/identifier.fy
index 591036b..49e70fa 100644
--- a/lib/compiler/ast/identifier.fy
+++ b/lib/compiler/ast/identifier.fy
@@ -53,9 +53,9 @@ class Fancy AST {
def bytecode: g {
pos(g)
match @string {
- case "true" -> g push_true()
- case "false" -> g push_false()
def while: a do: b {
loop() {
a call if_true: b else: { return nil }
}
}
i = 0
while: { i < 1_000_000 } do: {
i println
i = i + 1
backtype ~/Downloads $ rbx ffi-cairo.rb
An exception occurred running ffi-cairo.rb
Tried to use non-reference value 0x1 as type Float (25) (TypeError)
Backtrace:
Object#__script__ at ffi-cairo.rb:263
Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:65
Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:90
Rubinius::Loader#script at kernel/loader.rb:591
Rubinius::Loader#main at kernel/loader.rb:721
require "rubygems"
require "xmpp4r"
jid = Jabber::JID.new "[email protected]"
client = Jabber::Client.new jid
client.connect
puts "connected!"
client.auth "mysecretpassword"
puts "authenticated!"
client.close
backtype ~/projects/fancy[master] $ rake -v
(in /Users/backtype/projects/fancy)
bison --output /Users/backtype/projects/fancy/lib/parser/ext/parser.c -d -v /Users/backtype/projects/fancy/lib/parser/ext/parser.y
/Users/backtype/projects/fancy/lib/parser/ext/parser.y:182.17-25: warning: type clash on default action: <object> != <>
/Users/backtype/projects/fancy/lib/parser/ext/parser.y: conflicts: 301 shift/reduce, 46 reduce/reduce
flex --outfile /Users/backtype/projects/fancy/lib/parser/ext/lexer.c --header-file=lexer.h /Users/backtype/projects/fancy/lib/parser/ext/lexer.lex
rbx /Users/backtype/projects/fancy/lib/parser/ext/extconf.rb
checking for main() in -lfl... yes
creating Makefile
flex --outfile /Users/backtype/projects/fancy/boot/rbx-compiler/parser/lexer.c --header-file=lexer.h /Users/backtype/projects/fancy/boot/rbx-compiler/parser/lexer.lex
@bakkdoor
bakkdoor / gist:1094462
Created July 20, 2011 06:38
compile error with fxruby
g++ -I. -I. -I/Users/backtype/projects/rubinius/vm/capi/include -I/Users/backtype/projects/idefy/FXRuby-1.6.19/ext/fox16 -DHAVE_SYS_TIME_H -DHAVE_SIGNAL_H -I/usr/local/include/fxscintilla -I/usr/local/include/fox-1.6 -fPIC -ggdb3 -O2 -fPIC -O0 -Iinclude -c FXRuby.cpp
FXRuby.cpp: In function ‘long int FXRbHandleMessage(FX::FXObject*, intptr_t, FX::FXObject*, FX::FXSelector, void*)’:
FXRuby.cpp:1271: error: invalid conversion from ‘intptr_t (*)()’ to ‘intptr_t (*)(...)’
FXRuby.cpp:1271: error: initializing argument 1 of ‘intptr_t rb_rescue2(intptr_t (*)(...), intptr_t, intptr_t (*)(...), intptr_t, ...)’
FXRuby.cpp:1271: error: invalid conversion from ‘intptr_t (*)()’ to ‘intptr_t (*)(...)’
FXRuby.cpp:1271: error: initializing argument 3 of ‘intptr_t rb_rescue2(intptr_t (*)(...), intptr_t, intptr_t (*)(...), intptr_t, ...)’
make: *** [FXRuby.o] Error 1