Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: Bootstrap/BootstrapCodeAddress.java


1   // BootstrapCodeAddress.java, created Wed Sep 18  1:22:47 2002 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package Bootstrap;
5   
6   import Clazz.jq_Class;
7   import Memory.Address;
8   import Memory.CodeAddress;
9   import Util.Strings;
10  
11  /**
12   * BootstrapCodeAddress
13   *
14   * @author  John Whaley <jwhaley@alum.mit.edu>
15   * @version $Id: BootstrapCodeAddress.java,v 1.6 2003/03/05 08:41:34 joewhaley Exp $
16   */
17  public class BootstrapCodeAddress extends CodeAddress implements BootstrapAddress {
18  
19      public static BootstrapCodeAddressFactory FACTORY = new BootstrapCodeAddressFactory(BootstrapCodeAllocator.DEFAULT);
20      
21      public static class BootstrapCodeAddressFactory extends CodeAddressFactory {
22          final BootstrapCodeAllocator bca;
23          public BootstrapCodeAddressFactory(BootstrapCodeAllocator bca) {
24              this.bca = bca;
25          }
26          public int size() { return 4; }
27          public CodeAddress getNull() { return NULL; }
28          public static final BootstrapCodeAddress NULL = new BootstrapCodeAddress(0);
29      }
30      
31      public final int value;
32      
33      public BootstrapCodeAddress(int value) { this.value = value; }
34      
35      public Address peek() { return FACTORY.bca.peek(this); }
36      public byte    peek1() { return FACTORY.bca.peek1(this); }
37      public short   peek2() { return FACTORY.bca.peek2(this); }
38      public int     peek4() { return FACTORY.bca.peek4(this); }
39      public long    peek8() { return FACTORY.bca.peek8(this); }
40      
41      public void poke(Address v) { FACTORY.bca.poke(this, v); }
42      public void poke1(byte v) { FACTORY.bca.poke1(this, v); }
43      public void poke2(short v) { FACTORY.bca.poke2(this, v); }
44      public void poke4(int v) { FACTORY.bca.poke4(this, v); }
45      public void poke8(long v) { FACTORY.bca.poke8(this, v); }
46      
47      public Address offset(int offset) { return new BootstrapCodeAddress(value+offset); }
48      public Address align(int shift) {
49          int mask = (1 << shift) - 1;
50          return new BootstrapCodeAddress((value+mask)&~mask);
51      }
52      public int difference(Address v) { return this.value - v.to32BitValue(); }
53      public boolean isNull() { return value == 0; }
54      
55      public int to32BitValue() { return value; }
56      public String stringRep() { return Strings.hex8(value); }
57      
58      public static final jq_Class _class;
59      static {
60          _class = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("LBootstrap/BootstrapCodeAddress;");
61      }
62  }