System.out.print("\n   void setLinkage()\n"); System.out.print("      {\n"); for (int i = fields.length; --i >= 0;) { VM_Field field = fields[i]; if (field.isStatic()) continue;  String fieldName = field.getName().toString(); int suffixIndex = fieldName.indexOf("IP"); if (suffixIndex > 0) {  String functionName = fieldName.substring(0, suffixIndex); if (VM.BuildForAix)   System.out.print("      " + fieldName + " = ((AixLinkageLayout *)&" + functionName + ")->ip;\n"); else   System.out.print("      " + fieldName + " = (int) " + functionName + ";\n"); }  suffixIndex = fieldName.indexOf("TOC"); if (suffixIndex > 0) {  String functionName = fieldName.substring(0, suffixIndex); if (VM.BuildForAix)   System.out.print("      " + fieldName + " = ((AixLinkageLayout *)&" + functionName + ")->toc;\n"); else System.out.print("      " + fieldName + " = 0;\n"); } }  System.out.print("      }\n"); System.out.print("   };\n");
System.out.print("};\n");
  static void emitBootRecordDeclarations () {    VM_Atom className = VM_Atom.findOrCreateAsciiAtom("com/ibm/JikesRVM/VM_BootRecord");    VM_Atom classDescriptor = className.descriptorFromClassName();    VM_Class bootRecord = null;    try {      bootRecord = VM_TypeReference.findOrCreate(VM_SystemClassLoader.getVMClassLoader(), classDescriptor).resolve().asClass();    } catch (ClassNotFoundException e) {      System.err.println("Failed to load VM_BootRecord!");      System.exit(-1);    }    VM_Field[] fields = bootRecord.getDeclaredFields();    // emit function declarations    //    for (int i = fields.length; --i >= 0;) {      VM_Field field = fields[i];      if (field.isStatic())        continue;      String fieldName = field.getName().toString();      int suffixIndex = fieldName.indexOf("IP");      if (suffixIndex > 0) {        // java field "xxxIP" corresponds to C function "xxx"        String functionName = fieldName.substring(0, suffixIndex);        // e. g.,        // extern "C" void sysSprintf();        System.out.print("extern \"C\" int " + functionName + "();\n");      }    }    System.out.print("\nstruct VM_BootRecord\n");    System.out.print("   {\n");    // emit field declarations    // note that fields are layed out "backwards" in memory    //    for (int i = fields.length; --i >= 0;) {      VM_Field field = fields[i];      if (field.isStatic())        continue;      else if (field.getType().isIntType())	  System.out.print("   int " + field.getName() + ";\n");      else if (field.getType().isWordType())	  System.out.print("   VM_Address " + field.getName() + ";\n");      else if (field.getType().isArrayType() &&	       field.getType().getArrayElementType().isWordType())	  System.out.print("   VM_Address * " + field.getName() + ";\n");      else if (field.getName().toString().equals("heapRanges") &&	       field.getType().isArrayType() &&	       field.getType().getArrayElementType().isIntType())	  System.out.print("   unsigned int * " + field.getName() + ";\n");      else {	  System.err.print("Unexpected field " + field.getName().toString() + " with type " + field.getType() + "\n");	  throw new RuntimeException("unexpected field type");      }    }    // emit field initializers    //    System.out.print("\n   void setLinkage()\n");    System.out.print("      {\n");    for (int i = fields.length; --i >= 0;) {      VM_Field field = fields[i];      if (field.isStatic())        continue;      String fieldName = field.getName().toString();      int suffixIndex = fieldName.indexOf("IP");      if (suffixIndex > 0) {        // java field "xxxIP" corresponds to C function "xxx"        String functionName = fieldName.substring(0, suffixIndex);        if (VM.BuildForAix)          // e. g.,          // sysSprintfIP = ((AixLinkageLayout *)&sysSprintf)->ip;          System.out.print("      " + fieldName + " = ((AixLinkageLayout *)&"              + functionName + ")->ip;\n");         else           // e. g.,          //sysSprintfIP = (int) sysSprintf;           System.out.print("      " + fieldName + " = (int) " + functionName              + ";\n");      }      suffixIndex = fieldName.indexOf("TOC");      if (suffixIndex > 0) {        // java field "xxxTOC" corresponds to C function "xxx"        String functionName = fieldName.substring(0, suffixIndex);        if (VM.BuildForAix)          // e. g.,          // sysTOC = ((AixLinkageLayout *)&sys)->toc;          System.out.print("      " + fieldName + " = ((AixLinkageLayout *)&"              + functionName + ")->toc;\n");         else           System.out.print("      " + fieldName + " = 0;\n");      }    }    System.out.print("      }\n");    System.out.print("   };\n");  }