// Copyright (c) 1996-2002 Brian D. Carlstrom

package bdc.scheme.procedure;

import bdc.scheme.Stack;
import bdc.scheme.Scheme;
import bdc.scheme.exception.ArgumentTypeException;
import bdc.scheme.expression.Procedure1;

/**
    Object.toString and Integer.toString
    (symbol->string x) (integer->string x)
*/
public class ToString extends Procedure1
{
    public Object apply1 (Stack stack)
    {
        Object o1 = stack.array[stack.inUse-1];
        return o1.toString();
    }

    public Object apply2 (Stack stack) throws ArgumentTypeException
    {
        Object o1 = stack.array[stack.inUse-1];
        Object o2 = stack.array[stack.inUse-2];
        return Integer.toString(Scheme.integer(o1, this),
                                Scheme.integer(o2, this));
    }
}
