Skip to content

Instantly share code, notes, and snippets.

View macournoyer's full-sized avatar

Marc-André Cournoyer macournoyer

View GitHub Profile
@macournoyer
macournoyer / gist:80852
Created March 18, 2009 00:14
Lua-like upvalues in tinyrb
def yielder
yield
end
x = "yeaaah!"
yielder do
yielder do
x
end
is_indexed :fields => %w(title description created_at updated_at),
:include => [{:association_name => 'location', :field => 'locality', :as => 'locality'},
{:association_name => 'location', :field => 'region', :as => 'region'},
{:association_name => 'location', :field => 'country', :as => 'country'}],
:concatenate => [{:fields => %w(locality region country), :as => "location"}],
:delta => true
generator = Compiler::TextGenerator.new
node = Compiler.compile_string "1", binding
node.bytecode generator
puts generator.text
x = 1
while x < 50000000
x = x + 1
end
; block definition: 0xaaf80 (level 0)
; 2 registers ; 0 nested blocks
; 0 args
.local x ; 0
.value 1 ; 0
======================environment======================
yarv
command: ruby19
version: ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.6.0]
jruby
command: PATH=$JDKS_ROOT/1.6.0/Home/bin:$PATH ~/projects/jruby/bin/jruby -server --fast
version: jruby 1.3.0 (ruby 1.8.6 patchlevel 287) (2009-03-12 rev 9393) [x86_64-java]
mri
command: ruby
version: ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-darwin9.3.0]
./tinyrb -d -e "1 + 2"
; block definition: 0x219f80 (level 0)
; 2 registers ; 0 nested blocks
; 0 args
.value 1 ; 0
.value 2 ; 1
[000] add 0 256 257
[001] return 0 0 0
; block end
_STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3 -fno-exceptions -fno-common -Woverloaded-virtual -mmacosx-version-min=10.5 -Wall -W -Wwrite-strings -Wunused -Wno-unused-parameter -fstrict-aliasing -Wstrict-aliasing -arch i386 -arch x86_64 -c TimeValue.cpp -o /Users/marc/projects/llvm/llvm/lib/System/Release/TimeValue.o
llvm[1]: Building Release Archive Library libLLVMSystem.a
make[1]: *** [/Users/marc/projects/llvm/llvm/Release/lib/libLLVMSystem.a] Error 1
make: *** [all] Error 1
diff --git a/vm/string.c b/vm/string.c
index 64fa97e..9e8dd3e 100644
--- a/vm/string.c
+++ b/vm/string.c
@@ -1,3 +1,4 @@
+#include <alloca.h>
#include <stdarg.h>
#include <stdio.h>
#include "tr.h"
@@ -124,14 +125,11 @@ OBJ tr_sprintf(VM, const char *fmt, ...) {
Nice = Object clone do(
yo = method(
"yo"
).
is = method(
"indeed"
).
).
@macournoyer
macournoyer / example.io
Created April 23, 2009 13:36
mio -- a lil tiny subset of Io all in Ruby
Xzibit = Object clone do(
dawg = method(what,
"yo dawg" print.
what print.
"clone" print.
self
).
so_you_can = method(
"so you can print" print.