Skip to content

Instantly share code, notes, and snippets.

" treetop.vim
" syntax file for treetop.
" Author: NANKI Haruo.
let b:ruby_no_expensive=1
syntax match ttOperators /[&~!*+?\/]/
syntax keyword ttDefine end
syntax keyword ttKeywords include super
diff --git a/ext/llvm_basicblock.cpp b/ext/llvm_basicblock.cpp
index e9937b1..83b5bc4 100644
--- a/ext/llvm_basicblock.cpp
+++ b/ext/llvm_basicblock.cpp
@@ -133,7 +133,7 @@ llvm_builder_malloc(VALUE self, VALUE rtype, VALUE rsize) {
const Type *type;
Data_Get_Struct(rtype, Type, type);
- Value *size = ConstantInt::get(Type::Int32Ty, FIX2INT(rsize));
+ Value *size = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), FIX2INT(rsize));
@str = internal constant [4 x i8] c"%d\0A\00"
define void @main() nounwind {
%fact = call i32 @fact.tr(i32 5)
call i32 @printf( i8* getelementptr ([4 x i8]* @str, i32 0,i32 0), i32 %fact)
ret void
}
; tail recurse
define i32 @fact.tr(i32 %n) nounwind {
; ModuleID = '<stdin>'
define void @main() nounwind {
%r.1 = alloca double ; <double*> [#uses=3]
store double 1.000000e+00, double* %r.1
%r.9 = alloca double ; <double*> [#uses=3]
store double 9.000000e+00, double* %r.9
br label %loop
loop: ; preds = %switch, %0
@nanki
nanki / edit.rb
Created March 28, 2011 13:15
Edit ruby string by the editor.
# editor.rb
#
# $ irb -reditor
# > Editor.edit("abc") # Edit "abc" with the external editor.
# => "abc has changed"
#
# Author: @nanki / nanki at dotswitch dot net
require 'tempfile'
puts (1..100).map{|i|[[i, :Fizz], [:Buzz, :FizzBuzz]][(1 - i**4) % 5][(1 - i**2) % 3]}
@nanki
nanki / ff.rb
Created August 27, 2011 07:02
file filter: $ ff -@bin -_test.rb controller ...
#!/usr/bin/env ruby
require 'open3'
EXCLUDE_EXTENTSONS = %w(psd gif jpg png DS_Store tmp JPG PNG swp swf o bundle dylib so)
EXCLUDE_FROM_CURRENT = %w(estraier tmp log coverage build)
subdirs = Dir.glob("*")
subdirs -= EXCLUDE_FROM_CURRENT
def process_args(argv, _subdirs, _patterns)
@nanki
nanki / sirb.rb
Created September 3, 2011 07:37
Super-interactive ruby console.
#!/usr/bin/env ruby
# -*- coding: UTF-8 -*-;
require 'io/console'
require 'ansi'
class Textbox
def initialize(input=$stdin)
@input = input
end
@nanki
nanki / console.c.diff
Created September 8, 2011 20:11
io-console for jruby.
--- console.c.orig 2011-09-09 04:59:09.000000000 +0900
+++ console.c 2011-09-09 05:08:30.000000000 +0900
@@ -4,6 +4,9 @@
*/
#include "ruby.h"
#include "rubyio.h"
+
+#include <errno.h>
+
#ifndef HAVE_RB_IO_T
@nanki
nanki / a.rb
Created September 11, 2011 08:57
1.8.7/1.9.2
# $ echo 'class B;end' > b.rb
b = Thread.new { p autoload(:B, './b') }
sleep 0.00002
b.kill
B