01: /*
02: * @(#)CVMInitInfo.java 1.10 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27: package runtime;
28:
29: class CVMInitInfo {
30: /*
31: * This class puts together a list of "initialization records".
32: *
33: * This takes two possible forms:
34: *
35: * A triple of:
36: * from-address
37: * to-address
38: * byte count
39: *
40: * Or a list of:
41: * pointers to ROMizer generated data structs.
42: *
43: * This data is interpreted by the startup code.
44: */
45: String fromAddress;
46: String toAddress;
47: String byteCount;
48: CVMInitInfo next;
49:
50: CVMInitInfo(String f, String t, String c, CVMInitInfo n) {
51: fromAddress = f;
52: toAddress = t;
53: byteCount = c;
54: next = n;
55: }
56:
57: //
58: // The single address version
59: //
60: CVMInitInfo(String f, CVMInitInfo n) {
61: fromAddress = f;
62: next = n;
63: }
64:
65: CVMInitInfo() {
66: }
67:
68: CVMInitInfo initList = null;
69:
70: public void addInfo(String f, String t, String c) {
71: initList = new CVMInitInfo(f, t, c, initList);
72: }
73:
74: public void addInfo(String f) {
75: initList = new CVMInitInfo(f, initList);
76: }
77:
78: public void write(CCodeWriter out, String typename, String dataname) {
79: out.println("const " + typename + " " + dataname + "[] = {");
80: if (initList.toAddress == null && initList.byteCount == null) {
81: // The single address variant
82: for (CVMInitInfo p = initList; p != null; p = p.next) {
83: out.println(" " + p.fromAddress + ",");
84: }
85: out.println(" NULL"); /* terminator */
86: } else {
87: // The triple variant
88: for (CVMInitInfo p = initList; p != null; p = p.next) {
89: out.println(" { " + p.fromAddress + ", "
90: + p.toAddress + ", " + p.byteCount + " },");
91: }
92: out.println(" {NULL, NULL, 0}"); /* terminator */
93: }
94:
95: out.println("};");
96: }
97: }
|