Changeset 5874


Ignore:
Timestamp:
02/19/04 01:35:12 (17 years ago)
Author:
piso
Message:

VECTOR-PUSH-EXTEND

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Primitives.java

    r5870 r5874  
    33 *
    44 * Copyright (C) 2002-2004 Peter Graves
    5  * $Id: Primitives.java,v 1.573 2004-02-19 00:45:42 piso Exp $
     5 * $Id: Primitives.java,v 1.574 2004-02-19 01:35:12 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    19261926                return new Fixnum(fillPointer);
    19271927            if (arg instanceof AbstractArray)
    1928                 return signal(new TypeError("Array does not have a fill pointer."));
     1928                return ((AbstractArray)arg).noFillPointer();
    19291929            else
    19301930                return signal(new TypeError(arg, Symbol.ARRAY));
     
    19391939        {
    19401940            AbstractVector v = checkVector(first);
    1941             int fillPointer = v.getFillPointer();
    1942             if (fillPointer < 0)
    1943                 signal(new TypeError("array does not have a fill pointer"));
     1941            if (v.getFillPointer() < 0)
     1942                v.noFillPointer();
    19441943            v.setFillPointer(second);
    19451944            return second;
     
    19571956            int fillPointer = v.getFillPointer();
    19581957            if (fillPointer < 0)
    1959                 signal(new TypeError("array does not have a fill pointer"));
     1958                v.noFillPointer();
    19601959            if (fillPointer >= v.capacity())
    19611960                return NIL;
     
    19751974            throws ConditionThrowable
    19761975        {
    1977             AbstractVector v = checkVector(second);
    1978             final int fillPointer = v.getFillPointer();
    1979             if (fillPointer < 0)
    1980                 signal(new TypeError("Array does not have a fill pointer."));
    1981             if (fillPointer >= v.capacity()) {
    1982                 // Need to extend vector.
    1983                 v.ensureCapacity(v.capacity() * 2 + 1);
    1984             }
    1985             v.set(fillPointer, first);
    1986             v.setFillPointer(fillPointer + 1);
    1987             return new Fixnum(fillPointer);
     1976            try {
     1977                return ((AbstractVector)second).vectorPushExtend(first);
     1978            }
     1979            catch (ClassCastException e) {
     1980                return signal(new TypeError(second, Symbol.VECTOR));
     1981            }
    19881982        }
    19891983        public LispObject execute(LispObject first, LispObject second,
     
    19911985            throws ConditionThrowable
    19921986        {
    1993             AbstractVector v = checkVector(second);
    1994             int extension = Fixnum.getValue(third);
    1995             final int fillPointer = v.getFillPointer();
    1996             if (fillPointer < 0)
    1997                 signal(new TypeError("Array does not have a fill pointer."));
    1998             if (fillPointer >= v.capacity()) {
    1999                 // Need to extend vector.
    2000                 extension = Math.max(extension, v.capacity() + 1);
    2001                 v.ensureCapacity(v.capacity() + extension);
    2002             }
    2003             v.set(fillPointer, first);
    2004             v.setFillPointer(fillPointer + 1);
    2005             return new Fixnum(fillPointer);
     1987            try {
     1988                return ((AbstractVector)second).vectorPushExtend(first, third);
     1989            }
     1990            catch (ClassCastException e) {
     1991                return signal(new TypeError(second, Symbol.VECTOR));
     1992            }
    20061993        }
    20071994    };
     
    20162003            int fillPointer = v.getFillPointer();
    20172004            if (fillPointer < 0)
    2018                 signal(new TypeError("array does not have a fill pointer"));
     2005                v.noFillPointer();
    20192006            if (fillPointer == 0)
    20202007                signal(new LispError("nothing left to pop"));
     
    20582045    // function-lambda-expression function => lambda-expression, closure-p, name
    20592046    private static final Primitive1 FUNCTION_LAMBDA_EXPRESSION =
    2060         new Primitive1("function-lambda-expression","function")
     2047        new Primitive1("function-lambda-expression", "function")
    20612048    {
    20622049        public LispObject execute(LispObject arg) throws ConditionThrowable
     
    20762063                    value2 = NIL;
    20772064                else
    2078                     value2 = env;
     2065                    value2 = env; // Return environment as closure-p.
    20792066            } else
    20802067                value1 = value2 = NIL;
Note: See TracChangeset for help on using the changeset viewer.