OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [tools/] [gnu/] [classpath/] [tools/] [javah/] [MethodHelper.java] - Blame information for rev 779

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 779 jeremybenn
/* MethodHelper.java - helper class for manipulating methods
2
 Copyright (C) 2006, 2007 Free Software Foundation, Inc.
3
 
4
 This file is part of GNU Classpath.
5
 
6
 GNU Classpath is free software; you can redistribute it and/or modify
7
 it under the terms of the GNU General Public License as published by
8
 the Free Software Foundation; either version 2, or (at your option)
9
 any later version.
10
 
11
 GNU Classpath is distributed in the hope that it will be useful, but
12
 WITHOUT ANY WARRANTY; without even the implied warranty of
13
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 General Public License for more details.
15
 
16
 You should have received a copy of the GNU General Public License
17
 along with GNU Classpath; see the file COPYING.  If not, write to the
18
 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
 02110-1301 USA.
20
 
21
 Linking this library statically or dynamically with other modules is
22
 making a combined work based on this library.  Thus, the terms and
23
 conditions of the GNU General Public License cover the whole
24
 combination.
25
 
26
 As a special exception, the copyright holders of this library give you
27
 permission to link this library with independent modules to produce an
28
 executable, regardless of the license terms of these independent
29
 modules, and to copy and distribute the resulting executable under
30
 terms of your choice, provided that you also meet, for each linked
31
 independent module, the terms and conditions of the license of that
32
 module.  An independent module is a module which is not derived from
33
 or based on this library.  If you modify this library, you may extend
34
 this exception to your version of the library, but you are not
35
 obligated to do so.  If you do not wish to do so, delete this
36
 exception statement from your version. */
37
 
38
 
39
package gnu.classpath.tools.javah;
40
 
41
import java.lang.reflect.Modifier;
42
import java.util.Iterator;
43
 
44
import org.objectweb.asm.Opcodes;
45
import org.objectweb.asm.Type;
46
import org.objectweb.asm.tree.AbstractInsnNode;
47
import org.objectweb.asm.tree.MethodInsnNode;
48
import org.objectweb.asm.tree.MethodNode;
49
 
50
public class MethodHelper
51
{
52
 
53
  public static boolean overrides(MethodNode derived, MethodNode base)
54
  {
55
    if (! derived.name.equals(base.name))
56
      return false;
57
    if (! derived.desc.equals(base.desc))
58
      return false;
59
    // FIXME: permission madness?
60
    return true;
61
  }
62
 
63
  public static String getBridgeTarget(MethodNode meth)
64
  {
65
    if ((meth.access & Opcodes.ACC_BRIDGE) == 0)
66
      return null;
67
    Iterator<?> i = meth.instructions.iterator();
68
    while (i.hasNext())
69
      {
70
        AbstractInsnNode insn = (AbstractInsnNode) i.next();
71
        if (! (insn instanceof MethodInsnNode))
72
          continue;
73
        return ((MethodInsnNode) insn).desc;
74
      }
75
    return null;
76
  }
77
 
78
  public static void print(CniPrintStream out, MethodNode meth,
79
                           ClassWrapper declarer, String realMethodName)
80
  {
81
    if ("<clinit>".equals(meth.name))
82
      return;
83
    boolean isInit = "<init>".equals(meth.name);
84
    out.setModifiers(meth.access);
85
    out.print("  ");
86
    if (Modifier.isStatic(meth.access))
87
      out.print("static ");
88
    // If a class is final then we might as well skip 'virtual'.
89
    // The reason here is that it is safe in this case for C++
90
    // ABI code to generate a direct call. The method does end
91
    // up in the vtable (for BC code) but we don't care. Also,
92
    // the class can't be derived from anyway.
93
    else if (! isInit && ! Modifier.isPrivate(meth.access)
94
             && ! Modifier.isFinal(declarer.access))
95
      out.print("virtual ");
96
    if (! isInit)
97
      {
98
        out.print(Type.getReturnType(meth.desc));
99
        out.print(" ");
100
        out.printName(realMethodName);
101
      }
102
    else
103
      {
104
        String name = declarer.name;
105
        int index = name.lastIndexOf('/');
106
        name = name.substring(index + 1);
107
        out.printName(name);
108
      }
109
    out.print("(");
110
    Type[] argTypes = Type.getArgumentTypes(meth.desc);
111
    for (int i = 0; i < argTypes.length; ++i)
112
      {
113
        if (i > 0)
114
          out.print(", ");
115
        out.print(argTypes[i]);
116
      }
117
    out.print(")");
118
    if (Modifier.isAbstract(meth.access))
119
      out.print(" = 0");
120
    out.println(";");
121
  }
122
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.