This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

internal compiler error from gcj


Hi there,

I am using gcj "2.95.2-0pre2" (Debian package's version number, hope this
is meaningful to you) and experienced an internal compiler error when
trying to compile some code to .class format. It compiles successfully
in native format. The error message given is

Fc32RLEImageSource.java: In class `Fc32RLEImageSource':
Fc32RLEImageSource.java: In method `ReadImageData(java.io.DataInputStream,int)':
Fc32RLEImageSource.java:62: internal error - tree code not implemented: save_expr
Fc32RLEImageSource.java:62: internal error - tree code not implemented: save_expr
Fc32RLEImageSource.java:62: Internal compiler error in `generate_bytecode_insns', at java/jcf-write.c:1992

My command line was "gcj -c -C Fc32RLEImageSource.java". My system
is Debian GNU/Linux unstable (linux 2.2). I have attached the source code
for this class and the two parent classes (which both compile successfully).

Hope this is of use to you.


Hamish

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

/**
  * This class is an extension of the Fc32ImageSource class which
  * reads the CS544 SCR (full colour with run-length encoding) image format.
  * Writing of these files is not supported.
  *
  * @see CustomImageSource
  * @see Fc32ImageSource
  * @author Hamish Moffatt
  *
  * Copyright 1999 Hamish Moffatt.
  * References: CS544 notes/web page
  *
  */
public class Fc32RLEImageSource extends Fc32ImageSource {

    /**
      * Constructs an Fc32RLEImageSource object, reading RLE image data
      * from the named file.
      *
      * @param filename Name of the file to read
      * @see CustomImageSource#CustomImageSource
      *
      */
    public Fc32RLEImageSource(String filename) {
        super(filename);
    }

    /**
      * Reads RLE image data from a FC image file.
      *
      * @param ds DataInputStream to read from
      * @param channels Number of channels to read
      * @see Fc32ImageSource#ReadImageData
      *
      */ 
    protected void ReadImageData(DataInputStream ds, int channels) {
        int x, y, colour;

        try {

            // Read the red components
            // First read the multiplier, then the actual value,
            // until we have read the entire channel data
            x = 0;
            while (x < i_width * i_height) {
                y = ds.readUnsignedByte();
                colour = ds.readUnsignedByte();
                for (int z = 0; z < y; z++)
                    pix[x++] = colour << 16;
            }

            // Read the green components
            x = 0;
            while (x < i_width * i_height) {
                y = ds.readUnsignedByte();
                colour = ds.readUnsignedByte();
                for (int z = 0; z < y; z++)
                    pix[x++] |= colour << 8;
            }

            // Read the blue components
            x = 0;
            while (x < i_width * i_height) {
                y = ds.readUnsignedByte();
                colour = ds.readUnsignedByte();
                for (int z = 0; z < y; z++)
                    pix[x++] |= colour;
            }

            // Read the alpha components
            x = 0;
            if (channels == 4)
                while (x < i_width * i_height) {
                    y = ds.readUnsignedByte();
                    colour = ds.readUnsignedByte();
                    for (int z = 0; z < y; z++)
                        pix[x++] |= colour << 24;
                }

        } catch(IOException e) {
            System.out.println(e.toString());
        }

    }

}
import java.awt.image.MemoryImageSource;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
import java.awt.image.PixelGrabber;
import java.awt.Image;

/**
  * This class is an extension of the CustomImageSource class which
  * reads the CS544 FC32 (full colour 32-bit) image format.
  *
  * @see CustomImageSource
  * @author Hamish Moffatt
  *
  * Copyright 1999 Hamish Moffatt.
  * References: CS544 notes/web page
  *
  */
public class Fc32ImageSource extends CustomImageSource {

    /**
      *
      * Constructs an Fc32ImageSource object, reading image data
      * from the named file.
      *
      * @param filename Name of the file to read
      * @see CustomImageSource#CustomImageSource
      *
      */
    public Fc32ImageSource(String filename) {
        super(filename);
    }

    /**
      * Reads an FC 32-bit image file from disk
      *
      * @param filename Name of the file to read
      * @see CustomImageSource#ReadImageFile
      *
      */
    protected void ReadImageFile(String filename) {
        DataInputStream ds;
        String st;
        int i, x, y, colour, channels;
        byte tmp;

        try {
            ds = new DataInputStream(new FileInputStream(filename));

            // System.out.println("opened the file");

            // Read the SIC headers -- firstly the format and the comment
            for (x = 0; x < 3; x++) {
                do {
                    tmp = ds.readByte();
                } while (tmp != '#');
            }

            // Read the dimensions
            i_width = ds.readInt();
            i_height = ds.readInt();

            // Read the number of channels
            channels = ds.readInt();

            pix = new int[i_width*i_height];
            ReadImageData(ds, channels);

            if (channels == 3) 
                cm = new DirectColorModel(24, 0xFF0000, 0x00FF00, 0x0000FF);
            else
                cm = new DirectColorModel(32, 0x00FF0000, 0x0000FF00, 
                    0x000000FF, 0xFF000000);

        } catch(IOException e) {
            System.out.println(e.toString());
        }

    }

    /**
      * Reads image data from a SIC image file. 
      * Overridden in the subclass to read RLE data.
      *
      * @param ds DataInputStream to read from
      * @param channels Number of colour channels to read
      * @see SicImageSource#ReadImageData
      *
      */ 
    protected void ReadImageData(DataInputStream ds, int channels) {
        int x, y;

        try {

            // Read the red components
            for (y = 0; y < i_height; y++)
                for (x = 0; x < i_width; x++)
                    pix[x+(y*i_width)] = (ds.readUnsignedByte() << 16);

            // Read the green components
            for (y = 0; y < i_height; y++)
                for (x = 0; x < i_width; x++)
                    pix[x+(y*i_width)] |= (ds.readUnsignedByte() << 8);

            // Read the blue components
            for (y = 0; y < i_height; y++)
                for (x = 0; x < i_width; x++)
                    pix[x+(y*i_width)] |= (ds.readUnsignedByte());

            // Read the alpha components
            if (channels == 4)
                for (y = 0; y < i_height; y++)
                    for (x = 0; x < i_width; x++) {
                        pix[x+(y*i_width)] |= (ds.readUnsignedByte() << 24);
                    }

        } catch(IOException e) {
            System.out.println(e.toString());
        }

    }

    /**
      * Write an image to disk in FCB format.
      *
      * @param filename Filename to write to
      * @param i Image to write
      *
      */
    public static void writeImage(String filename, Image i) {
        int width = i.getWidth(null);
        int height = i.getHeight(null);
        int pix[] = new int[width*height];
        PixelGrabber pg = new PixelGrabber(i, 0, 0, width, height, 
            pix, 0, width);

        ColorModel model;
        int channels = 4;
        DataOutputStream ds;

        try {
            // Grab the pixels
            pg.grabPixels();
            model = pg.getColorModel();

            // Create the output file and write the headers
            ds = new DataOutputStream(new FileOutputStream(filename));
            ds.writeBytes("#FC32BIT#Written by the Graphic Editor#");
            ds.writeInt(width);
            ds.writeInt(height);
            ds.writeInt(channels);

            // Write the four colour channels
            for (int y = 0; y < height; y++)
                for (int x = 0; x < width; x++)
                    ds.writeByte(model.getRed(pix[y*width+x]));

            for (int y = 0; y < height; y++)
                for (int x = 0; x < width; x++)
                    ds.writeByte(model.getGreen(pix[y*width+x]));

            for (int y = 0; y < height; y++)
                for (int x = 0; x < width; x++)
                    ds.writeByte(model.getBlue(pix[y*width+x]));

            for (int y = 0; y < height; y++)
                for (int x = 0; x < width; x++)
                    ds.writeByte(model.getAlpha(pix[y*width+x]));

        } catch (Exception e) {
            System.out.println(e.toString());
        }

    }

}
import java.awt.Component;
import java.awt.image.MemoryImageSource;
import java.awt.image.ColorModel;
import java.awt.image.ImageProducer;
import java.awt.image.ImageConsumer;

/**
  * This is an abstract class which implements the ImageProducer interface.
  * This class is used to read the custom image formats for CS544.
  * Subclasses must define the ReadImageFile function, which is responsible
  * for reading the actual image file. This class only handles the
  * ImageProducer interface and management of the MemoryImageSource.
  *
  * @see ImageProducer
  * @see MemoryImageSource
  * @author Hamish Moffatt
  *
  * Copyright 1999 Hamish Moffatt.
  * References: CS544 notes/web page
  *
  */

public abstract class CustomImageSource implements ImageProducer {
    /** Contains the width of the image */
    protected int i_width;
    /** Contains the height of the image */
    protected int i_height;
    /** Contains the image pixel data */
    protected int[] pix;
    /** Contains the image's colour model */
    protected ColorModel cm;
    private MemoryImageSource MemoryImage;

    /**
      * Reads an image file from disk.
      * @param filename Name of the file to read
      */
    protected abstract void ReadImageFile(String filename);

    /**
      * Constructs a CustomImageSource object and reads the named file.
      *
      * @see Component#createImage
      * @param filename Name of the file to read
      *
      */
    public CustomImageSource(String filename) {
        ReadImageFile(filename);
        MemoryImage = new MemoryImageSource(i_width, i_height, cm, 
            pix, 0, i_width);

    }

    /******************************************************************/

    /**
      * Adds a consumer to the list of consumers for this producer.
      *
      * @param ic Consumer to add
      * @see ImageProducer#addConsumer
      *
      */
    public synchronized void addConsumer(ImageConsumer ic) {
        MemoryImage.addConsumer(ic);
    }

    /**
      * Tests whether the consumer is a consumer of this producer.
      *
      * @returns boolean, true if the consumer is on the consumer list
      * @param ic Consumer to test for
      * @see ImageProducer#isConsumer
      *
      */
    public synchronized boolean isConsumer(ImageConsumer ic) {
        return MemoryImage.isConsumer(ic);
    }

    /**
      * Removes a consumer from the list of registered consumers.
      * @param ic Consumer to remove
      * @see ImageProducer#removeConsumer
     */
    public synchronized void removeConsumer(ImageConsumer ic) {
        MemoryImage.removeConsumer(ic);
    }                                  
     
    /**
      * Starts production of the image
      * @param ic Consumer requesting production
      * @see ImageProducer#startProduction
      */
    public void startProduction(ImageConsumer ic) {
        MemoryImage.startProduction(ic);
    }                   
     
    /**
      * Requests a resend of the image in top-down-left-right format.
      *
      * @param ic Consumer requesting the resend
      * @see ImageProducer#requestTopDownLeftRightResend
      *
      */
    public void requestTopDownLeftRightResend(ImageConsumer ic) {
        MemoryImage.requestTopDownLeftRightResend(ic);
    }
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]