Package jminusminus

Examples of jminusminus.CLEmitter.addMethod()


        // Add message() method to HelloWorld
        accessFlags.clear();
        accessFlags.add("private");
        accessFlags.add("static");
        e.addMethod(accessFlags, "message", "()Ljava/lang/String;", null, true);
        e.addLDCInstruction("Hello, World!");
        e.addNoArgInstruction(ARETURN);

        // Add main() method to HelloWorld
        accessFlags.clear();
View Full Code Here


        // Add main() method to HelloWorld
        accessFlags.clear();
        accessFlags.add("public");
        accessFlags.add("static");
        e.addMethod(accessFlags, "main", "([Ljava/lang/String;)V", null, true);
        e.addMemberAccessInstruction(GETSTATIC, "java/lang/System", "out",
                "Ljava/io/PrintStream;");
        e.addMemberAccessInstruction(INVOKESTATIC, "HelloWorld", "message",
                "()Ljava/lang/String;");
        e.addMemberAccessInstruction(INVOKEVIRTUAL, "java/io/PrintStream",
View Full Code Here

        e.addClass(accessFlags, "IntFactorial", "java/lang/Object", null, true);

        // Add the implicit no-arg constructor IntFactorial()
        accessFlags.clear();
        accessFlags.add("public");
        e.addMethod(accessFlags, "<init>", "()V", null, true);
        e.addNoArgInstruction(ALOAD_0);
        e.addMemberAccessInstruction(INVOKESPECIAL, "java/lang/Object",
                "<init>", "()V");
        e.addNoArgInstruction(RETURN);
View Full Code Here

        e.addNoArgInstruction(RETURN);

        // Add factorial() method to IntFactorial
        accessFlags.clear();
        accessFlags.add("public");
        e.addMethod(accessFlags, "factorial", "(I)I", null, true);
        e.addNoArgInstruction(ILOAD_1);
        e.addNoArgInstruction(ICONST_1);
        e.addBranchInstruction(IF_ICMPGT, "Label1");
        e.addNoArgInstruction(ILOAD_1);
        e.addNoArgInstruction(IRETURN);
View Full Code Here

        // Add main() method to IntFactorial
        accessFlags.clear();
        accessFlags.add("public");
        accessFlags.add("static");
        e.addMethod(accessFlags, "main", "([Ljava/lang/String;)V", null, true);
        e.addReferenceInstruction(NEW, "IntFactorial");
        e.addNoArgInstruction(DUP);
        e.addMemberAccessInstruction(INVOKESPECIAL, "IntFactorial", "<init>",
                "()V");
        e.addNoArgInstruction(ASTORE_1);
View Full Code Here

        // Add the implicit no-arg constructor Factorial() to
        // Factorial
        accessFlags.clear();
        accessFlags.add("public");
        e.addMethod(accessFlags, "<init>", "()V", null, true);
        e.addNoArgInstruction(ALOAD_0);
        e.addMemberAccessInstruction(INVOKESPECIAL, "java/lang/Object",
                "<init>", "()V");
        e.addNoArgInstruction(RETURN);
View Full Code Here

        e.addNoArgInstruction(RETURN);

        // Add compute() method to Factorial
        accessFlags.clear();
        accessFlags.add("public");
        e.addMethod(accessFlags, "compute", "(I)I", null, true);
        e.addNoArgInstruction(ILOAD_1);
        e.addNoArgInstruction(ICONST_1);
        e.addBranchInstruction(IF_ICMPGT, "falseLabel");
        e.addNoArgInstruction(ILOAD_1);
        e.addNoArgInstruction(IRETURN);
View Full Code Here

        // Add main() method to Factorial
        accessFlags.clear();
        accessFlags.add("public");
        accessFlags.add("static");
        e.addMethod(accessFlags, "main", "([Ljava/lang/String;)V", null, true);
        e.addExceptionHandler("tryStart", "tryEnd", "catch",
                "java/lang/NumberFormatException");
        e.addLabel("tryStart");
        e.addReferenceInstruction(NEW, "Factorial");
        e.addNoArgInstruction(DUP);
View Full Code Here

                        null, true);

        // Add the implicit no-arg constructor LongFactorial()
        accessFlags.clear();
        accessFlags.add("public");
        e.addMethod(accessFlags, "<init>", "()V", null, true);
        e.addNoArgInstruction(ALOAD_0);
        e.addMemberAccessInstruction(INVOKESPECIAL, "java/lang/Object",
                "<init>", "()V");
        e.addNoArgInstruction(RETURN);
View Full Code Here

        e.addNoArgInstruction(RETURN);

        // Add factorial() method to LongFactorial
        accessFlags.clear();
        accessFlags.add("public");
        e.addMethod(accessFlags, "factorial", "(J)J", null, true);
        e.addNoArgInstruction(LLOAD_1);
        e.addNoArgInstruction(LCONST_1);
        e.addNoArgInstruction(LCMP);
        e.addBranchInstruction(IFGT, "falseLabel");
        e.addNoArgInstruction(LLOAD_1);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.