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
fib = Fiber.new do | |
x, y = 0, 1 | |
loop do | |
puts "before stop" | |
Fiber.yield y | |
puts "after stop" | |
x,y = y,x+y | |
end | |
end |
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
class FileDb | |
def self.open(path) | |
if File.exist?(path) | |
file = File.open(path, "r") | |
self.parse(file.read) | |
else | |
Hash.new | |
end | |
ensure | |
file.close if file |
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
2.0.0-p247 :001 > gets | |
123456789 | |
=> "123456789\n" | |
2.0.0-p247 :002 > gets("5") | |
1 | |
2 | |
3 | |
4 | |
5 | |
=> "1\n2\n3\n4\n5" |
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
module V1Compatibility | |
def self.flat(klass) | |
# create alias or change behaviour | |
class << klass::IO | |
def getc | |
puts "method getc old behaviour" | |
end | |
alias_method :read_card_old, :read_card | |
end |
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
if (IDE.settings.is_ruby) { | |
// EMULATING RUBY CODE | |
// --- DEVELOPMENT --- | |
console.log("LAST MRB IN B64", IDE.compiler.last_result.mrb); | |
// --- DEVELOPMENT --- | |
b = new Uint8Array(atob(IDE.compiler.last_result.mrb).split("").map(function(c) { return c.charCodeAt(0); })); | |
webruby.run_source(emulator.code.POS); | |
webruby.run_source("IO.display(0,0,'lol')"); | |
//webruby.run_bytecode(b); | |
} |
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
module Kernel | |
def _load(path) | |
raise NotImplementedError.new "'require' method depends on File" unless Object.const_defined?(:File) | |
raise TypeError unless path.class == String | |
if File.exist?(path) && File.extname(path) == ".mrb" | |
_load_mrb_file path | |
elsif File.exist?(path) | |
_load_rb_str File.open(path).read.to_s, path | |
else |
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
IO.display 0, 0, "Start" | |
begin | |
IO.getc | |
a = load("./show.mrb") | |
p "AAAAAAA" | |
rescue => @e | |
p @e.inspect | |
p @e.backtrace | |
end |
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
int webruby_internal_compile(mrb_state* mrb, const char *file_name, const char *code, int print_level) | |
{ | |
mrb_value result; | |
int ret = -1; | |
int debuginfo = 0; | |
mrb_irep *irep; | |
mrbc_context *cxt; | |
cxt = mrbc_context_new(mrb); | |
cxt->no_exec = 1; |
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
Got POS emulator.js:923 | |
We already had jQuery ;) emulator.js:939 | |
Got emulator emulator.js:923 | |
Got sockfs emulator.js:923 | |
Got interpreter emulator.js:923 | |
Got webruby emulator.js:923 | |
SOCKFS.mount function VM1002:144 | |
SOCKFS.createSocket function VM1002:144 | |
SOCKFS.getSocket function VM1002:144 | |
SOCKFS.stream_ops object VM1002:144 |
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
IO.display 0, 0, "Start" | |
begin | |
#IO.getc | |
a = load("./show.mrb") | |
p "AAAAAAA" | |
rescue => @e | |
p @e.inspect | |
p @e.backtrace | |
end |