Changeset 5916


Ignore:
Timestamp:
02/24/04 01:58:53 (17 years ago)
Author:
piso
Message:

Vector refactoring (work in progress).

Location:
trunk/j/src/org/armedbear/lisp
Files:
9 edited

Legend:

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

    r5496 r5916  
    33 *
    44 * Copyright (C) 2003-2004 Peter Graves
    5  * $Id: Condition.java,v 1.19 2004-01-18 20:07:26 piso Exp $
     5 * $Id: Condition.java,v 1.20 2004-02-24 01:54:40 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    3434    }
    3535
    36     public Condition(LispClass cls, Vector slots)
     36    public Condition(LispClass cls, SimpleVector slots)
    3737    {
    3838        super(cls, slots);
  • trunk/j/src/org/armedbear/lisp/GenericFunction.java

    r5209 r5916  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: GenericFunction.java,v 1.6 2003-12-19 20:26:26 piso Exp $
     5 * $Id: GenericFunction.java,v 1.7 2004-02-24 01:54:40 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2626    private LispObject discriminatingFunction;
    2727
    28     public GenericFunction(LispClass cls, Vector slots)
     28    public GenericFunction(LispClass cls, SimpleVector slots)
    2929    {
    3030        super(cls, slots);
  • trunk/j/src/org/armedbear/lisp/JHandler.java

    r5897 r5916  
    22 * JHandler.java
    33 *
    4  * Copyright (C) 2003 Peter Graves
    5  * $Id: JHandler.java,v 1.7 2004-02-23 14:24:46 piso Exp $
     4 * Copyright (C) 2003-2004 Peter Graves
     5 * $Id: JHandler.java,v 1.8 2004-02-24 01:54:40 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    3030    private static final Map table = new WeakHashMap();
    3131
    32     public static void callLisp (String s, Object o) {
     32    public static void callLisp (String s, Object o)
     33    {
    3334        callLisp(s, o, "");
    3435    }
    3536
    36     public static void callLisp (String s, Object o, String s1) {
     37    public static void callLisp (String s, Object o, String s1)
     38    {
    3739        callLisp(s, o, s1, new int[] {});
    3840    }
     
    4244    }
    4345
    44     public static void callLisp (String s, Object o, String as[]) {
     46    public static void callLisp (String s, Object o, String as[])
     47    {
    4548        callLisp(s, o, as, new int[] {});
    4649    }
    4750
    48     public static void callLisp (String s, Object o, String as[], int ai[]) {
     51    public static void callLisp (String s, Object o, String as[], int ai[])
     52    {
    4953        if (table.containsKey(o)) {
    5054            Map entryTable =  (Map)table.get(o);
     
    5761                    lispAi[i] = new Fixnum(ai[i]);
    5862                }
    59                 LispObject lispAiVector = new Vector(lispAi);
     63                LispObject lispAiVector = new SimpleVector(lispAi);
    6064                SimpleString[] lispAs = new SimpleString[as.length];
    6165                for (int i = 0; i < as.length; i++) {
    6266                    lispAs[i] = new SimpleString(as[i]);
    6367                }
    64                 LispObject lispAsVector = new Vector(lispAs);
     68                LispObject lispAsVector = new SimpleVector(lispAs);
    6569                LispObject[] args = new LispObject[] //FIXME: count -> seq_num
    6670                { data, new JavaObject(o), lispAiVector, lispAsVector, Keyword.internKeyword(s), count };
  • trunk/j/src/org/armedbear/lisp/Java.java

    r5897 r5916  
    33 *
    44 * Copyright (C) 2002-2004 Peter Graves
    5  * $Id: Java.java,v 1.40 2004-02-23 14:24:46 piso Exp $
     5 * $Id: Java.java,v 1.41 2004-02-24 01:54:40 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    624624        if (obj instanceof Object[]) {
    625625            Object[] array = (Object[]) obj;
    626             Vector v = new Vector(array.length);
     626            SimpleVector v = new SimpleVector(array.length);
    627627            for (int i = array.length; i-- > 0;)
    628628                v.set(i, new JavaObject(array[i]));
  • trunk/j/src/org/armedbear/lisp/StandardObject.java

    r5796 r5916  
    33 *
    44 * Copyright (C) 2003-2004 Peter Graves
    5  * $Id: StandardObject.java,v 1.17 2004-02-12 20:17:11 piso Exp $
     5 * $Id: StandardObject.java,v 1.18 2004-02-24 01:54:40 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2525{
    2626    private Layout layout;
    27     private Vector slots;
     27    private SimpleVector slots;
    2828
    2929    protected StandardObject()
     
    3232    }
    3333
    34     protected StandardObject(LispClass cls, Vector slots)
     34    protected StandardObject(LispClass cls, SimpleVector slots)
    3535    {
    3636        layout = cls.getLayout();
     
    170170        {
    171171            if (first instanceof StandardObject) {
    172                 if (second instanceof Vector) {
    173                     ((StandardObject)first).slots = (Vector) second;
     172                if (second instanceof SimpleVector) {
     173                    ((StandardObject)first).slots = (SimpleVector) second;
    174174                    return second;
    175175                }
    176                 return signal(new TypeError(second, Symbol.VECTOR));
     176                return signal(new TypeError(second, Symbol.SIMPLE_VECTOR));
    177177            }
    178178            return signal(new TypeError(first, Symbol.STANDARD_OBJECT));
     
    225225            throws ConditionThrowable
    226226        {
    227             Vector v = new Vector(Fixnum.getValue(first));
    228             v.fill(second);
    229             return v;
     227            try {
     228                SimpleVector v = new SimpleVector(((Fixnum)first).value);
     229                v.fill(second);
     230                return v;
     231            }
     232            catch (ClassCastException e) {
     233                return signal(new TypeError(first, Symbol.FIXNUM));
     234            }
    230235        }
    231236    };
     
    242247                return new StandardClass();
    243248            if (first instanceof LispClass) {
    244                 if (second instanceof Vector) {
     249                if (second instanceof SimpleVector) {
    245250                    Symbol symbol = ((LispClass)first).getSymbol();
    246                     Vector slots = (Vector) second;
     251                    SimpleVector slots = (SimpleVector) second;
    247252                    if (symbol == Symbol.STANDARD_GENERIC_FUNCTION)
    248253                        return new GenericFunction((LispClass)first, slots);
     
    256261                    return new StandardObject((LispClass)first, slots);
    257262                }
    258                 return signal(new TypeError(second, Symbol.VECTOR));
     263                return signal(new TypeError(second, Symbol.SIMPLE_VECTOR));
    259264            }
    260265            return signal(new TypeError(first, Symbol.CLASS));
  • trunk/j/src/org/armedbear/lisp/Stream.java

    r5897 r5916  
    33 *
    44 * Copyright (C) 2003-2004 Peter Graves
    5  * $Id: Stream.java,v 1.24 2004-02-23 14:24:47 piso Exp $
     5 * $Id: Stream.java,v 1.25 2004-02-24 01:54:40 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    487487                                new Cons(read(true, NIL, true)));
    488488            case '(':
    489                 return new Vector(readList());
     489                return new SimpleVector(readList());
    490490            case '\\':
    491491                return readCharacterLiteral();
     
    693693        LispObject obj = read(true, NIL, true);
    694694        if (rank == 1)
    695             return new Vector(obj);
     695            return new SimpleVector(obj);
    696696        return new Array(rank, obj);
    697697    }
  • trunk/j/src/org/armedbear/lisp/StructureObject.java

    r5836 r5916  
    33 *
    44 * Copyright (C) 2003-2004 Peter Graves
    5  * $Id: StructureObject.java,v 1.22 2004-02-15 18:42:05 piso Exp $
     5 * $Id: StructureObject.java,v 1.23 2004-02-24 01:58:53 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    9595            for (int i = 0; i < limit; i++) {
    9696                sb.append(' ');
    97                 Vector slotDefinition = (Vector) effectiveSlotsArray[i];
     97                SimpleVector slotDefinition = (SimpleVector) effectiveSlotsArray[i];
    9898                LispObject slotName = slotDefinition.get(1);
    9999                if (slotName instanceof Symbol) {
  • trunk/j/src/org/armedbear/lisp/Vector.java

    r5908 r5916  
    33 *
    44 * Copyright (C) 2002-2004 Peter Graves
    5  * $Id: Vector.java,v 1.33 2004-02-23 19:56:58 piso Exp $
     5 * $Id: Vector.java,v 1.34 2004-02-24 01:54:40 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    183183    public LispObject subseq(int start, int end) throws ConditionThrowable
    184184    {
    185         Vector v = new Vector(end - start);
     185        SimpleVector v = new SimpleVector(end - start);
    186186        int i = start, j = 0;
    187187        try {
    188188            while (i < end)
    189                 v.elements[j++] = elements[i++];
     189                v.set(j++, get(i++));
    190190            return v;
    191191        }
     
    218218    {
    219219        int length = length();
    220         Vector result = new Vector(length);
     220        SimpleVector result = new SimpleVector(length);
    221221        int i, j;
    222222        for (i = 0, j = length - 1; i < length; i++, j--)
    223             result.elements[i] = elements[j];
     223            result.set(i, get(j));
    224224        return result;
    225225    }
  • trunk/j/src/org/armedbear/lisp/make_array.java

    r5908 r5916  
    33 *
    44 * Copyright (C) 2003-2004 Peter Graves
    5  * $Id: make_array.java,v 1.13 2004-02-23 19:56:58 piso Exp $
     5 * $Id: make_array.java,v 1.14 2004-02-24 01:54:40 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    110110            else if (upgradedType == NIL)
    111111                v = new NilVector(size);
    112             else
    113                 v = new Vector(size);
     112            else {
     113                if (fillPointer != NIL || adjustable != NIL)
     114                    v = new Vector(size);
     115                else
     116                    v = new SimpleVector(size);
     117            }
    114118            if (initialElementProvided != NIL) {
    115119                // Initial element was specified.
Note: See TracChangeset for help on using the changeset viewer.