[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] JVMScript

Charles Oliver Nutter

9/6/2008 11:36:00 AM

In honor of the new project-hosting site kenai.com, I've spun off a
library I've been working on as part of JRuby. I'm hoping to find
interested parties to help improve it and test it (I have tests, but
testing a library like this is a little tricky).

http://kenai.com/projects...

JVMScript is, basically, a Ruby DSL for emitting JVM bytecode. It's
based on the ASM bytecode-gen library, but the bottom line is that it
looks and feels like a limited structured assembly language for the JVM.
You have the entire power of Ruby available to you, and calling an
opcode is essentially the same as emitting that bytecode. Here's a snippit:

builder = Compiler::FileBuilder.build("somefile.source") do
public_class "MyClass", object do
public_field "list", ArrayList

public_constructor string, ArrayList do
aload 0
invokespecial object, "<init>", [void]
aload 0
aload 1
aload 2
invokevirtual this, "bar", [ArrayList, string, ArrayList]
aload 0
swap
putfield this, "list", ArrayList
returnvoid
end

public_static_method "foo", this, string do
new this
dup
aload 0
new ArrayList
dup
invokespecial ArrayList, "<init>", [void]
invokespecial this, "<init>", [void, string, ArrayList]
areturn
end

public_method "bar", ArrayList, string, ArrayList do
aload 1
invokevirtual(string, "toLowerCase", string)
aload 2
swap
invokevirtual(ArrayList, "add", [boolean, object])
aload 2
areturn
end

public_method("getList", ArrayList) do
aload 0
getfield this, "list", ArrayList
areturn
end

public_static_method("main", void, string[]) do
aload 0
ldc_int 0
aaload
invokestatic this, "foo", [this, string]
invokevirtual this, "getList", ArrayList
aprintln
returnvoid
end
end
end
# then call builder.generate to dump the bytecode

The general syntax is still up for debate (it would be nice to eliminate
those underscores) but the library itself is already being used in my
pet language project Duby.

Interested parties, contributions, patches, and bug reports are welcome.
Check test/test_builder.rb for examples. I'm hoping to release this as a
Ruby gem soon.

Have fun...feel free to join the lists and let me know what you think.

- Charlie

1 Answer

william mosco

10/31/2011 9:21:00 AM

0

On Oct 31, 1:07 am, Yoorg...@Jurgis.net wrote:
> On Sun, 30 Oct 2011 15:03:57 -0700 (PDT), william mosco
>
> <wm5...@gmail.com> wrote:
> >> How does a black "present a competitive resume" when the system he's
> >> forced to go through is manipulated by the same class of people that
> >> don't want blacks to suceed?
>
> >easy.  the guy i hired had 23 years experience driving a tractor
> >trailer and he had a spotless ontime record and driving record.  i pay
> >him top dollar.  any other questions, stupid?
>
> You're still trying to "argue by anecdote" you fool
>
> It's not evidence of anything.

your premise above is a lie.