Link to home
Start Free TrialLog in
Avatar of nigg
niggFlag for Israel

asked on

Whats wrong with this code?

I'm not a C programmer (but Java) and need to get a c code working...

Code:

jbArray<java_object *>::primitiveArrayType java_object_array::array_type() const {
     return jbArray::T_CLASS;
}

Gives me the following error at the compiler (on Linux):

../../../common/decaf/java_object.cc: In method `jbArray<java_object
*>::primitiveArrayType java_object_array::array_type () const':
../../../common/decaf/java_object.cc:219: use of class template `template <elem_
t> class jbArray' as
expression
../../../common/decaf/java_object.cc:219: parse error before `::'
../../../common/decaf/java_object.cc:220: warning: no return statement in functi
on returning non-void
../../../common/decaf/java_object.cc: In method
`jbArray<jfloat>::primitiveArrayType java_jfloat_array::array_type ()
const':

Where do I look up the return type, like void? What do I need to change? For any help thanks...

BTW: Why does this not work?:

 char ch = va_arg(args, char);

The compiler complains about wrong type...I put va_arg(args, int); and it compiled..But is this right?
Avatar of peterdownes
peterdownes

Say you had a template class Foo:

template <class T> class Foo
{
void Bar(T* pT);
};

The method would be implemented as follows:

template<class T> void CEGMManager<T>::Bar(T* pT)
{

}
Ummm.... that's C++ code you got there, not C code.
Avatar of nigg

ASKER

Hi,

First off all, I did not get any mail notification...Just entered my question by mistake...

nebeker: You are right, how stupid from me...will consider this at the end...

peterdownes: OK, I understand more or less your example, so what's missing at my code above? I didn't catch it...sorry..
Can you post your code please.
Avatar of nigg

ASKER

Yes, you are great...This should be the code I'm trying to compile...The project seams to be dead, but it looks like a nice start for a allmost native java system...

At http://web.mit.edu/~tb/dev/jos/JJOS/ is the whole distro...
So, is this the code you are having problems with?
ASKER CERTIFIED SOLUTION
Avatar of peterdownes
peterdownes

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nigg

ASKER

This worked great...thanks.But now I'm stuck at a other place:

../../../common/decaf/d_main.cc: In method `jjBoolean
(*decafJVM::lookupBuiltInMethod (resolved_method *)) (java_word *,
frame *, resolved_method *, int)':
../../../common/decaf/d_main.cc:41: cannot convert `const utf8_native
*' to `utf8_native *' for argument `1' to `jbHashtable<KeyType,
DatumType>::lookup (KeyType) [with KeyType = utf8_native *, DatumType =
jjBoolean (*) (java_word *, frame *, resolved_method *, int)]'
make: *** [d_main.o] Error 1

Did they ever compile this stuff??

Maybe you try to compile it and tell me what to change? Increased the points. Thanks
Avatar of nigg

ASKER

mmmhh, http://web.mit.edu/~tb/dev/jos/JJOS/, does not match the sources I have, but both of them aren't compiling...Why didn't I learn C/C++??

But here the code I suspect making the error mentioned above:

This is from the header file:

builtInMethod lookupBuiltInMethod(resolved_method *rm, java_class* jc);

code from d_main.cc:

builtInMethod decafJVM::lookupBuiltInMethod(resolved_method *rm)
{
  constant_utf8 *foo = rm->namePtr();
  const utf8_native *bar = foo->string();
  /* $: why does lookup not use constant utf8_native pointers? */
  builtInMethod baz = myBuiltinMethods->lookup(bar);
.......

This is jjboolean:

jjBoolean decafJVM::main(int argc, char *argv[])
{
      char * className;

      /* fetch the class name for the zeroth thread */
      if ( argc < 2 ) {
     DEBUG(( "decafJVM::main(): using init as default" ));
        className = "init";
     } else {
     className = argv[1];
     } /* end class name fetch */

      /*
       * Create the zeroth thread.
       */

      constant_utf8 *classname = new constant_utf8(className);
      /* $: should be intern'd */
      constant_utf8 *methodname = new constant_utf8("main");
         
      java_thread *zeroth_thread = new java_thread(classname,
                                 methodname,
                                 myPrimordialClassLoader,
                                 (java_word *)NULL,
                                 0);

.............

I start to understand, why I didn't learn C/C++...:-)
Avatar of nigg

ASKER

Here some more of the header file...I guess, that's important:

typedef jjBoolean (*builtInMethod)(java_word arg[], frame *frame, resolved_method *rm, int n_args);
typedef jbHashtable<utf8_native*, builtInMethod> builtinMethodHashTable;

class decafJVM
{
public:

  decafJVM(jjMachine *jjmp, jbRamDisk *);

  jjBoolean    main(int argc, char *argv[]);
  jjMachine    *jjm(void) const;
  scheduler    *myscheduler(void);

  builtInMethod lookupBuiltInMethod(resolved_method *rm);

 protected:

  void         internBuiltInMethods(void);
  void         internBuiltInMethod(builtInMethod fcnp, char *classname, char *fcnname);

  scheduler    myScheduler;
  class_loader *myPrimordialClassLoader;
  jjMachine    *myjjMachine;

  builtinMethodHashTable *myBuiltinMethods;
};

extern decafJVM *jvm;
Sorry nigg,

This could take me forever.

Hope someone else can assist.

Regards.
Avatar of nigg

ASKER

Thanks....I'm going to post two new question, to get work....