[vmkit-commits] [vmkit] r55306 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathVMClass.cpp.inc VMCore/JavaClass.cpp VMCore/JavaClass.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Mon Aug 25 01:02:39 PDT 2008


Author: geoffray
Date: Mon Aug 25 03:02:38 2008
New Revision: 55306

URL: http://llvm.org/viewvc/llvm-project?rev=55306&view=rev
Log:
Move class-dependent code to JavaClass.


Modified:
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp.inc
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h

Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp.inc?rev=55306&r1=55305&r2=55306&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp.inc (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp.inc Mon Aug 25 03:02:38 2008
@@ -82,15 +82,8 @@
   if (cl->isArray || isInterface(cl->access)) {
     return (jobject)ArrayObject::acons(0, Classpath::constructorArrayClass, &(vm->allocator));
   } else {
-    CommonClass::method_map meths = cl->virtualMethods;
     std::vector<JavaMethod*> res;
-    for (CommonClass::method_iterator i = meths.begin(), e = meths.end();
-          i != e; ++i) {
-      JavaMethod* meth = i->second;
-      if (meth->name == Jnjvm::initName && (!publicOnly || isPublic(meth->access))) {
-        res.push_back(meth);
-      }
-    }
+    cl->getDeclaredConstructors(res, publicOnly);
     
     ArrayObject* ret = ArrayObject::acons(res.size(), Classpath::constructorArrayClass, &(vm->allocator));
     sint32 index = 0;
@@ -121,23 +114,8 @@
   if (cl->isArray) {
     return (jobject)ArrayObject::acons(0, Classpath::methodArrayClass, &(vm->allocator));
   } else {
-    CommonClass::method_map meths = cl->virtualMethods;
     std::vector<JavaMethod*> res;
-    for (CommonClass::method_iterator i = meths.begin(), e = meths.end();
-          i != e; ++i) {
-      JavaMethod* meth = i->second;
-      if (meth->name != Jnjvm::initName && (!publicOnly || isPublic(meth->access))) {
-        res.push_back(meth);
-      }
-    }
-    meths = cl->staticMethods; 
-    for (CommonClass::method_iterator i = meths.begin(), e = meths.end();
-          i != e; ++i) {
-      JavaMethod* meth = i->second;
-      if (meth->name != Jnjvm::clinitName && (!publicOnly || isPublic(meth->access))) {
-        res.push_back(meth);
-      }
-    }
+    cl->getDeclaredMethods(res, publicOnly);
     
     ArrayObject* ret = ArrayObject::acons(res.size(), Classpath::methodArrayClass, &(vm->allocator));
     sint32 index = 0;
@@ -289,23 +267,8 @@
   if (cl->isArray) {
     return (jobject)ArrayObject::acons(0, Classpath::fieldArrayClass, &(vm->allocator));
   } else {
-    CommonClass::field_map fields = cl->virtualFields;
     std::vector<JavaField*> res;
-    for (CommonClass::field_iterator i = fields.begin(), e = fields.end();
-          i != e; ++i) {
-      JavaField* field = i->second;
-      if (!publicOnly || isPublic(field->access)) {
-        res.push_back(field);
-      }
-    }
-    fields = cl->staticFields; 
-    for (CommonClass::field_iterator i = fields.begin(), e = fields.end();
-          i != e; ++i) {
-      JavaField* field = i->second;
-      if (!publicOnly || isPublic(field->access)) {
-        res.push_back(field);
-      }
-    }
+    cl->getDeclaredFields(res, publicOnly);
     
     ArrayObject* ret = ArrayObject::acons(res.size(),
                                           Classpath::fieldArrayClass, &(vm->allocator));

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=55306&r1=55305&r2=55306&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Mon Aug 25 03:02:38 2008
@@ -790,3 +790,55 @@
     innerOuterResolved = true;
   }
 }
+
+void CommonClass::getDeclaredConstructors(std::vector<JavaMethod*>& res,
+                                          bool publicOnly) {
+  for (CommonClass::method_iterator i = virtualMethods.begin(),
+       e = virtualMethods.end(); i != e; ++i) {
+    JavaMethod* meth = i->second;
+    bool pub = isPublic(meth->access);
+    if (meth->name == Jnjvm::initName && (!publicOnly || pub)) {
+      res.push_back(meth);
+    }
+  }
+}
+
+void CommonClass::getDeclaredMethods(std::vector<JavaMethod*>& res,
+                                     bool publicOnly) {
+  for (CommonClass::method_iterator i = virtualMethods.begin(),
+       e = virtualMethods.end(); i != e; ++i) {
+    JavaMethod* meth = i->second;
+    bool pub = isPublic(meth->access);
+    if (meth->name != Jnjvm::initName && (!publicOnly || pub)) {
+      res.push_back(meth);
+    }
+  }
+  
+  for (CommonClass::method_iterator i = staticMethods.begin(),
+       e = staticMethods.end(); i != e; ++i) {
+    JavaMethod* meth = i->second;
+    bool pub = isPublic(meth->access);
+    if (meth->name != Jnjvm::clinitName && (!publicOnly || pub)) {
+      res.push_back(meth);
+    }
+  }
+}
+
+void CommonClass::getDeclaredFields(std::vector<JavaField*>& res,
+                                    bool publicOnly) {
+  for (CommonClass::field_iterator i = virtualFields.begin(),
+       e = virtualFields.end(); i != e; ++i) {
+    JavaField* field = i->second;
+    if (!publicOnly || isPublic(field->access)) {
+      res.push_back(field);
+    }
+  }
+  
+  for (CommonClass::field_iterator i = staticFields.begin(),
+       e = staticFields.end(); i != e; ++i) {
+    JavaField* field = i->second;
+    if (!publicOnly || isPublic(field->access)) {
+      res.push_back(field);
+    }
+  }
+}

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=55306&r1=55305&r2=55306&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Mon Aug 25 03:02:38 2008
@@ -438,7 +438,11 @@
     return classLoader == JnjvmClassLoader::sharedLoader;
   }
 #endif
-
+  
+  void getDeclaredConstructors(std::vector<JavaMethod*>& res, bool publicOnly);
+  void getDeclaredMethods(std::vector<JavaMethod*>& res, bool publicOnly);
+  void getDeclaredFields(std::vector<JavaField*>& res, bool publicOnly);
+  
 };
 
 /// ClassPrimitive - This class represents internal classes for primitive





More information about the vmkit-commits mailing list