Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .project

This file was deleted.

6 changes: 6 additions & 0 deletions Gemfile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
source :rubygems

gem 'json'
gem 'rack'
gem 'rake'
gem 'rspec', '~>2'
24 changes: 24 additions & 0 deletions Gemfile.lock
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
GEM
remote: http://rubygems.org/
specs:
diff-lcs (1.1.2)
json (1.5.3)
rack (1.3.2)
rake (0.9.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)

PLATFORMS
ruby

DEPENDENCIES
json
rack
rake
rspec (~> 2)
16 changes: 0 additions & 16 deletions README

This file was deleted.

6 changes: 6 additions & 0 deletions Rakefile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
task :build do
File.open(File.join('web','js','HotRuby.js'),'w') do |f|
f.write File.read(File.join('src','RubyVM.js')) +
File.read(File.join('src','RubyNative.js'))
end
end
19 changes: 19 additions & 0 deletions Readme.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
# HotRuby

HotRuby is a Ruby VM build with JavaScript and Flash, that runs opcode compiled by Ruby 1.9+

Most of the grammars are implemented. However, exceptions are not implemented. Most of the build-in functions and build-in classes are not implemented.

# Running it

rake build
cd web
rackup

# Github?

It was developed by yukoba ? [official website](http://hotruby.accelart.jp)

[original repository](http://code.google.com/p/hotruby) seems to be abandoned.

Github to the rescue!
2 changes: 0 additions & 2 deletions build.bat

This file was deleted.

3 changes: 2 additions & 1 deletion src/RubyVM.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,6 +122,7 @@ HotRuby.prototype = {
this.runOpcode(opcode, this.classes.Object, null, this.topObject, [], null, false, null);
} catch(e) {
alert(e);
if(console) console.log(e) // more details than alert
}
},

Expand DownExpand Up@@ -184,7 +185,7 @@ HotRuby.prototype = {
*/
mainLoop : function(opcode, sf) {
// Create label to ip
if(!("label2ip" in opcode)) {
if(typeof(opcode.label2ip) != 'undefined') { // label2ip in opcode would throw exception
opcode.label2ip = {};
for (var ip = 0;ip < opcode.length; ip++) {
// If "cmd is a String then it is a jump label
Expand Down
20 changes: 0 additions & 20 deletions web/compileRuby.cgi

This file was deleted.

20 changes: 0 additions & 20 deletions web/compileRuby_cgi

This file was deleted.

25 changes: 25 additions & 0 deletions web/config.ru
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
require 'json'

COMPILE_OPTIONS = {
:peephole_optimization =>true,
:inline_const_cache =>false,
:specialized_instruction =>false,
:operands_unification =>false,
:instructions_unification =>false,
:stack_caching =>false,
}

def compile(source)
RubyVM::InstructionSequence.compile(source, "src", "", 1, COMPILE_OPTIONS).to_a.to_json
end

run lambda{|env|
if env['REQUEST_PATH'] == '/compileRuby.cgi' # TODO legacy url, gsub all js files to change it
source = Rack::Request.new(env).params['src']
[200, {'Content-Type'=>'text/plain'}, [compile(source)]]
elsif env['REQUEST_PATH'] == '/'
[200, {'Content-Type' => 'text/html'}, [File.read('index.html')]]
else
Rack::File.new('.').call(env)
end
}