;
; Output created by JasminView on 19-May-00
; mailto:shawn@pobox.com
; Copyright (c) 1997-Present Shawn Silverman
;
; Jasmin can be found at:
;     http://www.cat.nyu.edu/meyer/jasmin/
;

; Classfile version:
;     major: 45
;     minor: 3

.source Calc.java

.class  Calc
.super  java/lang/Object


; >> METHOD 1 <<
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    int add(int a, int b){
;;        return a+b;
;;    }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.method add(II)I
    .limit stack 2
    .limit locals 3
;---- [this, a, b]
.line 6
    iload_1
    iload_2
    iadd
    ireturn
.end method

; >> METHOD 2 <<
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
::    int sub(int a, int b){
::        int c=a-b;
::        return c;
::    }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.method sub(II)I
    .limit stack 2
    .limit locals 4
;---- [this, a, b, c]
.line 10
    iload_1
    iload_2
    isub
    istore_3
.line 11
    iload_3
    ireturn
.end method

; >> METHOD 3 <<
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    int lpower(int a, int b){
;;        int r=1;
;;        for(; b>0; b--) r *= a;
;;        return r;
;;    }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.method lpower(II)I
    .limit stack 2
    .limit locals 4
;---- [this, a, b, r]
.line 15
    iconst_1
    istore_3
.line 16
    goto Label2
Label1:
    iload_3
    iload_1
    imul
    istore_3
    iinc 2 -1
Label2:
    iload_2
    ifgt Label1
.line 17
    iload_3
    ireturn
.end method

; >> METHOD 4 <<
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    int rpower(int a, int b){
;;        if(b>0) return a * rpower(a, b-1);
;;        else    return 1;
;;    }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.method rpower(II)I
    .limit stack 5
    .limit locals 3
;---- [this, a, b]
.line 21
    iload_2
    ifle Label1
    iload_1
    aload_0
    iload_1
    iload_2
    iconst_1
    isub
    invokevirtual Calc/rpower(II)I
    imul
    ireturn
.line 22
Label1:
    iconst_1
    ireturn
.end method

; >> METHOD 5 <<
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    int rpower2(int a, int b){
;;        return b>0? a * rpower(a, b-1): 1;
;;    }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.method rpower2(II)I
    .limit stack 5
    .limit locals 3
;---- [this, a, b]
.line 26
    iload_2
    ifle Label1
    iload_1
    aload_0
    iload_1
    iload_2
    iconst_1
    isub
    invokevirtual Calc/rpower(II)I
    imul
    ireturn
Label1:
    iconst_1
    ireturn
.end method

; >> METHOD 6 <<
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    public static void main(String[] args){
;;        Calc c=new Calc();
;;
;;        int p=c.rpower(2, 4); // 2^4 = 16
;;        int q=c.lpower(2, 6); // 2^6 = 64
;;        int a=c.add(p, c.sub(100, q)); // 16+(100-64) = 52
;;
;;        System.out.println(a);
;;    }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.method public static main([Ljava/lang/String;)V
    .limit stack 5
    .limit locals 5
;---- [args, c, p, q, a]
.line 30
    new Calc
    dup
    invokespecial Calc/<init>()V
    astore_1
.line 32
    aload_1
    iconst_2
    iconst_4
    invokevirtual Calc/rpower(II)I
    istore_2
.line 33
    aload_1
    iconst_2
    bipush 6
    invokevirtual Calc/lpower(II)I
    istore_3
.line 34
    aload_1
    iload_2
    aload_1
    bipush 100
    iload_3
    invokevirtual Calc/sub(II)I
    invokevirtual Calc/add(II)I
    istore 4
.line 36
    getstatic java/lang/System/out Ljava/io/PrintStream;
    iload 4
    invokevirtual java/io/PrintStream/println(I)V
.line 29
    return
.end method

; >> METHOD 7 <<
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; このクラスではデフォルトのコンストラクタが使われます,曰く
;; Calc(){
;;   super();
;;}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.method <init>()V
    .limit stack 1
    .limit locals 1
;---- [this]
.line 3
    aload_0
    invokespecial java/lang/Object/<init>()V
    return
.end method

// $xId: Calc.java,v 1.2 2000-05-19 12:28:58+09 kaiya Exp kaiya $

class Calc{

    int add(int a, int b){
        return a+b;
    }

    int sub(int a, int b){
        int c=a-b;
        return c;
    }

    int lpower(int a, int b){
        int r=1;
        for(; b>0; b--) r *= a;
        return r;
    }

    int rpower(int a, int b){
        if(b>0) return a * rpower(a, b-1);
        else    return 1;
    }

    int rpower2(int a, int b){
        return b>0? a * rpower(a, b-1): 1;
    }

    public static void main(String[] args){
        Calc c=new Calc();

        int p=c.rpower(2, 4); // 2^4 = 16
        int q=c.lpower(2, 6); // 2^6 = 64
        int a=c.add(p, c.sub(100, q)); // 16+(100-64) = 52

        System.out.println(a);
    }
}

$Id: list.html,v 1.6 2000-05-19 13:29:15+09 kaiya Exp $