NOTICE 
올바른 성장과 따뜻한 나눔이 있는 넥스트리
스크립트로 루비프로그래밍을 만든다?? 기발한 생각보다는 별놈이 다 있다는 생각이..

원본사이트 : HotRuby

아래그림은 루비로 실행된 FlashAS3 이다.

사용자 삽입 이미지

아래 파일을 다운로드 받아 다음과 같이 사용한다.



<html>
<head>
    <title>Block - HotRuby - Ruby on JavaScript</title>
    <link href="../css/prettify.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="../js/prettify.js"></script>
    <script type="text/javascript" src="../js/ext-base.js"></script>
    <script type="text/javascript" src="../js/HotRuby.js"></script>
   
    <script type="text/ruby">
class Hoge
    def add_msg &block
        block.yield "is"
    end
end
   
class Foo
    NAME = ' - William Shakespeare'
    def main
        pre = "Action"
        @space = " "
        Hoge.new.add_msg do |msg|
            fuga = "eloquence"
            puts pre + @space + msg + @space + fuga + NAME
        end
    end
end
   
Foo.new.main
    </script>
</head>
<body onload="prettyPrint(); new HotRuby().runFromScriptTag('/compileRuby.cgi')">
    <h1>Block - HotRuby(Ruby on JavaScript)</h1>
    <div>Result:</div>
    <div id="debug" class="result"></div>
    <br />




[compileRuby.cgi 내용]
require 'json'
require 'cgi'

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

cgi = CGI.new

puts "Content-type: text/plain\n\n"
puts VM::InstructionSequence.compile(cgi['src'], "src", 1, OutputCompileOption).to_a.to_json








크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback :: http://techbug.tistory.com/trackback/77
신기하네요 ㅎㅎ 벤치마크 페이지를 보니 루비 1.9 인터프리터보다도 빠르다고 합니다.
루비 언어를 좋아하는 사람으로서 이러한 바인딩을 알게 될 때 마다 기분이 좋네요 ㅎㅎㅎ
2008/04/01 17:05
ㅎㅎ 또다른 정보네요~ 제가 더 도움을 받아야 할듯한데요..

2008/04/01 17:18

 이전  1 ... 404142434445464748 ... 118   다음 

최근댓글
fotowall :: ncloud RSS Feeds today : 20   yesterday : 221
total : 25,049