블로그 이미지

카테고리

데꾸벅 (194)
Publisher (39)
Scripter (97)
Programmer (1)
Designer (30)
Integrator (18)
Pattern Searcher (4)
News (2)
강좌 및 번역 (3)

최근에 올라온 글

최근에 달린 댓글

'Ruby on Javascript'에 해당되는 글 1건

  1. 2008.03.28 자바스크립트로 루비프로그래밍을? 2
스크립트로 루비프로그래밍을 만든다?? 기발한 생각보다는 별놈이 다 있다는 생각이..

원본사이트 : 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








Post by 넥스트리소프트 데꾸벅(techbug)
, |