source: branches/0.17.x/abcl/src/org/armedbear/lisp/JavaStackFrame.java

Last change on this file was 12255, checked in by ehuelsmann, 16 years ago

Rename ConditionThrowable? to ControlTransfer? and remove

try/catch blocks which don't have anything to do with
non-local transfer of control.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1/*
2 * JavaStackFrame.java
3 *
4 * Copyright (C) 2009 Mark Evenson
5 * $Id: JavaStackFrame.java 12255 2009-11-06 22:36:32Z ehuelsmann $
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 *
21 * As a special exception, the copyright holders of this library give you
22 * permission to link this library with independent modules to produce an
23 * executable, regardless of the license terms of these independent
24 * modules, and to copy and distribute the resulting executable under
25 * terms of your choice, provided that you also meet, for each linked
26 * independent module, the terms and conditions of the license of that
27 * module.  An independent module is a module which is not derived from
28 * or based on this library.  If you modify this library, you may extend
29 * this exception to your version of the library, but you are not
30 * obligated to do so.  If you do not wish to do so, delete this
31 * exception statement from your version.
32 */
33
34package org.armedbear.lisp;
35
36public class JavaStackFrame 
37  extends StackFrame
38{
39  public final StackTraceElement javaFrame;
40
41  public JavaStackFrame(StackTraceElement javaFrame)
42  {
43    this.javaFrame = javaFrame;
44  }
45
46  @Override
47  public LispObject typeOf() { 
48    return Symbol.JAVA_STACK_FRAME; 
49  }
50
51  @Override
52  public LispObject classOf()   { return BuiltInClass.JAVA_STACK_FRAME; }
53
54  @Override
55  public String writeToString() { 
56    final String JAVA_STACK_FRAME = "JAVA-STACK-FRAME";
57    return unreadableString(JAVA_STACK_FRAME + " "
58        + toLispString().toString());
59  }
60
61  @Override
62  public LispObject typep(LispObject typeSpecifier) 
63
64  {
65     if (typeSpecifier == Symbol.JAVA_STACK_FRAME)
66       return T;
67     if (typeSpecifier == BuiltInClass.JAVA_STACK_FRAME)
68       return T;
69     return super.typep(typeSpecifier);
70   }
71
72  static final Symbol CLASS = Packages.internKeyword("CLASS");
73  static final Symbol METHOD = Packages.internKeyword("METHOD");
74  static final Symbol FILE = Packages.internKeyword("FILE");
75  static final Symbol LINE = Packages.internKeyword("LINE");
76  static final Symbol NATIVE_METHOD = Packages.internKeyword("NATIVE-METHOD");
77
78  public LispObject toLispList()
79  {
80    LispObject result = Lisp.NIL;
81   
82    if ( javaFrame == null) 
83      return result;
84
85    result = result.push(CLASS);
86    result = result.push(new SimpleString(javaFrame.getClassName()));
87    result = result.push(METHOD);
88    result = result.push(new SimpleString(javaFrame.getMethodName()));
89    result = result.push(FILE);
90    result = result.push(new SimpleString(javaFrame.getFileName()));
91    result = result.push(LINE);
92    result = result.push(Fixnum.getInstance(javaFrame.getLineNumber()));
93    if (javaFrame.isNativeMethod()) {
94      result = result.push(NATIVE_METHOD);
95      result = result.push(Symbol.T);
96    }
97
98    return result.nreverse();
99  }
100
101  @Override
102  public SimpleString toLispString() 
103
104  {
105    return new SimpleString(javaFrame.toString());
106  }
107
108  @Override
109  public LispObject getParts() 
110
111  { 
112    LispObject result = NIL;
113    result = result.push(new Cons("CLASS", 
114          new SimpleString(javaFrame.getClassName())));
115    result = result.push(new Cons("METHOD", 
116          new SimpleString(javaFrame.getMethodName())));
117    result = result.push(new Cons("FILE", 
118          new SimpleString(javaFrame.getFileName())));
119    result = result.push(new Cons("LINE",
120          Fixnum.getInstance(javaFrame.getLineNumber())));
121    result = result.push(new Cons("NATIVE-METHOD",
122          LispObject.getInstance(javaFrame.isNativeMethod())));
123    return result.nreverse();
124  }
125}
Note: See TracBrowser for help on using the repository browser.