?

Log in

No account? Create an account
Roy Janik [entries|archive|friends|userinfo]
Roy Janik

[ website | Parallelogramophonograph ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

something is wrong with my brain [Nov. 30th, 2002|04:45 pm]
Roy Janik
I'm spending the weekend coding in what amount to Assembly for Java.

It rules.


.class public streams/filein
.super java/lang/Object

.field private currVal I = -99
.field private br Ljava/io/BufferedReader;
.field private name Ljava/lang/String;
;
; standard initializer
.method public ()V
.limit stack 2
aload_0
invokenonvirtual java/lang/Object/()V
aload_0
invokenonvirtual streams/filein/setupFile()V
aload_0
ldc "filein"
putfield streams/filein/name Ljava/lang/String;
return
.end method

.method public getName()Ljava/lang/String;
.limit stack 2
aload_0
getfield streams/filein/name Ljava/lang/String;
areturn
.end method


.method private setupFile()V
.limit stack 3
.limit locals 2
.catch java/lang/Exception from TRY to ENDTRY using HANDLER
TRY:
new java/io/FileReader
dup
ldc "teldata.txt"
invokenonvirtual java/io/FileReader/(Ljava/lang/String;)V
astore_1
new java/io/BufferedReader
dup
aload_1
invokenonvirtual java/io/BufferedReader/(Ljava/io/Reader;)V
aload_0
swap
putfield streams/filein/br Ljava/io/BufferedReader;
return
ENDTRY:
HANDLER:
pop
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Exception caught!"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
return
.end method

.method public getLastVal()I
.limit stack 3
.limit locals 2
.catch java/lang/Exception from TRYLAST to ENDTRYLAST using HANDLERLAST
TRYLAST:
aload_0
getfield streams/filein/br Ljava/io/BufferedReader;
invokevirtual java/io/BufferedReader/readLine()Ljava/lang/String;
dup
ifnull ENDTRYLAST
invokestatic java/lang/Integer/parseInt(Ljava/lang/String;)I
aload_0
swap
putfield streams/filein/currVal I
goto TRYLAST
ENDTRYLAST:
aload_0
getfield streams/filein/currVal I
ireturn
HANDLERLAST:
pop
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Exception caught!"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
bipush -99
ireturn
.end method
LinkReply