Week 8/44

Exercises on virtual machines

  • Translate by hand the following class into Java Virtual Machine code (can you beat joosc -O?):
    public class Cons {
      protected Object first;
      protected Cons rest;
     
      public Cons(Object f, Cons r) 
      { super();
        first = f; rest = r;
      }
     
      public void setFirst(Object newfirst) 
      { first = newfirst; }
     
      public Object getFirst() 
      { return first; }
     
      public Cons getRest()
      { return rest; }
     
      public boolean member(Object item)
      { if (first.equals(item))
           return true;
        else if (rest==null)
           return false;
        else
           return rest.member(item);
      }
    }
    

Maintained by Laurie J. Hendren. Last modified Fri Sep 17 07:25:47 EDT 2004. [HOME]
Compiler research projects: Soot, a Java analysis, optimization and transformation toolkit ---- abc, an AspectJ compiler.