// Copyright (c) 1996-2002 Brian D. Carlstrom

package bdc.scheme.procedure;

import bdc.scheme.Scheme;
import bdc.scheme.SchemeException;
import bdc.scheme.Stack;
import bdc.scheme.exception.ParseException;
import bdc.scheme.expression.Procedure1;
import java.io.IOException;

/**
    (close-input-port x)
*/
public class CloseInputPort extends Procedure1
{
    public Object apply1 (Stack stack) throws SchemeException
    {
        Object o1 = stack.array[stack.inUse-1];

        try {
            Scheme.pushbackReader(o1, this).close();
            return Scheme.Unspecified;
        }
        catch (IOException ioe) {
            throw new ParseException(this.toString(),
                                     0,
                                     ioe.toString());
        }
    }
}
