Category: Entertainment

Presentation Description

No description available.


Presentation Transcript


Ruby.NET Dr Wayne Kelly Queensland University of Technology

Ruby Implementations: 

Ruby Implementations Matz’s Ruby Interpreter (MRI) Yet Another Ruby VM (YARV) JRuby RubyCLR Ruby.NET IronRuby

Ruby.exe and RubyCompiler.exe: 

Ruby.exe and RubyCompiler.exe Ruby Source files Ruby Source files Ruby Source files RubyCompiler.exe Native Code Execution JIT Ruby Source file Ruby.exe .NET exe Native Code Execution JIT memory stream .NET exe or dll .NET exe or dll


Architecture RubyRuntime.dll (Compiler Infrastructure + built-in classes and modules) Visual Studio Ruby.NET Package msbuild Task RubyCompiler.exe Ruby.exe PERWAPI.dll SymbolWriter.dll

Implementation Issues: 

Implementation Issues Lack of Formal Specification Scanning and Parsing

Interpreting vs. Compiling : 

Interpreting vs. Compiling Traditionally: Determine what to do Perform the action Compiling faster at runtime than Interpreting Ruby: Requires compilation at Runtime Highly dynamic semantics Consider expression: x + 2

Mapping Ruby to the CIL: 

Mapping Ruby to the CIL Ruby has objects, classes and methods CIL has objects, classes and methods ?

Dynamic Ruby Semantics: 

Dynamic Ruby Semantics Firstly the good news: All Ruby objects belong to a class and that class cannot change. The super class of a Ruby class cannot be changed. The bad news: The set of instance variables and methods of a class can change at runtime. Variables and expressions are not typed. Therefore don’t know type of receiver in method calls Therefore don't know which method is being called Unfortunately everything in Ruby is done via method calls!

Ruby.Class vs System.Type: 

Ruby.Class vs System.Type Can't even create CLI classes at Runtime So, in general, Ruby class != CLI class Ruby.Class object: Points to super class object Maps method names to methods Ruby Object [instance variables] Ruby Class [class instance variables] Parent Class method method method method method method

Invoking Ruby Methods: 

Invoking Ruby Methods object Eval.Call(object recv, string method_name, object[] args …) Determine the Ruby class of the receiver Determine the Ruby method currently bound to the specified method name for that Ruby class Invoke the found Ruby method

Ruby Objects: 

Ruby Objects "Most" Ruby objects inherit from CLI class Ruby.Object But we don't rely on this:

Instance Variables: 

Instance Variables Normally fields of a specific class Since the set of instance variables is dynamic, we use a dictionary to store instance variables Don’t need objects of specific class Can use Ruby.Object in most cases Some classes such as Ruby.String are special For interop – want to create specific classes where possible. How do we allocate instances of a class? Don’t statically know super class

Local variables and blocks: 

Local variables and blocks Set of local variables is known statically But, they may be “captured” therefore generally can’t use CLI locals. def foo(a) b = a + 4 bar {|x| return a * x + b} end

Dynamic Evaluation: 

Dynamic Evaluation eval invokes compiler at runtime Generates a CLI assembly to a memory stream Dynamically loads it and invokes a method using reflection. eval may be evaluated in a different runtime context encapsulated by Binding object

Dynamic locals: 

Dynamic locals

Non-local control flow: 

Non-local control flow Blocks as loop bodies:



ObjectSpace and Weak References: 

ObjectSpace and Weak References

Current Status and Future Plans: 

Current Status and Future Plans


TODO Extending Ruby/.NET interop Performance Optimization Threads and Continuations? Ruby on Rails Bug fixing


Links ACSC08 Ruby.NET Design Paper: Public source repository: Discussion email list: Dr Wayne Kelly, QUT 3138 9336

authorStream Live Help