Source code: Assembler/x86/ExternalReference.java
1 // ExternalReference.java, created Tue Feb 27 2:59:43 2001 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 Assembler.x86;
5
6 import java.io.DataOutput;
7 import java.io.IOException;
8
9 import Memory.HeapAddress;
10 import Util.Assert;
11
12 /**
13 * ExternalReference
14 *
15 * @author John Whaley <jwhaley@alum.mit.edu>
16 * @version $Id: ExternalReference.java,v 1.12 2003/05/12 10:04:52 joewhaley Exp $
17 */
18 public class ExternalReference extends Reloc {
19
20 private HeapAddress heap_from;
21 private int symbol_ndx;
22 private String external_name;
23
24 /** Creates new ExternalReference */
25 public ExternalReference(HeapAddress heap_from, String external_name) {
26 this.heap_from = heap_from;
27 this.external_name = external_name;
28 }
29
30 public void setSymbolIndex(int ndx) { Assert._assert(ndx != 0); this.symbol_ndx = ndx; }
31
32 public void dumpCOFF(DataOutput out) throws IOException {
33 Assert._assert(symbol_ndx != 0);
34 out.writeInt(heap_from.to32BitValue()); // r_vaddr
35 out.writeInt(symbol_ndx); // r_symndx
36 out.writeChar(Reloc.RELOC_ADDR32); // r_type
37 }
38
39 public HeapAddress getAddress() { return heap_from; }
40 public int getSymbolIndex() { return symbol_ndx; }
41 public String getName() { return external_name; }
42
43 public void patch() { Assert.UNREACHABLE(); }
44
45 public String toString() {
46 return "from heap:"+heap_from.stringRep()+" to external:"+external_name+" (symndx "+symbol_ndx+")";
47 }
48
49 }