Beispiel #1
0
        // APPLY
        public static object Apply(object op, params object [] operands)
        {
            if (operands == null)
            {
                return(ResolveFunctionSpecifier(op).DynamicInvoke());
            }
            else if (operands.Length == 0)
            {
                return(ResolveFunctionSpecifier(op).DynamicInvoke());
            }
            Cons arglist = (Cons)operands [operands.Length - 1];

            for (int i = operands.Length - 2; i > -1; i--)
            {
                arglist = CL.Cons(operands [i], arglist);
            }
            int limit = CL.Length(arglist);

            object [] argarray = new object [limit];

            for (int i = 0; i < limit; i++)
            {
                argarray [i] = arglist.Car;
                arglist      = (Cons)arglist.Cdr;
            }
            return(ResolveFunctionSpecifier(op).DynamicInvoke((object)argarray));
        }
Beispiel #2
0
        public override ReaderMacroStep NextStep()
        {
            Cons   head = null;
            object tail = null;

            Readtable currentReadtable = CL.Readtable;

            while (true)
            {
                int  xx;
                char x;
                // Discard whitespace
                do
                {
                    xx = this.context.InputStream.Peek();
                    if (xx == -1)
                    {
                        throw new NotImplementedException();
                    }
                    else
                    {
                        x = (char)xx;
                    }
                }while (currentReadtable.IsWhitespaceSyntax(x) && (this.context.InputStream.Read() != -1));
                if (x == ')')
                {
                    this.context.InputStream.Read();  // discard the close paren
                    return((CL.ReadSuppress == true)
                    ? new FinalReaderMacroStep()
                    : new FinalReaderMacroStep(CL.Reconc(head, tail)));
                }
                //else if (x == '.') {
                //    throw new NotImplementedException ();
                //}
                else
                {
                    object next = CL.Read(this.context.InputStream, true, null, true);  // recursive read
                    if (CL.ReadSuppress != true)
                    {
                        head = CL.Cons(next, head);
                    }
                }
            }
        }