Strings and jasmin.jar

56 views
Skip to first unread message

Martin

unread,
Apr 4, 2011, 8:30:51 AM4/4/11
to Compiler construction 2011
Hi, I have two questions:

First, I cannot manage to print Strings in a .j file. When I have the
needed instructions
lcd "hello_world"
invokestatic Runtime/printString(Ljava/lang/
String;)V
in the file, the jasmin program complains about "Missing arguments for
instruction invokestatic."

And the second question is about using the jasmin.jar file in myjava
program. I have it in my path, and can easily use it in the terminal
to compile and run my .j files. In java I can access the jasmin
package and run the static main functions with the arguments given in
the project description, but then I get the following runtime error:
java.lang.NoSuchMethodError: jasmin.parser.parse()V. How do I have to
run the jar jasmin package? Also I don't understand what you mean in
the project description, when you say, that we need to manipulate the
file path.

Thank you

Martin

Björn von Sydow

unread,
Apr 4, 2011, 9:26:18 AM4/4/11
to compiler-cons...@googlegroups.com
Hi,

For the first question, I think that you just misspell the instruction; it should be "ldc", not "lcd".

The second is more difficult to understand. Are you trying to call methods in jasmin.jar from your Java code? A preferrable method is to execute the jasmin command from your compiler. This could be using method exec in java.lang.Runtime , or it could be in a shell script. In the latter case your compiler proper produces Jasmin code and your script calls first the compiler, then Jasmin. In both cases, you invoke jasmin kust as you would do in the terminal.

The manipulation of the file path is just the fact that if you compile foo/bar/myfile.jl, your compiler must produce Jasmin file foo/bar/myfile.j, which must be assembled by Jasmin to foo/bar/myfile.class. For the latter, you must give Jasmin the command line argument -d foo/bar . Without this, the class file will be placed in the current directory.

Best regards

Björn

Martin

unread,
Apr 4, 2011, 9:57:03 AM4/4/11
to Compiler construction 2011


On 4 Apr., 15:26, Björn von Sydow <bjorn.von.sy...@gmail.com> wrote:
> Hi,
>
> For the first question, I think that you just misspell the instruction; it should be "ldc", not "lcd".

Yes, sorry, I fixed this problem in a prevous version, but messed it
up again. But now I still get an error about incompatible argument
types. But the printString method in my Runtime expects an
java.lang.String, which should be right. And all the other print
functions work.

> The second is more difficult to understand. Are you trying to call methods in jasmin.jar from your Java code? A preferrable method is to execute the jasmin command from your compiler. This could be using method exec in java.lang.Runtime , or it could be  in a shell script. In the latter case your compiler proper produces Jasmin code and your script calls first the compiler, then Jasmin. In both cases, you invoke jasmin kust as you would do in the terminal.

Ok, thank you. I think I will use the script method.


/Martin
Reply all
Reply to author
Forward
0 new messages