This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Calling keyed functions from Java (also decompiling Java)


Well, I answered my own question. I did a search for Java decompilers,
downloaded Jad from
http://www.geocities.com/SiliconValley/Bridge/8617/jad.html , and ran a
keyed function through it. Easier than reading the JVM code.

Here's the result. Clearly, the keywords are tested for during the
function call, and have to be inserted into the argument list. Which Jad
tells me below how to do when calling from Java!


// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   test.scm

package kb7.mm3.general;

import gnu.expr.*;
import gnu.lists.LList;
import gnu.mapping.*;
import gnu.math.IntNum;
import kawa.lib.ports;
import kawa.standard.Scheme;

public class test extends ModuleBody
{

    public test()
    {
    }

    public static LList makePair$V(Object argsArray[])
    {
        Object low = Keyword.searchForKeyword(argsArray, 0, Lit0, Boolean.FALSE);
        Object high = Keyword.searchForKeyword(argsArray, 0, Lit1, Boolean.FALSE);
        Scheme.writeFormat.apply1(low);
        ports.newline();
        Scheme.writeFormat.apply1(high);
        ports.newline();
        return LList.list2(low, high);
    }

    public Object applyN(ModuleMethod modulemethod, Object aobj[])
    {
        while(modulemethod.selector != 1) 
            return super.applyN(modulemethod, aobj);
        return makePair$V(aobj);
    }

    static final test $instance;
    public static final ModuleMethod makePair;
    public static final Binding l;
    static final Binding id$module;
    static final Binding id$$LsList$Gr;
    static final Keyword Lit0;
    static final Keyword Lit1;
    static final IntNum Lit2;
    static final IntNum Lit3;

    static 
    {
        Environment env$;
        $instance = new test();
        while(false) 
        {
            Lit3 = IntNum.make(2);
            Lit2 = IntNum.make(1);
            Lit1 = Keyword.make("high");
            Lit0 = Keyword.make("low");
            l = Environment.getCurrent().getBinding("l");
            makePair = new ModuleMethod($instance, 1, "make-pair", 16384);
        }
        env$ = Environment.getCurrent();
        id$$LsList$Gr = env$.getBinding("<list>");
        id$module = env$.getBinding("module");
        ((Procedure)id$module.getProcedure()).apply1("test");
        l.set(makePair$V(new Object[] {
            Lit0, Lit2, Lit1, Lit3
        }));
        Interpreter.voidObject;
    }
}

Jocelyn Paine
http://www.ifs.org.uk/~popx/
+44 (0)7768 534 091 




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]