How to jump forward in BiteScript

I was wondering how I can port the following code to BiteScript since
the label statement has to appear before I can use it in BiteScript:

28: if_icmpge 44
31: getstatic #8; //Field
java/lang/System.out:Ljava/io/PrintStream;
34: aload_2
35: invokevirtual #9; //Method
java/io/PrintStream.println:(Ljava/lang/String;)V
38: iinc 3, 1
41: goto 25
44: return

The following gives an error in BiteScript:

  ldc "Hello World"
  astore 1
  new java.lang.StringBuilder
  dup
  goto :top
  invokespecial java.lang.StringBuilder, "<init>", [void]
  aload 1
  invokevirtual java.lang.StringBuilder, "append", 

[java.lang.StringBuilder, string]
ldc " again"
invokevirtual java.lang.StringBuilder, “append”,
[java.lang.StringBuilder, string]
invokevirtual java.lang.StringBuilder, “toString”, [string]
astore 2
push_int 9
istore 3
label :top
getstatic System, “out”, java.io.PrintStream

=> /jruby/1.8/gems/bitescript-0.0.5/lib/bitescript/bytecode.rb:361:in
`sym_to_label’: Unknown label ‘finish’ (RuntimeError)

Regards
Roger


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Tue, Apr 6, 2010 at 12:46 PM, Roger G. [email protected] wrote:

 I was wondering how I can port the following code to BiteScript since the label statement has to appear before I can use it in BiteScript:

   ldc " again"
   invokevirtual java.lang.StringBuilder, “append”, [java.lang.StringBuilder, string]
   invokevirtual java.lang.StringBuilder, “toString”, [string]
   astore 2
   push_int 9
   istore 3
   label :top
   getstatic System, “out”, java.io.PrintStream

=> Â /jruby/1.8/gems/bitescript-0.0.5/lib/bitescript/bytecode.rb:361:in `sym_to_label’: Unknown label ‘finish’ (RuntimeError)

This looks like something we could add to bitescript (and I’m
surprised I hadn’t done it already). If a label is referenced before
being defined by “label”, define it anyway, and then use that label
for the eventual “label” call later.

I’ve added it and tests in 99e7ec0. If you’re comfortable running from
master, it’s there, and maybe there’s other things we could finish up
to push a 0.0.6 release out.

If you don’t want to use master, the traditional way would be to
pre-allocate the label:

lbl = label
goto lbl

lbl.set!

The change I committed makes this almost totally unnecessary, I suppose.

goto :some_label

label :some_label

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs