Changeset 4070


Ignore:
Timestamp:
09/26/03 15:04:46 (20 years ago)
Author:
piso
Message:

EXT:BACKTRACE

File:
1 edited

Legend:

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

    r4051 r4070  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: LispThread.java,v 1.14 2003-09-25 15:37:08 piso Exp $
     5 * $Id: LispThread.java,v 1.15 2003-09-26 15:04:46 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    226226    public void backtrace()
    227227    {
     228        backtrace(0);
     229    }
     230
     231    public void backtrace(int limit)
     232    {
    228233        if (stack.size() > 0) {
    229234            CharacterOutputStream out = getTraceOutput();
     235            int count = 0;
    230236            try {
    231237                out.writeLine("Evaluation stack:");
     
    248254                    out.terpri();
    249255                    out.flushOutput();
     256                    if (limit > 0 && ++count == limit)
     257                        break;
    250258                }
    251259            }
     
    392400        }
    393401    };
     402
     403    // ### backtrace
     404    private static final Primitive BACKTRACE =
     405        new Primitive("backtrace", PACKAGE_EXT, true)
     406    {
     407        public LispObject execute(LispObject[] args)
     408            throws ConditionThrowable
     409        {
     410            if (args.length > 1)
     411                throw new ConditionThrowable(new WrongNumberOfArgumentsException(this));
     412            int count = args.length > 0 ? Fixnum.getValue(args[0]) : 0;
     413            LispThread thread = currentThread();
     414            thread.backtrace(count);
     415            return thread.nothing();
     416        }
     417    };
    394418}
Note: See TracChangeset for help on using the changeset viewer.