...
bipush 10
iload_2
isub
invokestatic java/lang/String/valueOf(I)Ljava/lang/String;
astore_3
; ... and print it
aload_1 ; push the PrintStream object
aload_3 ; push the string we just created - then ...
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
; decrement the counter and loop
iinc 2 -1
iload_2
ifne Loop
; done
return
.end method
examples/HelloWeb.html 100644 0 0 145 10070636274 12377 0 ustar 0 0
This shows how to run HelloApplet:
examples/HelloWeb.j 100644 0 0 4130 10070636274 11702 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/HelloWeb.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Demonstration of a Jasmin-created applet
; -------------------------------------------------------------------------
; HelloWeb.j
; This demonstrates how you can use Jasmin to create an applet.
; The code below is like the Java code:
;
; import java.applet.*;
; import java.awt.*;
;
; public class HelloWeb extends Applet {
; private Font font;
;
; public void init() {
; font = new Font("Helvetica", Font.BOLD, 48);
; }
;
; public void paint(Graphics g) {
; g.setFont(font);
; g.drawString("Hello World!", 25, 50);
; }
; }
.class public HelloWeb
.super java/applet/Applet
.field private font Ljava/awt/Font;
; my init() method - allocate a font and assign it to this.font.
.method public init()V
.limit stack 5
; Create a new Font and call its constructor with
; "Helvetica", 1 (i.e. Font.BOLD), and 48.
new java/awt/Font
dup
ldc "Helvetica"
iconst_1
bipush 48
invokenonvirtual java/awt/Font/(Ljava/lang/String;II)V
; now store the Font on the stack in this.font
aload_0
swap
putfield HelloWeb/font Ljava/awt/Font;
; done
return
.end method
; my paint() method - draws the string "Hello World!" using this.font.
.method public paint(Ljava/awt/Graphics;)V
.limit stack 4
.limit locals 2
; local variable 0 holds
; local variable 1 holds the java.awt.Graphics instance ('g').
; g.setFont(this.font);
aload_1
aload_0
getfield HelloWeb/font Ljava/awt/Font;
invokevirtual java/awt/Graphics/setFont(Ljava/awt/Font;)V
; g.drawString("Hello Web!", 25, 50);
aload_1
ldc "Hello Web!"
bipush 25
bipush 50
invokevirtual java/awt/Graphics/drawString(Ljava/lang/String;II)V
; done
return
.end method
; standard constructor
.method public ()V
aload_0
invokenonvirtual java/applet/Applet/()V
return
.end method
examples/HelloWorld.j 100644 0 0 1476 10070636274 12266 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/HelloWorld.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Prints out "Hello World!"
; -------------------------------------------------------------------------
.class public examples/HelloWorld
.super java/lang/Object
;
; standard initializer
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 2
; push System.out onto the stack
getstatic java/lang/System/out Ljava/io/PrintStream;
; push a string onto the stack
ldc "Hello World!"
; call the PrintStream.println() method.
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
; done
return
.end method
examples/Implementor.j 100644 0 0 2330 10070636274 12474 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/HelloWorld.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Shows how to define a class that implements an interface
; -------------------------------------------------------------------------
;
; This class implements the examples.AnInterface interface - see
; AnInterface.j
;
.class public examples/Implementor
.super java/lang/Object
.implements examples/AnInterface
;
; standard initializer
;
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
;
; implement the foo()V method - this is an interface method
;
.method public foo()V
.limit stack 2
; print a simple message
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Hello Interface"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
; done
return
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 2
; create a new one of me
new examples/Implementor
dup
invokenonvirtual examples/Implementor/()V
; now call my interface method foo()
invokeinterface examples/AnInterface/foo()V 1
return
.end method
examples/InvokeInterface.j 100644 0 0 2164 10070636274 13262 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/InvokeInterface.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Example of using invokeinterface
; -------------------------------------------------------------------------
;
; Demonstrates invoking an interface method
;
.class public examples/InvokeInterface
.super java/lang/Object
; standard initializer
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
;
; This is a rather silly example - since the result of calling the
; interface method isn't actually used. But it does illustrate how to
; use invokeinterface.
;
.method public example(Ljava/util/Enumeration;)V
.limit stack 1
.limit locals 3
; push local variable 1 (the Enumeration object)
aload_1
; now call the hasMoreElements() interface method.
invokeinterface java/util/Enumeration/hasMoreElements()Z 1
; store the integer result in local variable 2
istore_2
; done
return
.end method
.method public static main([Ljava/lang/String;)V
return
.end method
examples/MultiANewArray.j 100644 0 0 1505 10070636274 13050 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/MultiANewArray.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Example of multanewarray instruction
; -------------------------------------------------------------------------
;
; This illustrates how to use multianewarray to allocate
; an array.
;
.class public examples/MultiANewArray
.super java/lang/Object
; standard initializer
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 4
.limit stack 2
;
; This allocates an array like:
;
; String s[][] = new String[2][5];
;
iconst_2
iconst_5
multianewarray [[Ljava/lang/String; 2
astore_1
return
.end method
examples/MultiArrays.j 100644 0 0 2347 10070636274 12465 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/MultiArrays.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Examples involving multi-dimensional arrays
; -------------------------------------------------------------------------
;
; This illustrates how to use multi-dimensional arrays in the Java VM
; (though it doesn't actually do anything very interesting with the arrays.)
;
.class public examples/MultiArrays
.super java/lang/Object
; standard initializer
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit locals 4
.limit stack 5
; this is like:
; new int[2][5][]
iconst_2
iconst_5
multianewarray [[[I 2
; store the result in local variable 1
astore_1
aload_1
iconst_1
aaload ; stack now contains x[0]
astore_2 ; store the array in local variable 2
; create a new array of 50 ints and store it in x[1][1]
aload_2
iconst_1
bipush 50
newarray int
aastore
; create a new array of 60 ints and store it in x[1][2]
aload_2
iconst_2
bipush 60
newarray int
aastore
return
.end method
examples/NewArray.j 100644 0 0 1467 10070636274 11743 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/NewArray.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Example of newarray
; -------------------------------------------------------------------------
;
; Example showing how to allocate an array using
; newarray.
;
.class public examples/NewArray
.super java/lang/Object
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 4
.limit locals 2
; create an array like:
;
; boolean b[] = new boolean[2]
;
; (stores it in local var 1)
iconst_2
newarray boolean
astore_1
; b[0] = true;
aload_1
iconst_0
iconst_1
bastore
return
.end method
examples/Switch.j 100644 0 0 1377 10070636274 11454 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/Switch.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Shows usage of lookupswitch and tableswitch
; -------------------------------------------------------------------------
;
; Illustrates lookupswitch and tableswitch syntax for Jasmin
;
.class public examples/Switch
.super java/lang/Object
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 3
iconst_1
lookupswitch
1 : Hello
2 : Goodbye
default : Foo
iconst_1
tableswitch 0
Hello
Goodbye
default : Foo
Hello:
Goodbye:
Foo:
return
.end method
examples/Uncaught.j 100644 0 0 1712 10070636274 11762 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/Uncaught.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Throws an exception - doesn't catch it
; -------------------------------------------------------------------------
;
; This example class contains a main() method that throws
; an exception but doesn't catch it -
;
.source Uncaught.j
.class public examples/Uncaught
.super java/lang/Object
; specify the initializer method (as for HelloWorld)
.method public ()V
; just call Object's initializer
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
; specify the "main" method - this throws an uncaught exception
.method public static main([Ljava/lang/String;)V
.limit stack 2
new java/lang/Exception
dup
invokenonvirtual java/lang/Exception/()V
athrow
; without this the verifier might complain ...
return
.end method
examples/VerifyTest.j 100644 0 0 2216 10070636274 12310 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/VerifyTest.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Treats an int as an object - should alert the Verifier
; -------------------------------------------------------------------------
;
; This code demonstrates the verifier at work. See also VerifyTest1.j.
;
; The main() method below tries to clone the integer 100 - this
; is clearly an error since clone() expects an Object, not an integer.
;
; If you run this with no verification on, it is likely to crash the
; interpreter. Running this with the -verify option produces a
; Verifier error.
;
; This is similar to the Java code:
;
; class VerifyTest {
; public static void main(String args[]) {
; int x = 100;
; x.clone();
; }
; }
.class public examples/VerifyTest
.super java/lang/Object
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
.method public static main([Ljava/lang/String;)V
bipush 100
invokevirtual java/lang/Object/clone()Ljava/lang/Object;
return
.end method
examples/VerifyTest1.j 100644 0 0 3626 10070636274 12377 0 ustar 0 0 ; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/VerifyTest1.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Trys to pull one on the verifier
; -------------------------------------------------------------------------
; This file illustrates the bytecode verifier at work - the
; code in the example() method below seems reasonable, but
; Java's bytecode verifier will fail the code because the two points leading
; to the Loop label (from the top of the method and from the ifne
; statement) have different stack states. Instead, a different approach
; must be adopted - e.g. by allocating an array, or simply writing:
;
; aconst_null
; aconst_null
; aconst_null
; aconst_null
; Note that many interpreters will run this code OK if you don't use
; a verifier. The code itself is well behaved (it doesn't trash the
; interpreter), but the approach it uses is disallowed by the verifier.
;
; Compile the example, then run it using:
;
; % java -verify VerifyTest1
; VERIFIER ERROR VerifyTest1.example()V:
; Inconsistent stack height 1 != 0
;
.class public examples/VerifyTest1
.super java/lang/Object
.method public ()V
aload_0
invokenonvirtual java/lang/Object/()V
return
.end method
.method public example()V
.limit locals 2
.limit stack 10
; this tries to push four nulls onto the stack
; using a loop - Java's verifier will fail this program
iconst_4 ; store 4 in local variable 1 (used as a counter)
istore_1
Loop:
aconst_null ; push null onto the stack
iinc 1 -1 ; decrement local variable 4 (the counter variable)
iload_1
ifne Loop ; jump back to Loop unless the variable has reached 0
return
.end method
.method public static main([Ljava/lang/String;)V
; - do nothing : this is only to illustrate the bytecode verifier at work.
return
.end method
generated/scm/AutoInit.java 100644 0 0 5146 10154114357 13333 0 ustar 0 0 package scm;
import jas.*;
class AutoInit
{
static void fillit(Env e)
{
e.definevar(Symbol.intern("make-ascii-cpe"), new scmAsciiCP());
e.definevar(Symbol.intern("make-class-cpe"), new scmClassCP());
e.definevar(Symbol.intern("make-name-type-cpe"), new scmNameTypeCP());
e.definevar(Symbol.intern("make-field-cpe"), new scmFieldCP());
e.definevar(Symbol.intern("make-interface-cpe"), new scmInterfaceCP());
e.definevar(Symbol.intern("make-method-cpe"), new scmMethodCP());
e.definevar(Symbol.intern("make-integer-cpe"), new scmIntegerCP());
e.definevar(Symbol.intern("make-float-cpe"), new scmFloatCP());
e.definevar(Symbol.intern("make-long-cpe"), new scmLongCP());
e.definevar(Symbol.intern("make-double-cpe"), new scmDoubleCP());
e.definevar(Symbol.intern("make-string-cpe"), new scmStringCP());
e.definevar(Symbol.intern("make-field"), new scmVar());
e.definevar(Symbol.intern("make-const"), new scmConstAttr());
e.definevar(Symbol.intern("make-outputstream"), new scmscmOutputStream());
e.definevar(Symbol.intern("make-label"), new scmLabel());
e.definevar(Symbol.intern("make-class-env"), new scmClassEnv());
e.definevar(Symbol.intern("make-code"), new scmCodeAttr());
e.definevar(Symbol.intern("make-exception"), new scmExceptAttr());
e.definevar(Symbol.intern("make-catchtable"), new scmCatchtable());
e.definevar(Symbol.intern("make-catch-entry"), new scmCatchEntry());
e.definevar(Symbol.intern("iinc"), new scmIincInsn());
e.definevar(Symbol.intern("multianewarray"), new scmMultiarrayInsn());
e.definevar(Symbol.intern("invokeinterface"), new scmInvokeinterfaceInsn());
e.definevar(Symbol.intern("jas-class-addcpe"), new scmaddCPItem());
e.definevar(Symbol.intern("jas-class-addfield"), new scmaddField());
e.definevar(Symbol.intern("jas-class-addinterface"), new scmaddInterface());
e.definevar(Symbol.intern("jas-class-setclass"), new scmsetClass());
e.definevar(Symbol.intern("jas-class-setsuperclass"), new scmsetSuperClass());
e.definevar(Symbol.intern("jas-class-addmethod"), new scmaddMethod());
e.definevar(Symbol.intern("jas-class-setaccess"), new scmsetClassAccess());
e.definevar(Symbol.intern("jas-class-setsource"), new scmsetSource());
e.definevar(Symbol.intern("jas-class-write"), new scmwrite());
e.definevar(Symbol.intern("jas-exception-add"), new scmaddException());
e.definevar(Symbol.intern("jas-code-addinsn"), new scmaddInsn());
e.definevar(Symbol.intern("jas-code-stack-size"), new scmsetStackSize());
e.definevar(Symbol.intern("jas-code-var-size"), new scmsetVarSize());
e.definevar(Symbol.intern("jas-set-catchtable"), new scmsetCatchtable());
e.definevar(Symbol.intern("jas-add-catch-entry"), new scmaddEntry());
}
}
generated/scm/AutoProcs.java 100644 0 0 47565 10277203160 13546 0 ustar 0 0 package scm;
import jas.*;
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmaddCPItem extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-class-addcpe expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-addcpe expects a ClassEnv for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ClassEnv)) { throw new SchemeError("jas-class-addcpe expects a ClassEnv for arg #1"); }
ClassEnv arg0 = (tmp != null)?(ClassEnv)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-class-addcpe expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-addcpe expects a CP for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("jas-class-addcpe expects a CP for arg #2"); }
CP arg1 = (tmp != null)?(CP)(((primnode)tmp).val):null;
arg0.addCPItem(arg1);
return null;
}
public String toString()
{ return ("<#jas-class-addcpe#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmaddField extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-class-addfield expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-addfield expects a ClassEnv for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ClassEnv)) { throw new SchemeError("jas-class-addfield expects a ClassEnv for arg #1"); }
ClassEnv arg0 = (tmp != null)?(ClassEnv)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-class-addfield expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-addfield expects a Var for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof Var)) { throw new SchemeError("jas-class-addfield expects a Var for arg #2"); }
Var arg1 = (tmp != null)?(Var)(((primnode)tmp).val):null;
arg0.addField(arg1);
return null;
}
public String toString()
{ return ("<#jas-class-addfield#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmaddInterface extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-class-addinterface expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-addinterface expects a ClassEnv for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ClassEnv)) { throw new SchemeError("jas-class-addinterface expects a ClassEnv for arg #1"); }
ClassEnv arg0 = (tmp != null)?(ClassEnv)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-class-addinterface expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-addinterface expects a CP for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("jas-class-addinterface expects a CP for arg #2"); }
CP arg1 = (tmp != null)?(CP)(((primnode)tmp).val):null;
arg0.addInterface(arg1);
return null;
}
public String toString()
{ return ("<#jas-class-addinterface#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmsetClass extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-class-setclass expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-setclass expects a ClassEnv for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ClassEnv)) { throw new SchemeError("jas-class-setclass expects a ClassEnv for arg #1"); }
ClassEnv arg0 = (tmp != null)?(ClassEnv)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-class-setclass expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-setclass expects a CP for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("jas-class-setclass expects a CP for arg #2"); }
CP arg1 = (tmp != null)?(CP)(((primnode)tmp).val):null;
arg0.setClass(arg1);
return null;
}
public String toString()
{ return ("<#jas-class-setclass#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmsetSuperClass extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-class-setsuperclass expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-setsuperclass expects a ClassEnv for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ClassEnv)) { throw new SchemeError("jas-class-setsuperclass expects a ClassEnv for arg #1"); }
ClassEnv arg0 = (tmp != null)?(ClassEnv)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-class-setsuperclass expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-setsuperclass expects a CP for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("jas-class-setsuperclass expects a CP for arg #2"); }
CP arg1 = (tmp != null)?(CP)(((primnode)tmp).val):null;
arg0.setSuperClass(arg1);
return null;
}
public String toString()
{ return ("<#jas-class-setsuperclass#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmaddMethod extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-class-addmethod expects 6 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-addmethod expects a ClassEnv for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ClassEnv)) { throw new SchemeError("jas-class-addmethod expects a ClassEnv for arg #1"); }
ClassEnv arg0 = (tmp != null)?(ClassEnv)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-class-addmethod expects 6 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("jas-class-addmethod expects a number for arg #2"); }
short arg1 = (short)(((Selfrep)tmp).num);
if (t == null) { throw new SchemeError("jas-class-addmethod expects 6 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("jas-class-addmethod expects a String for arg #3"); }
String arg2 = (tmp!=null)?((Selfrep)tmp).val:null;
if (t == null) { throw new SchemeError("jas-class-addmethod expects 6 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("jas-class-addmethod expects a String for arg #4"); }
String arg3 = (tmp!=null)?((Selfrep)tmp).val:null;
if (t == null) { throw new SchemeError("jas-class-addmethod expects 6 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-addmethod expects a CodeAttr for arg #5"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CodeAttr)) { throw new SchemeError("jas-class-addmethod expects a CodeAttr for arg #5"); }
CodeAttr arg4 = (tmp != null)?(CodeAttr)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-class-addmethod expects 6 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-addmethod expects a ExceptAttr for arg #6"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ExceptAttr)) { throw new SchemeError("jas-class-addmethod expects a ExceptAttr for arg #6"); }
ExceptAttr arg5 = (tmp != null)?(ExceptAttr)(((primnode)tmp).val):null;
arg0.addMethod(arg1, arg2, arg3, arg4, arg5);
return null;
}
public String toString()
{ return ("<#jas-class-addmethod#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmsetClassAccess extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-class-setaccess expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-setaccess expects a ClassEnv for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ClassEnv)) { throw new SchemeError("jas-class-setaccess expects a ClassEnv for arg #1"); }
ClassEnv arg0 = (tmp != null)?(ClassEnv)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-class-setaccess expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("jas-class-setaccess expects a number for arg #2"); }
short arg1 = (short)(((Selfrep)tmp).num);
arg0.setClassAccess(arg1);
return null;
}
public String toString()
{ return ("<#jas-class-setaccess#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmsetSource extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-class-setsource expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-setsource expects a ClassEnv for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ClassEnv)) { throw new SchemeError("jas-class-setsource expects a ClassEnv for arg #1"); }
ClassEnv arg0 = (tmp != null)?(ClassEnv)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-class-setsource expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("jas-class-setsource expects a String for arg #2"); }
String arg1 = (tmp!=null)?((Selfrep)tmp).val:null;
arg0.setSource(arg1);
return null;
}
public String toString()
{ return ("<#jas-class-setsource#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmwrite extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-class-write expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-write expects a ClassEnv for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ClassEnv)) { throw new SchemeError("jas-class-write expects a ClassEnv for arg #1"); }
ClassEnv arg0 = (tmp != null)?(ClassEnv)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-class-write expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-class-write expects a scmOutputStream for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof scmOutputStream)) { throw new SchemeError("jas-class-write expects a scmOutputStream for arg #2"); }
scmOutputStream arg1 = (tmp != null)?(scmOutputStream)(((primnode)tmp).val):null;
arg0.write(arg1);
return null;
}
public String toString()
{ return ("<#jas-class-write#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmaddException extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-exception-add expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-exception-add expects a ExceptAttr for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ExceptAttr)) { throw new SchemeError("jas-exception-add expects a ExceptAttr for arg #1"); }
ExceptAttr arg0 = (tmp != null)?(ExceptAttr)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-exception-add expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-exception-add expects a CP for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("jas-exception-add expects a CP for arg #2"); }
CP arg1 = (tmp != null)?(CP)(((primnode)tmp).val):null;
arg0.addException(arg1);
return null;
}
public String toString()
{ return ("<#jas-exception-add#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmaddInsn extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-code-addinsn expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-code-addinsn expects a CodeAttr for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CodeAttr)) { throw new SchemeError("jas-code-addinsn expects a CodeAttr for arg #1"); }
CodeAttr arg0 = (tmp != null)?(CodeAttr)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-code-addinsn expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-code-addinsn expects a Insn for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof Insn)) { throw new SchemeError("jas-code-addinsn expects a Insn for arg #2"); }
Insn arg1 = (tmp != null)?(Insn)(((primnode)tmp).val):null;
arg0.addInsn(arg1);
return null;
}
public String toString()
{ return ("<#jas-code-addinsn#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmsetStackSize extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-code-stack-size expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-code-stack-size expects a CodeAttr for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CodeAttr)) { throw new SchemeError("jas-code-stack-size expects a CodeAttr for arg #1"); }
CodeAttr arg0 = (tmp != null)?(CodeAttr)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-code-stack-size expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("jas-code-stack-size expects a number for arg #2"); }
short arg1 = (short)(((Selfrep)tmp).num);
arg0.setStackSize(arg1);
return null;
}
public String toString()
{ return ("<#jas-code-stack-size#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmsetVarSize extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-code-var-size expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-code-var-size expects a CodeAttr for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CodeAttr)) { throw new SchemeError("jas-code-var-size expects a CodeAttr for arg #1"); }
CodeAttr arg0 = (tmp != null)?(CodeAttr)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-code-var-size expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("jas-code-var-size expects a number for arg #2"); }
short arg1 = (short)(((Selfrep)tmp).num);
arg0.setVarSize(arg1);
return null;
}
public String toString()
{ return ("<#jas-code-var-size#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmsetCatchtable extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-set-catchtable expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-set-catchtable expects a CodeAttr for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CodeAttr)) { throw new SchemeError("jas-set-catchtable expects a CodeAttr for arg #1"); }
CodeAttr arg0 = (tmp != null)?(CodeAttr)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-set-catchtable expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-set-catchtable expects a Catchtable for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof Catchtable)) { throw new SchemeError("jas-set-catchtable expects a Catchtable for arg #2"); }
Catchtable arg1 = (tmp != null)?(Catchtable)(((primnode)tmp).val):null;
arg0.setCatchtable(arg1);
return null;
}
public String toString()
{ return ("<#jas-set-catchtable#>"); }
}
//Autogenerated by procinfo on Thu May 19 14:07:20 EDT 2005
class scmaddEntry extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("jas-add-catch-entry expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-add-catch-entry expects a Catchtable for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof Catchtable)) { throw new SchemeError("jas-add-catch-entry expects a Catchtable for arg #1"); }
Catchtable arg0 = (tmp != null)?(Catchtable)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("jas-add-catch-entry expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("jas-add-catch-entry expects a CatchEntry for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CatchEntry)) { throw new SchemeError("jas-add-catch-entry expects a CatchEntry for arg #2"); }
CatchEntry arg1 = (tmp != null)?(CatchEntry)(((primnode)tmp).val):null;
arg0.addEntry(arg1);
return null;
}
public String toString()
{ return ("<#jas-add-catch-entry#>"); }
}
generated/scm/AutoTypes.java 100644 0 0 46512 10277203160 13553 0 ustar 0 0 package scm;
import jas.*;
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmAsciiCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-ascii-cpe expects 1 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-ascii-cpe expects a String for arg #1"); }
String arg0 = (tmp!=null)?((Selfrep)tmp).val:null;
return new primnode(new AsciiCP(arg0));
}
public String toString()
{ return ("<#make-ascii-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmClassCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-class-cpe expects 1 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-class-cpe expects a String for arg #1"); }
String arg0 = (tmp!=null)?((Selfrep)tmp).val:null;
return new primnode(new ClassCP(arg0));
}
public String toString()
{ return ("<#make-class-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmNameTypeCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-name-type-cpe expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-name-type-cpe expects a String for arg #1"); }
String arg0 = (tmp!=null)?((Selfrep)tmp).val:null;
if (t == null) { throw new SchemeError("make-name-type-cpe expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-name-type-cpe expects a String for arg #2"); }
String arg1 = (tmp!=null)?((Selfrep)tmp).val:null;
return new primnode(new NameTypeCP(arg0, arg1));
}
public String toString()
{ return ("<#make-name-type-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmFieldCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-field-cpe expects 3 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-field-cpe expects a String for arg #1"); }
String arg0 = (tmp!=null)?((Selfrep)tmp).val:null;
if (t == null) { throw new SchemeError("make-field-cpe expects 3 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-field-cpe expects a String for arg #2"); }
String arg1 = (tmp!=null)?((Selfrep)tmp).val:null;
if (t == null) { throw new SchemeError("make-field-cpe expects 3 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-field-cpe expects a String for arg #3"); }
String arg2 = (tmp!=null)?((Selfrep)tmp).val:null;
return new primnode(new FieldCP(arg0, arg1, arg2));
}
public String toString()
{ return ("<#make-field-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmInterfaceCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-interface-cpe expects 3 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-interface-cpe expects a String for arg #1"); }
String arg0 = (tmp!=null)?((Selfrep)tmp).val:null;
if (t == null) { throw new SchemeError("make-interface-cpe expects 3 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-interface-cpe expects a String for arg #2"); }
String arg1 = (tmp!=null)?((Selfrep)tmp).val:null;
if (t == null) { throw new SchemeError("make-interface-cpe expects 3 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-interface-cpe expects a String for arg #3"); }
String arg2 = (tmp!=null)?((Selfrep)tmp).val:null;
return new primnode(new InterfaceCP(arg0, arg1, arg2));
}
public String toString()
{ return ("<#make-interface-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmMethodCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-method-cpe expects 3 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-method-cpe expects a String for arg #1"); }
String arg0 = (tmp!=null)?((Selfrep)tmp).val:null;
if (t == null) { throw new SchemeError("make-method-cpe expects 3 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-method-cpe expects a String for arg #2"); }
String arg1 = (tmp!=null)?((Selfrep)tmp).val:null;
if (t == null) { throw new SchemeError("make-method-cpe expects 3 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-method-cpe expects a String for arg #3"); }
String arg2 = (tmp!=null)?((Selfrep)tmp).val:null;
return new primnode(new MethodCP(arg0, arg1, arg2));
}
public String toString()
{ return ("<#make-method-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmIntegerCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-integer-cpe expects 1 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("make-integer-cpe expects a number for arg #1"); }
int arg0 = (int)(Math.round(((Selfrep)tmp).num));
return new primnode(new IntegerCP(arg0));
}
public String toString()
{ return ("<#make-integer-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmFloatCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-float-cpe expects 1 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("make-float-cpe expects a number for arg #1"); }
float arg0 = (float)(((Selfrep)tmp).num);
return new primnode(new FloatCP(arg0));
}
public String toString()
{ return ("<#make-float-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmLongCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-long-cpe expects 1 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("make-long-cpe expects a number for arg #1"); }
long arg0 = (long)(Math.round(((Selfrep)tmp).num));
return new primnode(new LongCP(arg0));
}
public String toString()
{ return ("<#make-long-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmDoubleCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-double-cpe expects 1 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("make-double-cpe expects a number for arg #1"); }
double arg0 = (double)(((Selfrep)tmp).num);
return new primnode(new DoubleCP(arg0));
}
public String toString()
{ return ("<#make-double-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmStringCP extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-string-cpe expects 1 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-string-cpe expects a String for arg #1"); }
String arg0 = (tmp!=null)?((Selfrep)tmp).val:null;
return new primnode(new StringCP(arg0));
}
public String toString()
{ return ("<#make-string-cpe#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmVar extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-field expects 4 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("make-field expects a number for arg #1"); }
short arg0 = (short)(Math.round(((Selfrep)tmp).num));
if (t == null) { throw new SchemeError("make-field expects 4 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("make-field expects a CP for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("make-field expects a CP for arg #2"); }
CP arg1 = (tmp != null)?(CP)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("make-field expects 4 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("make-field expects a CP for arg #3"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("make-field expects a CP for arg #3"); }
CP arg2 = (tmp != null)?(CP)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("make-field expects 4 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("make-field expects a ConstAttr for arg #4"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof ConstAttr)) { throw new SchemeError("make-field expects a ConstAttr for arg #4"); }
ConstAttr arg3 = (tmp != null)?(ConstAttr)(((primnode)tmp).val):null;
return new primnode(new Var(arg0, arg1, arg2, arg3));
}
public String toString()
{ return ("<#make-field#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmConstAttr extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-const expects 1 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("make-const expects a CP for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("make-const expects a CP for arg #1"); }
CP arg0 = (tmp != null)?(CP)(((primnode)tmp).val):null;
return new primnode(new ConstAttr(arg0));
}
public String toString()
{ return ("<#make-const#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmscmOutputStream extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-outputstream expects 1 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-outputstream expects a String for arg #1"); }
String arg0 = (tmp!=null)?((Selfrep)tmp).val:null;
return new primnode(new scmOutputStream(arg0));
}
public String toString()
{ return ("<#make-outputstream#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmLabel extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-label expects 1 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof Selfrep)) { throw new SchemeError("make-label expects a String for arg #1"); }
String arg0 = (tmp!=null)?((Selfrep)tmp).val:null;
return new primnode(new Label(arg0));
}
public String toString()
{ return ("<#make-label#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmClassEnv extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
return new primnode(new ClassEnv());
}
public String toString()
{ return ("<#make-class-env#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmCodeAttr extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
return new primnode(new CodeAttr());
}
public String toString()
{ return ("<#make-code#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmExceptAttr extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
return new primnode(new ExceptAttr());
}
public String toString()
{ return ("<#make-exception#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmCatchtable extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
return new primnode(new Catchtable());
}
public String toString()
{ return ("<#make-catchtable#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmCatchEntry extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("make-catch-entry expects 4 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("make-catch-entry expects a Label for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof Label)) { throw new SchemeError("make-catch-entry expects a Label for arg #1"); }
Label arg0 = (tmp != null)?(Label)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("make-catch-entry expects 4 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("make-catch-entry expects a Label for arg #2"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof Label)) { throw new SchemeError("make-catch-entry expects a Label for arg #2"); }
Label arg1 = (tmp != null)?(Label)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("make-catch-entry expects 4 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("make-catch-entry expects a Label for arg #3"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof Label)) { throw new SchemeError("make-catch-entry expects a Label for arg #3"); }
Label arg2 = (tmp != null)?(Label)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("make-catch-entry expects 4 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("make-catch-entry expects a CP for arg #4"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("make-catch-entry expects a CP for arg #4"); }
CP arg3 = (tmp != null)?(CP)(((primnode)tmp).val):null;
return new primnode(new CatchEntry(arg0, arg1, arg2, arg3));
}
public String toString()
{ return ("<#make-catch-entry#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmIincInsn extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("iinc expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("iinc expects a number for arg #1"); }
int arg0 = (int)(Math.round(((Selfrep)tmp).num));
if (t == null) { throw new SchemeError("iinc expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("iinc expects a number for arg #2"); }
int arg1 = (int)(Math.round(((Selfrep)tmp).num));
return new primnode(new IincInsn(arg0, arg1));
}
public String toString()
{ return ("<#iinc#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmMultiarrayInsn extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("multianewarray expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("multianewarray expects a CP for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("multianewarray expects a CP for arg #1"); }
CP arg0 = (tmp != null)?(CP)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("multianewarray expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("multianewarray expects a number for arg #2"); }
int arg1 = (int)(Math.round(((Selfrep)tmp).num));
return new primnode(new MultiarrayInsn(arg0, arg1));
}
public String toString()
{ return ("<#multianewarray#>"); }
}
//Autogenerated by typeinfo on Thu May 19 14:07:20 EDT 2005
class scmInvokeinterfaceInsn extends Procedure implements Obj
{
Obj apply(Cell args, Env f)
throws Exception
{
Cell t = args;
Obj tmp;
if (t == null) { throw new SchemeError("invokeinterface expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if ((tmp != null) && !(tmp instanceof primnode)) { throw new SchemeError("invokeinterface expects a CP for arg #1"); }
if ((tmp != null) && !((((primnode)tmp).val) instanceof CP)) { throw new SchemeError("invokeinterface expects a CP for arg #1"); }
CP arg0 = (tmp != null)?(CP)(((primnode)tmp).val):null;
if (t == null) { throw new SchemeError("invokeinterface expects 2 arguments"); }
tmp = (t.car!=null)?t.car.eval(f):null; t = t.cdr;
if (!(tmp instanceof Selfrep)) { throw new SchemeError("invokeinterface expects a number for arg #2"); }
int arg1 = (int)(Math.round(((Selfrep)tmp).num));
return new primnode(new InvokeinterfaceInsn(arg0, arg1));
}
public String toString()
{ return ("<#invokeinterface#>"); }
}
lib/jas/.jas.prcs_aux 100644 0 0 6332 10070636274 12142 0 ustar 0 0 ;; This file is automatically generated, editing may cause PRCS to do
;; REALLY bad things.
(Created-By-Prcs-Version 1 2 15)
(src/scm/driver.java 5506 957458219 3_driver.jav 1.2)
(src/scm/AutoInit.java 2662 957455940 16_AutoInit.j 1.1)
(src/jas/CatchEntry.java 1410 957388675 b/41_CatchEntry 1.1)
(src/jas/AsciiCP.java 598 957388675 b/40_AsciiCP.ja 1.1)
(src/scm/AutoTypes.java 19786 957392553 14_AutoTypes. 1.3)
(src/jas/Insn.java 5743 957388675 b/26_Insn.java 1.1)
(src/jas/GenericAttr.java 1404 957388675 b/28_GenericAtt 1.1)
(src/jas/StringCP.java 638 957388675 b/8_StringCP.j 1.1)
(src/scm/Symbol.java 476 957455940 5_Symbol.jav 1.1)
(src/jas/Var.java 1724 957388675 b/15_Var.java 1.1)
(src/jas/FieldCP.java 1224 957388675 b/30_FieldCP.ja 1.1)
(src/scm/scmOutputStream.java 350 957455940 8_scmOutputS 1.1)
(src/jas/FloatCP.java 581 957388675 b/29_FloatCP.ja 1.1)
(src/jas/Label.java 1856 957388675 b/21_Label.java 1.1)
(src/scm/Cell.java 1032 957455940 13_Cell.java 1.1)
(src/jas/RuntimeConstants.java 15677 957388675 b/13_RuntimeCon 1.1)
(src/jas/Method.java 1765 957388675 b/16_Method.jav 1.1)
(src/scm/Selfrep.java 362 957455940 6_Selfrep.ja 1.1)
(src/scm/SchemeError.java 175 957455940 7_SchemeErro 1.1)
(src/jas/SourceAttr.java 1004 957388675 b/9_SourceAttr 1.1)
(src/jas/MultiarrayInsn.java 607 957388675 b/12_Multiarray 1.1)
(src/jas/TableswitchInsn.java 731 957388675 b/10_Tableswitc 1.1)
(src/jas/InvokeinterfaceInsn.java 525 957388675 b/38_Invokeinte 1.1)
(src/scm/Procedure.java 13542 957455940 11_Procedure. 1.1)
(src/scm/Obj.java 178 957455940 9_Obj.java 1.1)
(src/jas/ConstAttr.java 899 957388675 b/33_ConstAttr. 1.1)
(src/scm/InsnProcedure.java 1136 957458071 17_InsnProced 1.2)
(src/jas/CP.java 685 957388675 b/39_CP.java 1.1)
(src/jas/IntegerCP.java 587 957388675 b/24_IntegerCP. 1.1)
(src/scm/Env.java 2539 957455940 12_Env.java 1.1)
(src/jas/InsnOperand.java 10206 957388675 b/25_InsnOperan 1.1)
(src/jas/jasError.java 304 957388675 b/7_jasError.j 1.1)
(src/scm/Lambda.java 524 957455940 10_Lambda.jav 1.1)
(src/jas/LookupswitchInsn.java 727 957388675 b/14_Lookupswit 1.1)
(src/jas/NameTypeCP.java 931 957388675 b/11_NameTypeCP 1.1)
(src/jas/MethodCP.java 920 957388675 b/18_MethodCP.j 1.1)
(src/scm/primnode.java 343 957455940 2_primnode.j 1.1)
(src/jas/IincInsn.java 993 957388675 b/27_IincInsn.j 1.1)
(src/jas/CodeAttr.java 7160 957392553 b/34_CodeAttr.j 1.2)
(src/jas/InterfaceCP.java 977 957388675 b/23_InterfaceC 1.1)
(src/jas/Catchtable.java 1641 957388675 b/37_Catchtable 1.1)
(src/jas/ClassEnv.java 7614 957388675 b/35_ClassEnv.j 1.1)
(src/jas/LongCP.java 572 957388675 b/17_LongCP.jav 1.1)
(src/jas/ExceptAttr.java 1109 957388675 b/31_ExceptAttr 1.1)
(src/jas/LocalVarTableAttr.java 1728 957388675 b/20_LocalVarTa 1.1)
(src/scm/AutoProcs.java 20341 957392553 15_AutoProcs. 1.3)
(src/scm/procinfo.class 3152 955469363 1_procinfo.c 1.1)
(src/jas/DoubleCP.java 590 957388675 b/32_DoubleCP.j 1.1)
(src/jas/ClassCP.java 657 957388675 b/36_ClassCP.ja 1.1)
(src/scm/typeinfo.class 3323 955469363 0_typeinfo.c 1.1)
(src/jas/LocalVarEntry.java 2120 957388675 b/19_LocalVarEn 1.1)
(src/scm/autogen.class 5046 955469363 4_autogen.cl 1.1)
(src/jas/LineTableAttr.java 1685 957388675 b/22_LineTableA 1.1)
(src/scm/autogen/autogen.java 11568 957458031 18_autogen.ja 1.2)
lib/jas/CHANGES.jm 100644 0 0 273 10070636274 11117 0 ustar 0 0
1 March 1997, Jon Meyer
* Modified JAS to use self-contained RuntimeConstants interface.
* Moved JAS classes into the Jasmin classes directory.
* Fixed bug in CatchEntry.
lib/jas/README 100644 0 0 6146 10070636274 10424 0 ustar 0 0 This is v0.3 of a simple Java bytecode assembler.
Quick Info:
-----------
If you want to just quickly check out things, do the following.
% java scm.driver examples/hworld.jas
This compiles an assembler script to bytecode.
% java out
This runs the resultant bytecode, which should print the
string "Hello World" 5 times.
Then read the online documentation at
http://www.blackdown.org/~kbs/jas.html
More Details:
-------------
* What is available:
A simple java bytecode assembler that can be used either as a
standalone scripting program or directly from java (through the jas
package)
* What is not available in this version:
- Error recovery in the scripting interface
- defining a tableswitch or lookupswitch instruction from the scripting
interface
* Documentation
You can leaf through the jas API in reference/jas You can look at
the list of available scripting functions from reference/scm. The
bulk of what documentation exists is online from
http://www.blackdown.org/~kbs/jas.html
UTSL, ofcourse ;-) And documentation is mostly demand-driven,
if there is interest I'll continue to expand it.
* Examples
The examples directory contains a few examples of using the
assembler with the script and directly from java. Look at the
README in this directory to see how to run them. Online
documentation contains more details.
simple.java
simple.jas
These are simple programs that create classes which
don't do anything but get initialized.
hworld.java
hworld.jas
These create bytecode that can be run standalone,
which print a string a few times.
exprcomp.java
This is a primitive compiler that does runtime
codegeneration and execution of arithmetic expressions.
exprcomp.jas
This is a primitive compiler written in jas to translate
jas arithmetic expressions to bytecode.
* Recompiling
You can recompile all classes if you wish. First remove the
jas/ and the scm/ directories under this directory. Then run the
script compile.sh in this directory.
You will probably want to then run the tests in the test directory
to make sure the basic api is functional. Look at the README in this
directory for details.
Running the scripting driver:
-----------------------------
If you are going to use the scripting language, the driver for it is
located in the class scm.driver. The magic incantation is
% java scm.driver [path to file]
If you don't give it a file name, it will try to read from stdin.
Using code from this distribution:
----------------------------------
There is exactly one class that I *use* from the sun/* package, which
is sun.tools.java.RuntimeConstants. I know of no other reasonable way
to keep in sync with the VM.
Outside of this class, (which is not present in this distribution) you
can freely use/modify/sell/dance on with hobnailed boots any or all of
this code. If you do end up using derived code and feel disinclined to
buy me a snowboard :) all I ask is that you add me to the list of
credits.
-KB-
kbs@sbktech.org
Version created: Tue Aug 21 09:50:23 PDT 1996
lib/jas/examples/README 100644 0 0 3115 10070636274 12233 0 ustar 0 0 This contains three examples of using the assembler
from java and from the script
Look up http://www.blackdown.org/~kbs/jas.html for more
documentation. This only tells you how to run the examples. The
documentation is very Unix centric, I apologize.... I have not had
time to set this up on the PC's yet.
simple.java:
simple.jas:
Unexciting program that generates a do nothing class.
Go up a directory and compile simple.java. Run the program,
which generates the bytecode. Disassemble the bytecode
% (cd ..; javac -d . examples/simple.java; java simple; javap -p -c out)
Same thing, but using the script instead of java directly.
% (cd ..; java scm.driver examples/simple.jas; javap -p -c out)
hworld.java:
hworld.jas:
Print a string in a loop.
% (cd ..; javac -d . examples/hworld.java; java hworld; java out)
As before, but use script instead.
% (cd ..; java scm.driver examples/hworld.jas; java out)
exprcomp.java:
Primitive runtime expression compiler. It translates arithmetic
expressions into bytecode and loads it on the fly as a class, which
is run to get the answer. test.inp is an example of the sort of
arithmetic expressions it translates.
% (cd ..; javac -d . examples/exprcomp.java; java exprcomp examples/test.inp)
exprcomp.jas:
Primitive compiler for jas arithmetic expressions (in jas).
jas is fairly expressive, thats about the only point of this
exercise ;-) Unlike the java version, this gets written out
into a file which you'll have to run to get the results.
% (cd ..; java scm.driver examples/exprcomp.jas; java results)
lib/jas/examples/exprcomp.jas 100644 0 0 6156 10070636274 13717 0 ustar 0 0 ;;; Simple arithmetic expression compiler for jas in jas.
;;;
;;; The compiler is defined in the function
;;; compile-expression
;;;
;;; use as (for instance)
;;; (compile-expression (quote (+ (* 2 (+ 1 3)) 1)))
;;;
;;; This will generate a standalone program called results.class
;;; Run the bytecode interpreter on it as:
;;;
;;; % java results
;;;
;;; which will print the result of the expression
(define compile-expression
(lambda (expr)
(real-compile-expression expr)
(dump-code)))
;; The fun part...
(define real-compile-expression
(lambda (expr)
(cond
((num? expr)
(compile-number expr))
(1 (progn
(real-compile-expression (get-op1 expr))
(real-compile-expression (get-op2 expr))
(compile-op (get-op expr))
(set! cur-stack-height (- cur-stack-height 1)))))))
;; Ah well. Back to boring bookkeeping.
(define compile-number
(lambda (num)
(append-insn (bipush num))
(set! cur-stack-height (+ 1 cur-stack-height))
(cond
((< max-stack-height cur-stack-height)
(set! max-stack-height cur-stack-height)))))
(define compile-op
(lambda (op)
(cond
((eq? op (quote +)) (append-insn (iadd)))
((eq? op (quote -)) (append-insn (isub)))
((eq? op (quote *)) (append-insn (imul)))
((eq? op (quote /)) (append-insn (idiv))))))
(define get-op1
(lambda (expr) (car (cdr expr))))
(define get-op2
(lambda (expr) (car (cdr (cdr expr)))))
(define get-op
(lambda (expr) (car expr)))
(define append-insn
(lambda (insn)
(jas-code-addinsn my-code insn)))
(define cur-stack-height 1)
(define max-stack-height 1)
(define my-code (make-code))
(define my-init-code (make-code))
; define the main() portion,
; and the call to print out the
; results.
(define append-sequence
(lambda (code-part insn-list)
(mapcar (lambda (insn) (jas-code-addinsn code-part insn))
insn-list)))
(append-sequence
my-init-code
(quote
((aload_0)
(invokenonvirtual (make-method-cpe "java/lang/Object" "" "()V"))
(return))))
(define dump-code
(lambda ()
(define my-env (make-class-env))
(jas-class-setclass my-env (make-class-cpe "results"))
(jas-class-setsuperclass my-env (make-class-cpe "java/lang/Object"))
(jas-class-addmethod my-env acc-public "" "()V" my-init-code ())
(append-sequence
my-code
(quote
((getstatic
(make-field-cpe "java/lang/System" "out" "Ljava/io/PrintStream;"))
(swap)
(invokevirtual (make-method-cpe
"java/io/PrintStream" "println" "(I)V"))
(return))))
(jas-code-stack-size my-code max-stack-height)
(jas-class-addmethod my-env
(| acc-public acc-static)
"main" "([Ljava/lang/String;)V" my-code ())
(jas-class-write my-env
(make-outputstream "results.class"))))
;;;
;;; example usage of compiler.
;;;
;;; run the compiled class with
;;; % java results
;;; to get the answer.
(compile-expression (quote (+ (* 2 (+ 1 3)) 1)))
lib/jas/examples/exprcomp.java 100644 0 0 15412 10070636274 14076 0 ustar 0 0 // Primitive runtime code generation of expressions. This is a jas
// implementation of the example in Aho Sethi Ullman.
//
// You pass to it statements of the form
// a = 1*2 + 3*5;
// Only integer operations are allowed, and variables
// are magically created by using them in the LHS of a statement.
//
// You can print out the value of expressions with the println keyword:
// println(a + 10);
//
// It compiles this into a bytearray, and then loads it as
// a new class.
//
// Unfortunately, this trick cannot be used in an applet --- security
// restrictions prevent ClassLoaders from being placed on the
// stack. So much for writing regexp compilers that can do codegen instead of
// state tables.
//
// The grammar is simple, so code generation is part of the parsing
// step. Operator precedence is directly handled by the grammar.
//
// Grammar + production rules:
//
// start -> list EOF
// list -> id = expr ; { emit(istore, id.index); } list
// | println expr ; { emit(); } list
// | lambda
// expr -> term moreterms
// moreterms -> + term { emit(iadd) } moreterms
// | - term { emit(isub) } moreterms
// | lambda
// term -> factor morefactors
// morefactors -> * factor { emit(imul) } morefactors
// | / factor { emit(idiv) } morefactors
// | lambda
// factor -> ( expr )
// | number { emit(iconst, number.value) }
// | id { emit(iload, id.index); }
import java.util.*;
import java.io.*;
import jas.*;
public class exprcomp implements RuntimeConstants
{
StreamTokenizer inp;
CodeAttr myCode;
short cur_stack_height;
short max_stack_height;
short max_vars;
Hashtable vars;
public exprcomp(StreamTokenizer inp)
throws jasError
{
inp.eolIsSignificant(false);
this.inp = inp;
myCode = new CodeAttr();
// Add initializations
myCode.addInsn(new Insn(opc_aload_0));
myCode.addInsn(new Insn(opc_invokenonvirtual,
new MethodCP("java/lang/Object",
"", "()V")));
cur_stack_height = max_stack_height = 1;
vars = new Hashtable();
max_vars = 1;
}
public void write(DataOutputStream out)
throws IOException, jasError
{
ClassEnv clazz = new ClassEnv();
myCode.setStackSize(max_stack_height);
myCode.setVarSize(max_vars);
// add initializer to class
clazz.addMethod
((short) ACC_PUBLIC, "", "()V", myCode, null);
clazz.setClassAccess((short) ACC_PUBLIC);
clazz.setClass(new ClassCP("results"));
clazz.setSuperClass(new ClassCP("java/lang/Object"));
clazz.write(out);
}
public void parse()
throws IOException, parseError, jasError
{
inp.nextToken();
while(inp.ttype != inp.TT_EOF)
{
if (inp.ttype != inp.TT_WORD)
{
throw new parseError("Expected an id at line " + inp.lineno());
}
if (inp.sval.equals("println"))
{
match(inp.TT_WORD);
expr();
match(';');
emit(new Insn(opc_getstatic,
new FieldCP("java/lang/System",
"out", "Ljava/io/PrintStream;")));
emit(new Insn(opc_swap));
emit(new Insn(opc_invokevirtual,
new MethodCP("java/io/PrintStream",
"println", "(I)V")));
}
else
{ // search, maybe add into var list
Integer idx;
if ((idx = (Integer) vars.get(inp.sval)) == null)
{
idx = new Integer(max_vars++);
vars.put(inp.sval.intern(), idx);
}
match(inp.TT_WORD); match('='); expr(); match(';');
emit(new Insn(opc_istore, idx.intValue()));
}
}
emit(new Insn(opc_return));
}
void expr()
throws IOException, parseError, jasError
{
term();
while (true)
{
switch(inp.ttype)
{
case '+':
match('+'); term(); emit(new Insn(opc_iadd)); break;
case '-':
match('-'); term(); emit(new Insn(opc_isub)); break;
default: return;
}
cur_stack_height--;
}
}
void term()
throws IOException, parseError, jasError
{
factor();
while (true)
{
switch(inp.ttype)
{
case '*': match('*'); factor(); emit(new Insn(opc_imul)); break;
case '/': match('/'); factor(); emit(new Insn(opc_idiv)); break;
default: return;
}
cur_stack_height --;
}
}
void factor()
throws IOException, parseError, jasError
{
switch(inp.ttype)
{
case '(': match('('); expr(); match(')'); break;
case inp.TT_NUMBER:
int val = (int)(inp.nval);
emit(new Insn(opc_bipush, (short)val));
match(inp.TT_NUMBER);
break;
case inp.TT_WORD:
Integer idx;
if ((idx = (Integer) vars.get(inp.sval)) == null)
{
throw new parseError
("Unknown variable " + inp.sval + " at line " + inp.lineno());
}
emit(new Insn(opc_iload, idx.intValue()));
match(inp.TT_WORD);
break;
default:
throw new parseError("Syntax error at line " + inp.lineno());
}
cur_stack_height++;
if (max_stack_height < cur_stack_height)
max_stack_height = cur_stack_height;
}
void match(int val)
throws IOException, parseError
{
if (inp.ttype != val)
{ throw new parseError
("line " + inp.lineno() + ": expected " + val + " but got " + inp); }
inp.nextToken();
}
void emit(Insn insn)
{
myCode.addInsn(insn);
}
public static void main(String argv[])
throws Exception
{
exprcomp compiler =
new exprcomp(new StreamTokenizer(new FileInputStream(argv[0])));
compiler.parse();
ByteArrayOutputStream data = new ByteArrayOutputStream();
compiler.write(new DataOutputStream(data));
dynaloader dl = new dynaloader(data.toByteArray());
dl.exec();
}
}
class dynaloader extends ClassLoader
{
Hashtable cache;
Class ex;
dynaloader(byte[] data)
throws ClassFormatError
{
cache = new Hashtable();
ex = defineClass(data, 0, data.length);
cache.put("results", ex);
resolveClass(ex);
}
void exec() throws Exception { ex.newInstance(); }
public synchronized Class loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
Class c = (Class) cache.get(name);
if (c == null)
{
c = findSystemClass(name);
cache.put(name, c);
}
if (resolve) resolveClass(c);
return c;
}
}
class parseError extends Exception
{ parseError(String s) { super(s); } }
lib/jas/examples/hworld.jas 100644 0 0 4371 10070636274 13356 0 ustar 0 0 ;; create a container
(define my-class (make-class-env))
;; specify class hierarchy
(jas-class-setaccess my-class acc-public)
(jas-class-setclass my-class (make-class-cpe "out"))
(jas-class-setsuperclass my-class (make-class-cpe "java/lang/Object"))
;; write a convenience function to append insns as a list.
(define append-code
(lambda (code-part insn-list)
(mapcar (lambda (insn) (jas-code-addinsn code-part insn))
insn-list)))
;; Define code for initializer
;;
(define init-it (make-code))
(append-code
init-it
(quote
((aload_0)
(invokenonvirtual (make-method-cpe "java/lang/Object" "" "()V"))
(return))))
;; this is the code that comprises
;; the actual task, ie the code for
;; main(String argv[]).
;; print a string 5 times
(define doit (make-code))
(append-code
doit
(quote
(
; store references in local
; variables to avoid field/cp
; lookup
(getstatic
(make-field-cpe "java/lang/System" "out" "Ljava/io/PrintStream;"))
(astore_1)
(ldc (make-string-cpe "Hello World"))
(astore_2)
(bipush 5)
(istore_3) ; store loop index in var reg 3
; loop 5 times, printing out
; the string.
(make-label "loop")
; push arguments to function
; on stack and call it
(aload_1) (aload_2)
(invokevirtual
(make-method-cpe "java/io/PrintStream" "println" "(Ljava/lang/String;)V"))
; decrement loop index
(iinc 3 -1)
(iload_3)
(ifne (make-label "loop"))
(return))))
;; set stack/var size
(jas-code-stack-size doit 3)
(jas-code-var-size doit 4)
;; fill up the class with the methods
;; first the initializer.
(jas-class-addmethod my-class acc-public "" "()V" init-it ())
;; define the printing code as a static main(String argv[]) method
(jas-class-addmethod my-class
(| acc-static acc-public)
"main" "([Ljava/lang/String;)V" doit ())
;; write it out.
(jas-class-write my-class (make-outputstream "out.class"))
lib/jas/examples/hworld.java 100644 0 0 5202 10070636274 13514 0 ustar 0 0 import jas.*;
import java.io.*;
//
// This is program that makes calls into the jas package
// to generate a class that prints a string afew times.
//
class hworld implements RuntimeConstants
{
public static void main(String argv[])
throws jasError, IOException
{
// class hierarchy
ClassEnv nclass = new ClassEnv();
nclass.setClass(new ClassCP("out"));
nclass.setSuperClass(new ClassCP("java/lang/Object"));
nclass.setClassAccess((short)ACC_PUBLIC);
// Initialization code
CodeAttr init = new CodeAttr();
init.addInsn(new Insn(opc_aload_0));
init.addInsn(new Insn(opc_invokenonvirtual,
new MethodCP("java/lang/Object", "", "()V")));
init.addInsn(new Insn(opc_return));
// Actual code to print string
CodeAttr doit = new CodeAttr();
// store refs in local variables
doit.addInsn(new Insn(opc_getstatic,
new FieldCP("java/lang/System",
"out",
"Ljava/io/PrintStream;")));
doit.addInsn(new Insn(opc_astore_1));
doit.addInsn(new Insn(opc_ldc,
new StringCP("Hello World")));
doit.addInsn(new Insn(opc_astore_2));
// Loop index in var reg 3
doit.addInsn(new Insn(opc_bipush, 5));
doit.addInsn(new Insn(opc_istore_3));
// Start the loop
Label loop = new Label("loop");
doit.addInsn(loop);
doit.addInsn(new Insn(opc_aload_1));
doit.addInsn(new Insn(opc_aload_2));
doit.addInsn(new Insn(opc_invokevirtual,
new MethodCP("java/io/PrintStream",
"println",
"(Ljava/lang/String;)V")));
doit.addInsn(new IincInsn(3, -1));
doit.addInsn(new Insn(opc_iload_3));
doit.addInsn(new Insn(opc_ifne, loop));
doit.addInsn(new Insn(opc_return));
// set the right sizes for code
doit.setStackSize((short)3); doit.setVarSize((short)4);
// Add the init code to the class.
nclass.addMethod((short)ACC_PUBLIC, "", "()V", init, null);
// Add the printing code
nclass.addMethod((short)(ACC_PUBLIC|ACC_STATIC), "main",
"([Ljava/lang/String;)V", doit, null);
// write it all out
nclass.write(new DataOutputStream
(new FileOutputStream("out.class")));
}
}
lib/jas/examples/simple.jas 100644 0 0 2350 10070636274 13343 0 ustar 0 0 ;; script to create a class that does nothing.
; make-class-env creates
; a ClassEnv object which is
; used to store information about
; an object.
(define my-class (make-class-env))
; make-code creates a code object
; which contains the body of a
; method.
(define init-code (make-code))
(jas-code-addinsn init-code
(aload_0))
(jas-code-addinsn init-code
(invokenonvirtual
(make-method-cpe "java/lang/Object" "" "()V")))
(jas-code-addinsn init-code
(return))
; fill up the class with goodies
(jas-class-setsuperclass my-class (make-class-cpe "java/lang/Object"))
(jas-class-setclass my-class (make-class-cpe "out"))
(jas-class-setaccess my-class acc-public)
(jas-class-addmethod my-class acc-public "" "()V" init-code ())
; and write it all out
(jas-class-write my-class (make-outputstream "out.class"))
lib/jas/examples/simple.java 100644 0 0 2270 10070636274 13510 0 ustar 0 0 import jas.*;
import java.io.*;
//
// This is program that makes calls into the jas package
// to generate a class that does nothing at all.
//
class simple implements RuntimeConstants
{
public static void main(String argv[])
throws jasError, IOException
{
// CodeAttr's contain the body of
// a method.
CodeAttr init = new CodeAttr();
init.addInsn(new Insn(opc_aload_0));
init.addInsn(new Insn(opc_invokenonvirtual,
new MethodCP("java/lang/Object", "", "()V")));
init.addInsn(new Insn(opc_return));
// ClassEnv's are used as a container
// to hold all information about a class.
ClassEnv nclass = new ClassEnv();
nclass.setClass(new ClassCP("out"));
nclass.setSuperClass(new ClassCP("java/lang/Object"));
// Add the init code to the class.
nclass.addMethod((short)ACC_PUBLIC, "", "()V", init, null);
// write it all out
nclass.write(new DataOutputStream
(new FileOutputStream("out.class")));
}
}
lib/jas/examples/test.inp 100644 0 0 77 10070636274 13006 0 ustar 0 0 a = 10;
println a;
b = a + 5;
println (b);
println(a*b +2);
lib/jas/src/jas/AnnotElemValPair.java 100644 0 0 1654 10240435426 15106 0 ustar 0 0 /**
* ElemValPairs are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class AnnotElemValPair extends ElemValPair {
AnnotationAttr attr;
void resolve(ClassEnv e){
super.resolve(e);
attr.resolve(e);
}
/**
* Note: An annotation attr is associated with a class,
* method or field so you need to create a new VisibilityAnnotationAttr for
*/
public AnnotElemValPair(String name, char kind, AnnotationAttr attr) { //
super(name, kind);
this.attr = attr;
}
int size(){
return super.size() + attr.size();
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
super.write(e, out);
attr.write(e, out);
}
}
lib/jas/src/jas/AnnotationAttr.java 100644 0 0 3506 10240435426 14710 0 ustar 0 0 /**
* Annotation attributes are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class AnnotationAttr {
AsciiCP type;
ArrayList list = new ArrayList();
void resolve(ClassEnv e){
e.addCPItem(type);
if (list != null){
Iterator it = list.iterator();
while (it.hasNext()){
((ElemValPair)it.next()).resolve(e);
}
}
}
/**
* Note: An annotation attr is associated with a class,
* method or field so you need to create a new VisibilityAnnotationAttr for
*/
public AnnotationAttr(String type, ArrayList elems) { //
this.type = new AsciiCP(type);
this.list = elems;
}
public AnnotationAttr() { //
}
public void setType(String type){
this.type = new AsciiCP(type);
}
public void addElemValPair(ElemValPair pair){
list.add(pair);
}
int size(){
int i = 4;
if (list != null){
Iterator it = list.iterator();
while (it.hasNext()){
i += ((ElemValPair)it.next()).size();
}
}
return i;
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(type));
if (list == null){
out.writeShort(0);
}
else {
out.writeShort(list.size()); // fixed length
}
if (list != null){
Iterator it = list.iterator();
while (it.hasNext()){
((ElemValPair)it.next()).write(e, out);
}
}
}
}
lib/jas/src/jas/AnnotationDefaultAttr.java 100644 0 0 1712 10240435426 16212 0 ustar 0 0 /**
* Signature attributes are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class AnnotationDefaultAttr {
static CP attr = new AsciiCP("AnnotationDefault");
ElemValPair elem;
void resolve(ClassEnv e){
e.addCPItem(attr);
elem.resolve(e);
}
/**
* Note: A signature attr is associated with a class,
* method or field so you need to create a new SignatureAttr for
*/
public AnnotationDefaultAttr(ElemValPair s) { //
elem = s;
}
int size(){
return elem.size();
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(attr));
out.writeInt(size()); // fixed length
elem.write(e, out);
}
}
lib/jas/src/jas/ArrayElemValPair.java 100644 0 0 4054 10240435426 15102 0 ustar 0 0 /**
* ElemValPairs are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class ArrayElemValPair extends ElemValPair {
ArrayList list;
void resolve(ClassEnv e){
super.resolve(e);
if (list != null){
Iterator it = list.iterator();
while (it.hasNext()){
((ElemValPair)it.next()).resolve(e);
}
}
}
/**
* Note: An annotation attr is associated with a class,
* method or field so you need to create a new VisibilityAnnotationAttr for
*/
public ArrayElemValPair(String name, char kind, ArrayList list) { //
super(name, kind);
this.list = list;
}
public void setNoName(){
if (list == null) return;
Iterator it = list.iterator();
while (it.hasNext()){
((ElemValPair)it.next()).setNoName();
}
}
public ArrayElemValPair(String name, char kind) { //
super(name, kind);
}
public void addElemValPair(ElemValPair elem){
if (list == null){
list = new ArrayList();
}
list.add(elem);
}
int size(){
int i = super.size();
i += 2; // array elem count short
if (list != null){
Iterator it = list.iterator();
while (it.hasNext()){
i += ((ElemValPair)it.next()).size();
}
}
return i;
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
super.write(e, out);
if (list != null){
out.writeShort(list.size());
}
else {
out.writeShort(0);
}
if (list != null){
Iterator it = list.iterator();
while (it.hasNext()){
((ElemValPair)it.next()).write(e, out);
}
}
}
}
lib/jas/src/jas/AsciiCP.java 100644 0 0 1124 10070636274 13215 0 ustar 0 0 /**
* This is a class to create Ascii CP entries.
*
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
public class AsciiCP extends CP implements RuntimeConstants
{
/**
* @param s Name of the ascii constant pool entry
*/
public AsciiCP(String s)
{ uniq = s.intern(); }
void resolve(ClassEnv e)
{ return; }
public String toString() { return "AsciiCP: " + uniq; }
void write(ClassEnv e, DataOutputStream out)
throws IOException
{
out.writeByte(CONSTANT_UTF8);
out.writeUTF(uniq);
}
}
lib/jas/src/jas/Base64.java 100644 0 0 15713 10070636274 13017 0 ustar 0 0 // *** WARNING ***
// This Soot file has been copied to jas, as it is required for
// jas and jasmin compilation. In the unlikely event that any changes are
// made to this file, they should be reflected in the Soot
// distribution.
// - Patrick Lam, 01/25/2001
// *** END-WARNING ***
//////////////////////license & copyright header/////////////////////////
// //
// Base64 - encode/decode data using the Base64 encoding scheme //
// //
// Copyright (c) 1998 by Kevin Kelley //
// //
// This library is free software; you can redistribute it and/or //
// modify it under the terms of the GNU Lesser General Public //
// License as published by the Free Software Foundation; either //
// version 2.1 of the License, or (at your option) any later version. //
// //
// This library is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Lesser General Public License for more details. //
// //
// You should have received a copy of the GNU Lesser General Public //
// License along with this library; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA //
// 02111-1307, USA, or contact the author: //
// //
// Kevin Kelley - 30718 Rd. 28, La Junta, CO, //
// 81050 USA. //
// //
////////////////////end license & copyright header///////////////////////
package jas;
/**
* Provides encoding of raw bytes to base64-encoded characters, and
* decoding of base64 characters to raw bytes.
*
* @author Kevin Kelley (kelley@ruralnet.net)
* @version 1.3
* @date 06 August 1998
* @modified 14 February 2000
* @modified 22 September 2000
*/
public class Base64 {
/**
* returns an array of base64-encoded characters to represent the
* passed data array.
*
* @param data the array of bytes to encode
* @return base64-coded character array.
*/
static public char[] encode(byte[] data)
{
char[] out = new char[((data.length + 2) / 3) * 4];
//
// 3 bytes encode to 4 chars. Output is always an even
// multiple of 4 characters.
//
for (int i=0, index=0; i>= 6;
out[index+2] = alphabet[(trip? (val & 0x3F): 64)];
val >>= 6;
out[index+1] = alphabet[val & 0x3F];
val >>= 6;
out[index+0] = alphabet[val & 0x3F];
}
return out;
}
/**
* Decodes a BASE-64 encoded stream to recover the original
* data. White space before and after will be trimmed away,
* but no other manipulation of the input will be performed.
*
* As of version 1.2 this method will properly handle input
* containing junk characters (newlines and the like) rather
* than throwing an error. It does this by pre-parsing the
* input and generating from that a count of VALID input
* characters.
**/
static public byte[] decode(char[] data)
{
// as our input could contain non-BASE64 data (newlines,
// whitespace of any sort, whatever) we must first adjust
// our count of USABLE data so that...
// (a) we don't misallocate the output array, and
// (b) think that we miscalculated our data length
// just because of extraneous throw-away junk
int tempLen = data.length;
for( int ix=0; ix 255) || codes[ data[ix] ] < 0 )
--tempLen; // ignore non-valid chars and padding
}
// calculate required length:
// -- 3 bytes for every 4 valid base64 chars
// -- plus 2 bytes if there are 3 extra base64 chars,
// or plus 1 byte if there are 2 extra.
int len = (tempLen / 4) * 3;
if ((tempLen % 4) == 3) len += 2;
if ((tempLen % 4) == 2) len += 1;
byte[] out = new byte[len];
int shift = 0; // # of excess bits stored in accum
int accum = 0; // excess bits
int index = 0;
// we now go through the entire array (NOT using the 'tempLen' value)
for (int ix=0; ix255)? -1: codes[ data[ix] ];
if ( value >= 0 ) // skip over non-code
{
accum <<= 6; // bits shift up by 6 each time thru
shift += 6; // loop, with new bits being put in
accum |= value; // at the bottom.
if ( shift >= 8 ) // whenever there are 8 or more shifted in,
{
shift -= 8; // write them out (from the top, leaving any
out[index++] = // excess at the bottom for next iteration.
(byte) ((accum >> shift) & 0xff);
}
}
// we will also have skipped processing a padding null byte ('=') here;
// these are used ONLY for padding to an even length and do not legally
// occur as encoded data. for this reason we can ignore the fact that
// no index++ operation occurs in that special case: the out[] array is
// initialized to all-zero bytes to start with and that works to our
// advantage in this combination.
}
// if there is STILL something wrong we just have to throw up now!
if( index != out.length)
{
throw new Error("Miscalculated data length (wrote " + index + " instead of " + out.length + ")");
}
return out;
}
//
// code characters for values 0..63
//
static private char[] alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
.toCharArray();
//
// lookup table for converting base64 characters to value in range 0..63
//
static private byte[] codes = new byte[256];
static {
for (int i=0; i<256; i++) codes[i] = -1;
for (int i = 'A'; i <= 'Z'; i++) codes[i] = (byte)( i - 'A');
for (int i = 'a'; i <= 'z'; i++) codes[i] = (byte)(26 + i - 'a');
for (int i = '0'; i <= '9'; i++) codes[i] = (byte)(52 + i - '0');
codes['+'] = 62;
codes['/'] = 63;
}
}
lib/jas/src/jas/CP.java 100644 0 0 1253 10070636274 12247 0 ustar 0 0 /**
* this is an abstraction to contain all the CPE items
* that can be created.
*
* @see AsciiCP
* @see ClassCP
* @see NameTypeCP
* @see FieldCP
* @see InterfaceCP
* @see MethodCP
* @see IntegerCP
* @see LongCP
* @see FloatCP
* @see DoubleCP
* @see StringCP
*
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
// one class to ring them all...
import java.io.*;
public abstract class CP
{
String uniq;
String getUniq() { return uniq; }
abstract void resolve(ClassEnv e);
abstract void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError;
}
lib/jas/src/jas/CatchEntry.java 100644 0 0 2600 10070636274 14006 0 ustar 0 0 /**
* This class
* is used to build up entries in a catch table.
* @see Catchtable
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
public class CatchEntry
{
Label start_pc, end_pc, handler_pc;
CP catch_cpe;
/**
* Catch entries are created and then added to the Catchtable.
* @param start Label marking the beginning of the area
* where the catch table is active.
* @param end Label marking the end of the area where the
* table is active.
* @param handler Label marking the entrypoint into the
* exception handling routine.
* @param cat (usually a classCP) informing the VM to direct
* any exceptions of this (or its subclasses) to the handler.
* @see Catchtable
*/
public
CatchEntry(Label start, Label end, Label handler, CP cat)
{
start_pc = start;
end_pc = end;
handler_pc = handler;
catch_cpe = cat;
}
void resolve(ClassEnv e)
{ if (catch_cpe != null) e.addCPItem(catch_cpe); }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
start_pc.writeOffset(ce, null, out);
end_pc.writeOffset(ce, null, out);
handler_pc.writeOffset(ce, null, out);
if (catch_cpe != null)
{ out.writeShort(e.getCPIndex(catch_cpe)); }
else
{ out.writeShort(0); }
}
}
lib/jas/src/jas/Catchtable.java 100644 0 0 3147 10070636274 14003 0 ustar 0 0 /**
* This is used to make a table of catch handlers for a method.
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class Catchtable
{
Vector entries;
public Catchtable() { entries = new Vector(); }
/**
* add an entry to the catch table
*/
public void addEntry(CatchEntry entry) { entries.addElement(entry); }
/**
* add an entry to the catch table
* @param start Label marking the beginning of the area
* where the catch table is active.
* @param end Label marking the end of the area where the
* table is active.
* @param handler Label marking the entrypoint into the
* exception handling routine.
* @param cat (usually a classCP) informing the VM to direct
* any exceptions of this (or its subclasses) to the handler.
*/
public void
addEntry(Label start, Label end, Label handler, CP cat)
{ addEntry(new CatchEntry(start, end, handler, cat)); }
void resolve(ClassEnv e)
{
for (Enumeration en=entries.elements(); en.hasMoreElements(); )
{
CatchEntry ce = (CatchEntry)(en.nextElement());
ce.resolve(e);
}
}
int size()
{ return (8*entries.size()); } // each entry is 8 bytes
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(entries.size());
for (Enumeration en = entries.elements(); en.hasMoreElements();)
{
CatchEntry entry = (CatchEntry)(en.nextElement());
entry.write(e, ce, out);
}
}
}
lib/jas/src/jas/ClassCP.java 100644 0 0 1217 10070636274 13235 0 ustar 0 0 /**
* This is used to create a Class constant pool item
*
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
public class ClassCP extends CP implements RuntimeConstants
{
AsciiCP name;
/**
* @param name Name of the class
*/
public ClassCP(String name)
{
uniq = ("CLASS: #$%^#$" + name).intern();
this.name = new AsciiCP(name);
}
void resolve(ClassEnv e)
{ e.addCPItem(name); }
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
out.writeByte(CONSTANT_CLASS);
out.writeShort(e.getCPIndex(name));
}
}
lib/jas/src/jas/ClassElemValPair.java 100644 0 0 1662 10240435426 15073 0 ustar 0 0 /**
* ElemValPairs are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class ClassElemValPair extends ElemValPair {
AsciiCP cval;
void resolve(ClassEnv e){
super.resolve(e);
e.addCPItem(cval);
}
/**
* Note: An annotation attr is associated with a class,
* method or field so you need to create a new VisibilityAnnotationAttr for
*/
public ClassElemValPair(String name, char kind, String cval) { //
super(name, kind);
this.cval = new AsciiCP(cval);
}
int size(){
return super.size() + 2;
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
super.write(e, out);
out.writeShort(e.getCPIndex(cval));
}
}
lib/jas/src/jas/ClassEnv.java 100644 0 0 27054 11025352105 13477 0 ustar 0 0
package jas;
import java.io.*;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector;
import java.util.Iterator;
/**
* This is the place where all information about the class to
* be created resides.
*
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
public class ClassEnv implements RuntimeConstants
{
int magic;
short version_lo, version_hi;
CP this_class, super_class;
short class_access;
Hashtable cpe, cpe_index;
Vector interfaces;
Vector vars;
Vector methods;
SourceAttr source;
Vector generic;
boolean hasSuperClass;
InnerClassAttr inner_class_attr;
boolean classSynth;
SyntheticAttr synthAttr;
DeprecatedAttr deprAttr = null;
SignatureAttr sigAttr = null;
VisibilityAnnotationAttr visAnnotAttr = null;
VisibilityAnnotationAttr invisAnnotAttr = null;
EnclMethAttr encl_meth_attr;
boolean highVersion = false;
public ClassEnv()
{
// Fill in reasonable defaults
magic = JAVA_MAGIC;
version_lo = (short) JAVA_MINOR_VERSION;
version_hi = (short) JAVA_VERSION;
// Initialize bags
cpe = new Hashtable();
cpe_index = null;
interfaces = new Vector();
vars = new Vector();
methods = new Vector();
generic = new Vector();
}
public void setHighVersion(boolean b){
highVersion = b;
//System.out.println("setting high version number");
version_lo = (short) JAVA_MINOR_HIGH_VERSION;
version_hi = (short) JAVA_HIGH_VERSION;
}
/**
* Define this class to have this name.
* @param name CPE representing name for class. (This is usually
* a ClassCP)
*/
public void setClass(CP name)
{ this_class = name; addCPItem(name); }
/**
* Define this class to have no superclass. Should only ever
* be used for java.lang.Object
*/
public void setNoSuperClass()
{
hasSuperClass = false;
}
/**
* Define this class to have this superclass
* @param name CPE representing name for class. (This is usually
* a ClassCP)
*/
public void setSuperClass(CP name)
{
hasSuperClass = true;
super_class = name;
addCPItem(name);
}
/**
* Set the class access for this class. Constants understood
* by this are present along with the java Beta distribution.
* @param access number representing access permissions for
* the entire class.
* @see RuntimeConstants
*/
public void setClassAccess(short access)
{ class_access = access; }
/**
* Add this CP to the list of interfaces supposedly implemented by
* this class. Note that the CP ought to be a ClassCP to make
* sense to the VM.
*/
public void addInterface(CP ifc)
{
addCPItem(ifc);
interfaces.addElement(ifc);
}
/**
* Add this to the list of interfaces supposedly implemented
* by this class. Note that each CP is usually a ClassCP.
* @param ilist An array of CP items representing the
* interfaces implemented by this class.
*/
public void addInterface(CP ilist[])
{
for (int i=0; i 32K become negative and then not made wide
/* short */ int getCPIndex(CP cp)
throws jasError
{
if (cpe_index == null) {
throw new jasError("Internal error: CPE index has not been generated");
}
//System.out.println("cp uniq: "+cp.getUniq());
//System.out.println("cpe_index: "+cpe_index);
Integer idx = (Integer)(cpe_index.get(cp.getUniq()));
// LJH -----------------------------
//System.out.println("Getting idx " + idx);
if (idx == null)
throw new jasError("Item " + cp + " not in the class");
return (idx.intValue());
}
}
lib/jas/src/jas/CodeAttr.java 100644 0 0 16267 10242732000 13466 0 ustar 0 0 // CHANGES,
// Instead of calling soot.tagkits.JasminAttribute.decode,
// jas has its own CodeAttributeDecode class which performs
// the same functionality. It will remove the dependency to
// soot package. However, the decode method should be changed
// according to the format of CodeAttribute if the format is
// changed in the future.
// Feng Qian
// Jan 25, 2001
/**
* CodeAttr's are used as a bag to hold lists of instructions
* until it is time to put them into a Class.
* @see ClassEnv#addMethod
* @author $Author: olhota $
* @version $Revision: 1.2 $
*/
package jas;
import java.io.*;
import java.util.*;
public class CodeAttr
{
static CP attr = new AsciiCP("Code");
short stack_size, num_locals;
int code_size;
Vector insns;
Hashtable insn_pc;
Catchtable ctb;
LineTableAttr ltab;
LocalVarTableAttr lvar;
Vector generic;
Vector sootAttrNames = new Vector();
Vector sootAttrValues = new Vector();
Hashtable labels;
/**
* Create a new bag. Add instructions with the addInsn() method,
* set the catch table with the setCatchTable() method.
* @see Insn
* @see Catchtable
* @see ClassEnv#addMethod
*/
public CodeAttr()
{
this.stack_size = 1;
this.num_locals = 1;
this.ctb = null;
this.insns = new Vector();
generic = new Vector();
}
/**
* Set the catchtable for this code
*/
public void setCatchtable(Catchtable ctb)
{ this.ctb = ctb; }
/**
* Set the line number table for this method
*/
public void setLineTable(LineTableAttr ltab)
{ this.ltab = ltab; }
/**
* Set the local variable information for this method
*/
public void setLocalVarTable(LocalVarTableAttr lvar)
{ this.lvar = lvar; }
/**
* Add a generic attribute to the method. A generic attribute
* contains a stream of uninterpreted bytes which is ignored by
* the VM (as long as its name doesn't conflict with other names
* for attributes that are understood by the VM)
*/
public void addGenericAttr(GenericAttr g)
{ generic.addElement(g); }
public void addSootCodeAttr(String name, String value)
{
sootAttrNames.addElement(name);
sootAttrValues.addElement(value);
}
Label getLabel(String name) {
Label lab = (Label)labels.get(name);
if (lab == null) {
lab = new Label(name);
labels.put(name, lab);
}
return lab;
}
public void setLabelTable(Hashtable labelTable)
{
labels = labelTable;
}
private int processSootAttributes() {
Hashtable labelToPc = new Hashtable();
int totalSize = 0;
Enumeration enumeration = sootAttrValues.elements();
Enumeration nameEnum = sootAttrNames.elements();
while(enumeration.hasMoreElements()) {
String attrValue = (String) enumeration.nextElement();
String attrName = (String) nameEnum.nextElement();
boolean isLabel = false;//xx what if it starts with %
StringTokenizer st = new StringTokenizer(attrValue, "%", true);
while(st.hasMoreTokens()) {
String token = (String) st.nextElement();
if( token.equals( "%" ) ) {
isLabel = !isLabel;
continue;
}
if(isLabel) {
Integer i = (Integer) labelToPc.get(token);
try {
if(i == null)
labelToPc.put(token, new Integer( getPc(getLabel(token))));
} catch(jas.jasError e) {throw new RuntimeException(e.toString());}
}
}
byte[] data = CodeAttributeDecoder.decode(attrValue, labelToPc);
GenericAttr ga = new GenericAttr(attrName, data);
totalSize += ga.size();
addGenericAttr(ga);
}
sootAttrNames.removeAllElements();
sootAttrValues.removeAllElements();
return totalSize;
}
/**
* Append a new Insn to this code. Insn's are sequentially
* stored, in the order in which this method is called. You
* can't reorder code fragments after you've added it here.
*/
public void addInsn(Insn insn)
{ insns.addElement(insn); }
public void setStackSize(short stack_size)
{ this.stack_size = stack_size; }
public void setVarSize(short num_vars)
{ num_locals = num_vars; }
void resolve(ClassEnv e)
{
// propagate this resolution to
// the insns and catch table, so
// that any CP's referenced by them
// also get added.
e.addCPItem(attr);
for (Enumeration en = insns.elements(); en.hasMoreElements();)
{
Insn i = (Insn)(en.nextElement());
i.resolve(e);
}
if (ctb != null) ctb.resolve(e);
if (ltab != null) ltab.resolve(e);
if (lvar != null) lvar.resolve(e);
for (Enumeration gen = generic.elements(); gen.hasMoreElements();)
{
GenericAttr gattr = (GenericAttr)gen.nextElement();
gattr.resolve(e);
}
}
public int getPc(Insn i)
throws jasError
{
if (insn_pc == null){
throw new jasError("Internal error, insn_pc has not been initialized");
}
Integer tmp;
if (i instanceof Label)
{
tmp = (Integer)(insn_pc.get(((Label)i).id));
}
else
{
tmp = (Integer)(insn_pc.get(i));
}
if (tmp == null)
throw new jasError(i + " has not been added to the code");
return tmp.intValue();
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
// First, resolve all labels and
// compute total size
int code_size = 0;
insn_pc = new Hashtable();
for (Enumeration en = insns.elements(); en.hasMoreElements();)
{
Insn now = (Insn)(en.nextElement());
if (now instanceof Label)
{
insn_pc.put(((Label)now).id, new Integer(code_size));
}
else
{ insn_pc.put(now, new Integer(code_size)); }
code_size += now.size(e, this);
}
int total_size = code_size;
if (ctb != null) total_size += ctb.size();
if (ltab != null) total_size += ltab.size();
if (lvar != null) total_size += lvar.size();
for (Enumeration gen = generic.elements(); gen.hasMoreElements();)
{
GenericAttr gattr = (GenericAttr)(gen.nextElement());
total_size += gattr.size();
}
total_size += processSootAttributes();
// extra headers
total_size += 12;
out.writeShort(e.getCPIndex(attr));
out.writeInt(total_size);
out.writeShort(stack_size);
out.writeShort(num_locals);
out.writeInt(code_size);
for (Enumeration en = insns.elements(); en.hasMoreElements();)
{
Insn now = (Insn)(en.nextElement());
now.write(e, this, out);
}
if (ctb != null)
{ ctb.write(e, this, out); }
else
{ out.writeShort(0); }
short extra = 0;
if (ltab != null) extra++;
if (lvar != null) extra++;
extra += generic.size();
out.writeShort(extra);
if (ltab != null)
{ ltab.write(e, this, out); }
if (lvar != null)
{ lvar.write(e, this, out); }
for (Enumeration gen = generic.elements(); gen.hasMoreElements();)
{
GenericAttr gattr = (GenericAttr)gen.nextElement();
gattr.write(e, out);
}
}
public String toString()
{ return ("<#code-attr>"); }
}
lib/jas/src/jas/CodeAttributeDecoder.java 100644 0 0 6744 10070637625 16004 0 ustar 0 0 // CHANGES
// This is a customized copy of soot.tagkits.JasminAttribute class.
// It decodes the CodeAttribute format.
// Read comments on CodeAttr.java for more information.
// Feng Qian
// Jan 25, 2001
/* Soot - a J*va Optimization Framework
* Copyright (C) 2000 Patrice Pominville and Feng Qian
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the Sable Research Group and others 1997-1999.
* See the 'credits' file distributed with Soot for the complete list of
* contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
*/
package jas;
import java.util.*;
import java.io.*;
/**
* This class must be extended by Attributes that can
* be emitted in Jasmin. The attributes must format their data
* in Base64 and if Unit references they may contain must be emitted as
* labels embedded and
* escaped in the attribute's Base64 data stream at the location where the value
* of their pc is to occur. For example:
aload_1
iload_2
label2:
iaload
label3:
iastore
iinc 2 1
label0:
iload_2
aload_0
arraylength
label4:
if_icmplt label1
return
.code_attribute ArrayCheckAttribute "%label2%Aw==%label3%Ag==%label4%Ag=="
*
*/
class CodeAttributeDecoder
{
public static byte[] decode(String attr, Hashtable labelToPc)
{
List attributeHunks = new LinkedList();
int attributeSize = 0;
int tableSize = 0;
StringTokenizer st = new StringTokenizer(attr, "%", true);
boolean isLabel = false;
byte[] pcArray;
while(st.hasMoreTokens()) {
String token = st.nextToken();
if( token.equals( "%" ) ) {
isLabel = !isLabel;
continue;
}
if(isLabel) {
Integer pc = (Integer) labelToPc.get(token);
if(pc == null)
throw new RuntimeException("PC is null, the token is "+token);
int pcvalue = pc.intValue();
if(pcvalue > 65535)
throw new RuntimeException("PC great than 65535, the token is "+token+" : " +pcvalue);
pcArray = new byte[2];
pcArray[1] = (byte)(pcvalue&0x0FF);
pcArray[0] = (byte)((pcvalue>>8)&0x0FF);
attributeHunks.add(pcArray);
attributeSize += 2;
tableSize++;
} else {
byte[] hunk = Base64.decode(token.toCharArray());
attributeSize += hunk.length;
attributeHunks.add(hunk);
}
}
attributeSize += 2;
byte[] attributeValue = new byte[attributeSize];
attributeValue[0] = (byte)((tableSize>>8)&0x0FF);
attributeValue[1] = (byte)(tableSize&0x0FF);
int index = 2;
Iterator it = attributeHunks.iterator();
while(it.hasNext()) {
byte[] hunk = (byte[]) it.next();
for(int i = 0; i < hunk.length; i++) {
attributeValue[index++] = hunk[i];
}
}
if(index != (attributeSize))
throw new RuntimeException("Index does not euqal to attrubute size :"+index+" -- "+attributeSize);
return attributeValue;
}
}
lib/jas/src/jas/ConstAttr.java 100644 0 0 1601 10070636274 13663 0 ustar 0 0 /**
* This is typically used to represent a constant value for
* a field entry (as in static final int foo = 20).
*
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
public class ConstAttr
{
static CP attr = new AsciiCP("ConstantValue");
CP val;
/**
* Create a new constant attribute whose constant value
* is picked up from constant pool with the given entry.
* @param val Constant pool item whose value is associated
* with the constant value attribute
*/
public ConstAttr(CP val)
{ this.val = val; }
void resolve(ClassEnv e)
{
e.addCPItem(val);
e.addCPItem(attr);
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(attr));
out.writeInt(2);
out.writeShort(e.getCPIndex(val));
}
}
lib/jas/src/jas/DeprecatedAttr.java 100644 0 0 1074 10240435426 14634 0 ustar 0 0 /**
* This is used to represent the deprecated attr
*
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
public class DeprecatedAttr
{
static CP attr = new AsciiCP("Deprecated");
/**
* Create a new deprecated attribute
*/
public DeprecatedAttr()
{ }
void resolve(ClassEnv e)
{
e.addCPItem(attr);
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(attr));
out.writeInt(0);
}
}
lib/jas/src/jas/DoubleCP.java 100644 0 0 1114 10070636274 13376 0 ustar 0 0 package jas;
import java.io.*;
/**
* Wrap an Double constant reference with this CPE.
*
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
public class DoubleCP extends CP implements RuntimeConstants
{
double val;
/**
* @param n Value for Double constant
*/
public DoubleCP(double n)
{
uniq = ("Double: @#$" + n).intern();
val = n;
}
void resolve(ClassEnv e) { return; }
void write(ClassEnv e, DataOutputStream out)
throws IOException
{
out.writeByte(CONSTANT_DOUBLE);
out.writeDouble(val);
}
}
lib/jas/src/jas/DoubleElemValPair.java 100644 0 0 1657 10240435426 15244 0 ustar 0 0 /**
* ElemValPairs are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class DoubleElemValPair extends ElemValPair{
DoubleCP val;
void resolve(ClassEnv e){
super.resolve(e);
e.addCPItem(val);
}
/**
* Note: An annotation attr is associated with a class,
* method or field so you need to create a new VisibilityAnnotationAttr for
*/
public DoubleElemValPair(String name, char kind, double val) { //
super(name, kind);
this.val = new DoubleCP(val);
}
int size(){
return super.size() + 2;
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
super.write(e, out);
out.writeShort(e.getCPIndex(val));
}
}
lib/jas/src/jas/ElemValPair.java 100644 0 0 2030 10240435426 14073 0 ustar 0 0 /**
* ElemValPairs are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class ElemValPair {
AsciiCP name;
byte kind;
boolean noName;
void resolve(ClassEnv e){
e.addCPItem(name);
}
/**
* Note: An annotation attr is associated with a class,
* method or field so you need to create a new VisibilityAnnotationAttr for
*/
public ElemValPair(String name, char kind) { //
this.name = new AsciiCP(name);
this.kind = (byte)kind;
}
int size(){
if (noName) return 1;
return 3;
}
public void setNoName(){
noName = true;
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
if (!noName){
out.writeShort(e.getCPIndex(name));
}
out.writeByte(kind);
}
}
lib/jas/src/jas/EnclMethAttr.java 100644 0 0 2162 10240435426 14272 0 ustar 0 0 /**
* EnclMeth attributes are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class EnclMethAttr {
static CP attr = new AsciiCP("EnclosingMethod");
ClassCP cls;
NameTypeCP meth;
void resolve(ClassEnv e){
e.addCPItem(attr);
e.addCPItem(cls);
e.addCPItem(meth);
}
/**
* Note: An enclosing method attr is associated with a class,
* so you need to create a new EnclMethAttr for each anon or
* local class you create
*/
public EnclMethAttr(String a, String b, String c) { //
cls = new ClassCP(a);
meth = new NameTypeCP(b, c);
}
int size(){
return 4;
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(attr));
out.writeInt(4); // fixed length
out.writeShort(e.getCPIndex(cls));
out.writeShort(e.getCPIndex(meth));
}
}
lib/jas/src/jas/EnumElemValPair.java 100644 0 0 2101 10240435426 14717 0 ustar 0 0 /**
* ElemValPairs are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class EnumElemValPair extends ElemValPair {
AsciiCP tval;
AsciiCP cval;
void resolve(ClassEnv e){
super.resolve(e);
e.addCPItem(tval);
e.addCPItem(cval);
}
/**
* Note: An annotation attr is associated with a class,
* method or field so you need to create a new VisibilityAnnotationAttr for
*/
public EnumElemValPair(String name, char kind, String tval, String cval) { //
super(name, kind);
this.tval = new AsciiCP(tval);
this.cval = new AsciiCP(cval);
}
int size(){
return super.size() + 4;
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
super.write(e, out);
out.writeShort(e.getCPIndex(tval));
out.writeShort(e.getCPIndex(cval));
}
}
lib/jas/src/jas/ExceptAttr.java 100644 0 0 2123 10070636274 14025 0 ustar 0 0 /**
* This attribute is associated with a method, and indicates
* the set of exceptions (as classCP items) that can be thrown
* by the method.
*
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class ExceptAttr
{
static CP attr = new AsciiCP("Exceptions");
Vector cps;
public ExceptAttr() { cps = new Vector(); }
/**
* @param clazz Exception class to be added to attribute. This is
* typically a ClassCP
*/
public void addException(CP cp)
{ cps.addElement(cp); }
void resolve(ClassEnv e)
{
e.addCPItem(attr);
for (Enumeration en = cps.elements(); en.hasMoreElements();)
{ e.addCPItem((CP)(en.nextElement())); }
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(attr));
out.writeInt(cps.size()*2 + 2);
out.writeShort(cps.size());
for (Enumeration en = cps.elements(); en.hasMoreElements();)
{ out.writeShort(e.getCPIndex((CP)(en.nextElement()))); }
}
}
lib/jas/src/jas/FieldCP.java 100644 0 0 2306 10070636274 13213 0 ustar 0 0 /**
* FieldCP's are used to refer to a field in a particular
* class.
*
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
public class FieldCP extends CP implements RuntimeConstants
{
ClassCP clazz;
NameTypeCP nt;
/**
* FieldCP's are created by specifying the class to which the
* field belongs, the name of the symbol, and its signature.
* For instance, to refer to the field out in
* System.out use
* new FieldCP("java/lang/System", "out", "Ljava/io/PrintStream;")
*
* @param clazz Name of class
* @param name Name of symbol
* @param sig Signature for symbol
*/
public FieldCP(String clazz, String name, String sig)
{
uniq = (clazz + "&%$#&" + name + "*()#$" + sig).intern();
this.clazz = new ClassCP(clazz);
this.nt = new NameTypeCP(name, sig);
}
void resolve(ClassEnv e)
{
e.addCPItem(clazz);
e.addCPItem(nt);
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
out.writeByte(CONSTANT_FIELD);
out.writeShort(e.getCPIndex(clazz));
out.writeShort(e.getCPIndex(nt));
}
}
lib/jas/src/jas/FloatCP.java 100644 0 0 1103 10070636274 13227 0 ustar 0 0 package jas;
import java.io.*;
/**
* Wrap an Float constant reference with this CPE.
*
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
public class FloatCP extends CP implements RuntimeConstants
{
float val;
/**
* @param n Value for Float constant
*/
public FloatCP(float n)
{
uniq = ("Float: @#$" + n).intern();
val = n;
}
void resolve(ClassEnv e) { return; }
void write(ClassEnv e, DataOutputStream out)
throws IOException
{
out.writeByte(CONSTANT_FLOAT);
out.writeFloat(val);
}
}
lib/jas/src/jas/FloatElemValPair.java 100644 0 0 1656 10240435426 15076 0 ustar 0 0 /**
* ElemValPairs are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class FloatElemValPair extends ElemValPair{
FloatCP val;
void resolve(ClassEnv e){
super.resolve(e);
e.addCPItem(val);
}
/**
* Note: An annotation attr is associated with a class,
* method or field so you need to create a new VisibilityAnnotationAttr for
*/
public FloatElemValPair(String name, char kind, float val) { //
super(name, kind);
this.val = new FloatCP(val);
}
int size(){
return super.size() + 2;
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
super.write(e, out);
out.writeShort(e.getCPIndex(val));
}
}
lib/jas/src/jas/GenericAttr.java 100644 0 0 2572 10070636274 14161 0 ustar 0 0 /**
* This is an opaque attribute that lets you add an uninterpreted
* stream of bytes into an attribute in a class file. This can be
* used (for instance) to embed versioning or signatures into the
* class file or method.
*
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
public class GenericAttr
{
CP attr_name;
byte data[];
/**
* Make up a new attribute
* @param name Name to be associated with the attribute
* @data stream of bytes to be placed with the attribute
* @see ClassEnv#addGenericAttr
* @see CodeAttr#addGenericAttr
*/
public GenericAttr(String name, byte data[])
{
attr_name = new AsciiCP(name);
this.data = data;
}
/**
* Make up a new attribute
* @param name CP to be defined as the name of the attribute
* @data stream of bytes to be placed with the attribute
* @see ClassEnv#addGenericAttr
* @see CodeAttr#addGenericAttr
*/
public GenericAttr(CP name, byte data[])
{
attr_name = name;
this.data = data;
}
void resolve(ClassEnv e)
{ e.addCPItem(attr_name); }
int size()
{ return (2 + 4 + data.length); }
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(attr_name));
out.writeInt(data.length);
out.write(data);
}
}
lib/jas/src/jas/IincInsn.java 100644 0 0 1737 10070636274 13466 0 ustar 0 0 /**
* Some instructions are perniticky enough that its simpler
* to write them separately instead of smushing them with
* all the rest. the iinc instruction is one of them.
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
public class IincInsn extends Insn implements RuntimeConstants
{
/**
* @param vindex Index of variable to be incremented.
* @param increment value to be added to the variable.
*
* A wide prefix is automatically added if either the
* vindex exceeds 256, or the increment value lies
* outside the range [-128, 127]
*
* The VM spec is unclear on how the wide instruction is implemented,
* but the implementation makes both the constant and the
* variable index 16 bit values for the wide version of this instruction.
*/
public IincInsn(int vindex, int increment)
{
opc = opc_iinc;
operand = new IincOperand(vindex, increment);
}
}
lib/jas/src/jas/InnerClassAttr.java 100644 0 0 3442 10073526737 14650 0 ustar 0 0 /**
* InnerClass attributes are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class InnerClassAttr
{
static CP attr = new AsciiCP("InnerClasses");
short attr_length = 0;
short num = 0;
ArrayList list;
/**
* Note: An inner class attr is associated with a class, so you
* need to create a new InnerClassAttr for each class you create
*/
public InnerClassAttr() { //
list = new ArrayList();
}
void resolve(ClassEnv e){
e.addCPItem(attr);
if (list != null){
Iterator it = list.iterator();
while (it.hasNext()){
((InnerClassSpecAttr)it.next()).resolve(e);
}
}
}
int size(){
return
(2 + // name_idx
4 + // attr_len
2 + // inner class len spec
8*(list.size())); // table
}
public void addInnerClassSpec(InnerClassSpecAttr attr){
list.add(attr);
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError {
out.writeShort(e.getCPIndex(attr));
//out.writeInt(size());
out.writeInt(2+8*list.size());
out.writeShort(list.size());
Iterator it = list.iterator();
while(it.hasNext()){
((InnerClassSpecAttr)it.next()).write(e, out);
}
/*for (Enumeration en = pc.elements(), ien = line.elements();
en.hasMoreElements();)
{
Label l = (Label)(en.nextElement());
Integer i = (Integer)(ien.nextElement());
l.writeOffset(ce, null, out);
out.writeShort((int) i.intValue());*/
}
}
lib/jas/src/jas/InnerClassSpecAttr.java 100644 0 0 4100 10073526737 15453 0 ustar 0 0 /**
* InnerClassSpec attributes are embedded into class files
* and used for further ???
* @author $Author: Jennifer Lhotak$
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class InnerClassSpecAttr {
String inner_class_name;
String outer_class_name;
String inner_name;
short access;
void resolve(ClassEnv e){
e.addCPItem(new ClassCP(inner_class_name));
if (!outer_class_name.equals("null")){
e.addCPItem(new ClassCP(outer_class_name));
}
if (!inner_name.equals("null")){
e.addCPItem(new AsciiCP(inner_name));
}
}
/**
* Note: An inner class attr is associated with a class, so you
* need to create a new InnerClassAttr for each class you create
*/
public InnerClassSpecAttr(String a, String b, String c, short d) { //
inner_class_name = a;
outer_class_name = b;
inner_name = c;
access = d;
}
int size(){
return 8;
}
void write(ClassEnv e, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(new ClassCP(inner_class_name)));
if (outer_class_name.equals("null")){
out.writeShort(0);
}
else {
out.writeShort(e.getCPIndex(new ClassCP(outer_class_name)));
}
if (inner_name.equals("null")){
out.writeShort(0);
}
else {
out.writeShort(e.getCPIndex(new AsciiCP(inner_name)));
}
out.writeShort(access);
/*out.writeShort(e.getCPIndex(attr));
out.writeInt(2 + 4*(pc.size()));
out.writeShort(pc.size());
for (Enumeration en = pc.elements(), ien = line.elements();
en.hasMoreElements();)
{
Label l = (Label)(en.nextElement());
Integer i = (Integer)(ien.nextElement());
l.writeOffset(ce, null, out);
out.writeShort((int) i.intValue());*/
}
}
lib/jas/src/jas/Insn.java 100644 0 0 13240 10240435426 12666 0 ustar 0 0 /**
* An Insn is a generic instruction that is added to a
* CodeAttr to build up the code for a method.
* @see CodeAttr
* @see RuntimeConstants
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class Insn implements RuntimeConstants
{
int opc;
InsnOperand operand;
// private constructor, for the
// "strange" opcodes
Insn() { return; }
/**
* Instructions with no arguments are built with
* this constructor.
*/
public Insn(int opc)
throws jasError
{
if (opcLengths[opc] == 1)
{ operand = null; this.opc = opc; return; }
throw new jasError
(opcNames[opc] + " cannot be used without more parameters");
}
/**
* Instructions that take a single numeric argument. These are
* opc_bipush,
* opc_sipush,
* opc_ret,
* opc_iload,
* opc_lload,
* opc_fload,
* opc_dload,
* opc_aload,
* opc_istore,
* opc_lstore,
* opc_fstore,
* opc_dstore,
* opc_astore,
* opc_newarray
*
* Note that an extra wide prefix is automatically added
* for the following instructions if the numeric argument
* is larger than 256. Also note that while the spec makes
* no mention of opc_ret as being a "wideable" opcode, thats
* how the VM is implemented.
*
* opc_ret:
* opc_iload:
* opc_lload:
* opc_fload:
* opc_dload:
* opc_aload:
* opc_istore:
* opc_lstore:
* opc_fstore:
* opc_dstore:
* opc_astore:
*
*/
public Insn(int opc, int val)
throws jasError
{
this.opc = opc;
switch (opc)
{
case opc_bipush: operand = new ByteOperand(val); break;
case opc_sipush: operand = new ShortOperand(val); break;
case opc_newarray:
operand = new UnsignedByteOperand(val);
break;
case opc_ret:
case opc_iload:
case opc_lload:
case opc_fload:
case opc_dload:
case opc_aload:
case opc_istore:
case opc_lstore:
case opc_fstore:
case opc_dstore:
case opc_astore:
operand = new UnsignedByteWideOperand(val);
break;
default:
throw new jasError
(opcNames[opc] + " does not take a numeric argument");
}
}
/**
* Instructions that take a Label as an argument. These are
* opc_jsr,
* opc_goto,
* opc_if_acmpne,
* opc_if_acmpeq,
* opc_if_icmpge,
* opc_if_icmple,
* opc_if_icmpgt,
* opc_if_icmplt,
* opc_if_icmpne,
* opc_if_icmpeq,
* opc_ifge,
* opc_ifgt,
* opc_ifne,
* opc_ifle,
* opc_iflt,
* opc_ifeq,
* opc_ifnull,
* opc_ifnonnull,
* opc_goto_w,
* opc_jsr_w
*/
public Insn(int opc, Label target)
throws jasError
{
this.opc = opc;
switch(opc)
{
case opc_jsr:
case opc_goto:
case opc_if_acmpne:
case opc_if_acmpeq:
case opc_if_icmpge:
case opc_if_icmple:
case opc_if_icmpgt:
case opc_if_icmplt:
case opc_if_icmpne:
case opc_if_icmpeq:
case opc_ifge:
case opc_ifgt:
case opc_ifne:
case opc_ifle:
case opc_iflt:
case opc_ifeq:
case opc_ifnull:
case opc_ifnonnull:
operand = new LabelOperand(target, this);
break;
case opc_goto_w:
case opc_jsr_w:
operand = new LabelOperand(target, this, true);
break;
default:
throw new jasError
(opcNames[opc] + " does not take a label as its argument");
}
}
/**
* This constructor is used for instructions that take a CP item
* as their argument. These are
* opc_anewarray,
* opc_ldc_w,
* opc_ldc2_w,
* opc_invokenonvirtual,
* opc_invokestatic,
* opc_invokevirtual,
* opc_new,
* opc_checkcast,
* opc_instanceof,
* opc_getstatic,
* opc_putstatic,
* opc_getfield,
* opc_putfield,
* opc_ldc
*/
public Insn(int opc, CP arg)
throws jasError
{
this.opc = opc;
switch(opc)
{
case opc_anewarray:
case opc_invokenonvirtual:
case opc_invokestatic:
case opc_invokevirtual:
case opc_new:
case opc_checkcast:
case opc_instanceof:
case opc_getstatic:
case opc_putstatic:
case opc_getfield:
case opc_putfield:
operand = new CPOperand(arg);
break;
case opc_ldc2_w:
case opc_ldc_w:
//System.out.println("ldc_w: arg: "+arg);
operand = new LdcOperand(this, arg);
break;
case opc_ldc:
operand = new LdcOperand(this, arg, false);
break;
default:
throw new jasError
(opcNames[opc] + " does not take a CP item as an argument");
}
}
// This allows the Insn a chance to
// add things to the global env if
// necessary. The CPInsnOperands
// use this to add the CP to the
// classEnv
void resolve(ClassEnv e)
{ if (operand != null) { operand.resolve(e); } }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
if (operand != null)
operand.writePrefix(e, ce, out);
out.writeByte((byte) opc);
if (operand != null)
operand.write(e, ce, out);
}
int size(ClassEnv e, CodeAttr ce)
throws jasError
{
if (operand == null) return 1;
return (1 + operand.size(e, ce));
}
}
lib/jas/src/jas/InsnOperand.java 100644 0 0 24436 10240435426 14210 0 ustar 0 0 // This is not visible outside the
// package. It is used to
// handle the various types
// of operands used by Insns.
package jas;
import java.io.*;
abstract class InsnOperand
{
abstract void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError;
abstract int size(ClassEnv e, CodeAttr code) throws jasError;
abstract void resolve(ClassEnv e);
void writePrefix(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{ return; }
}
// Used to implement targets of Insns
class LabelOperand extends InsnOperand
{
Label target;
Insn source;
boolean wide;
LabelOperand(Label l, Insn source)
{ target = l; this.source = source; this.wide = false; }
LabelOperand(Label l, Insn source, boolean wide)
{ target = l; this.source = source; this.wide = wide; }
int size(ClassEnv ce, CodeAttr code) { if (wide) return 4; else return 2; }
void resolve(ClassEnv e) { return; }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
if (wide) { target.writeWideOffset(ce, source, out); }
else { target.writeOffset(ce, source, out); } }
}
class UnsignedByteOperand extends InsnOperand
{
int val;
UnsignedByteOperand(int n) { val = n; }
int size(ClassEnv ce, CodeAttr code) { return 1; }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
if (val >= 256)
throw
new jasError("Operand is too large (" +val+ ") for this instruction");
out.writeByte((byte)(0xff & val));
}
void resolve(ClassEnv e) { return; }
}
// This (conditionally) adds a wide
// prefix if the value is larger than
// 256
class UnsignedByteWideOperand extends InsnOperand
implements RuntimeConstants
{
int val;
UnsignedByteWideOperand(int n) { val = n; }
int size(ClassEnv ce, CodeAttr code)
{
if (val >= 256) return 3;
return 1;
}
void writePrefix(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException
{
if (val > 255)
out.writeByte((byte)(opc_wide));
}
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException
{
if (val > 255)
out.writeShort((short)(0xffff & val));
else
out.writeByte((byte)(val & 0xff));
}
void resolve(ClassEnv e) { return; }
}
class ByteOperand extends InsnOperand
{
int val;
ByteOperand(int n) { val = n; }
int size(ClassEnv ce, CodeAttr code) { return 1; }
void resolve(ClassEnv e) { return; }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException
{ out.writeByte((byte)val); }
}
class IntegerOperand extends InsnOperand
{
int val;
IntegerOperand(int n) { val = n; }
int size(ClassEnv ce, CodeAttr code) { return 4; }
void resolve(ClassEnv e) { return; }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException
{ out.writeInt(val); }
}
class ShortOperand extends InsnOperand
{
int offset;
ShortOperand(int n) { offset = n; }
void resolve(ClassEnv e) { return; }
int size(ClassEnv ce, CodeAttr code) { return 2; }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException
{ out.writeShort((short)offset); }
}
class CPOperand extends InsnOperand
{
CP cpe;
boolean wide;
int size(ClassEnv ce, CodeAttr code) { if (wide) return 2; else return 1; }
CPOperand(CP cpe) { this.cpe = cpe; wide = true; }
CPOperand(CP cpe, boolean wide)
{ this.cpe = cpe; this.wide = wide; }
void resolve(ClassEnv e)
{ e.addCPItem(cpe); }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
int idx = e.getCPIndex(cpe);
if (wide)
{ out.writeShort((short) idx); }
else
{
if (idx > 255)
{ throw new jasError("exceeded size for small cpidx" + cpe); }
out.writeByte((byte) (0xff & (idx)));
}
}
}
// these are unique enough that
// they need a separate handler for their
// args
class LdcOperand extends InsnOperand implements RuntimeConstants
{
CP cpe;
Insn source;
boolean wide;
int size(ClassEnv ce, CodeAttr code) throws jasError
{
if (wide)
{ return 2; }
else
{
// Should we promote it?
int idx = ce.getCPIndex(cpe);
// LJH
// System.out.println("getting idx in size: " + idx);
if (idx > 255)
{
wide = true;
source.opc = opc_ldc_w;
return 2;
}
return 1;
}
}
LdcOperand(Insn s, CP cpe) { source = s; this.cpe = cpe; wide = true; }
LdcOperand(Insn s, CP cpe, boolean wide)
{ source = s; this.cpe = cpe; this.wide = wide; }
void resolve(ClassEnv e)
{ e.addCPItem(cpe);
if (cpe instanceof ClassCP){
e.setHighVersion(true);
}
}
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
int idx = e.getCPIndex(cpe);
// LJH
// System.out.println("Writing " + idx + " which as a short is " +
// ((short) idx) + " and is " + wide);
if (wide)
{ out.writeShort((short) idx); }
else
{
if (idx > 255)
{ throw new jasError("exceeded size for small cpidx" + cpe); }
out.writeByte((byte) (0xff & (idx)));
}
}
}
class InvokeinterfaceOperand extends InsnOperand
{
CP cpe;
int nargs;
InvokeinterfaceOperand(CP cpe, int nargs)
{ this.cpe = cpe; this.nargs = nargs; }
int size(ClassEnv ce, CodeAttr code) { return 4; }
void resolve(ClassEnv e)
{ e.addCPItem(cpe); }
void write (ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(cpe));
out.writeByte((byte) (0xff & nargs));
out.writeByte(0);
}
}
class IincOperand extends InsnOperand
implements RuntimeConstants
{
int vindex, constt;
IincOperand(int vindex, int constt)
{ this.vindex = vindex; this.constt = constt; }
int size(ClassEnv ce, CodeAttr code)
{
if ((vindex > 255) ||
(constt > 127) ||
(constt < -128))
return 5;
else
return 2;
}
void resolve(ClassEnv e) { return; }
void writePrefix(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException
{
if ((vindex > 255) ||
(constt > 127) ||
(constt < -128))
out.writeByte((byte)opc_wide);
}
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException
{
if ((vindex > 255) ||
(constt > 127) ||
(constt < -128))
{
out.writeShort((short)(0xffff & vindex));
out.writeShort((short)(0xffff & constt));
}
else
{
out.writeByte((byte) (0xff & vindex));
out.writeByte((byte) (0xff & constt));
}
}
}
class MultiarrayOperand extends InsnOperand
{
CP cpe;
int sz;
MultiarrayOperand(CP cpe, int sz)
{ this.cpe = cpe; this.sz = sz; }
void resolve(ClassEnv e) { e.addCPItem(cpe); }
int size(ClassEnv ce, CodeAttr code) { return 3; }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(cpe));
out.writeByte((byte)(0xff & sz));
}
}
class LookupswitchOperand extends InsnOperand
{
Label dflt;
Insn source;
int match[];
Label jmp[];
LookupswitchOperand(Insn s, Label def, int m[], Label j[])
{ dflt = def; jmp = j; match = m; source = s; }
void resolve (ClassEnv e) { return; }
int size(ClassEnv ce, CodeAttr code) throws jasError
{
int sz = 8; // 4 + 4 + padding + jumptable
int source_pc = code.getPc(source);
if (((source_pc+1) % 4) != 0)
{
// need padding
sz += (4 - ((source_pc+1) % 4));
}
if (jmp != null)
{ sz += 8*(jmp.length); }
return sz;
}
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
int pad;
int source_pc = ce.getPc(source);
if (((source_pc+1) % 4) != 0)
{ // need padding
pad = (4 - ((source_pc+1) % 4));
for (int x=0; x