From: bdemsky Date: Fri, 15 Apr 2011 07:50:22 +0000 (+0000) Subject: code to generate calls into JNI native code... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0f0646900b06ffc1d1111085d8b2f0f8531fcba8;p=IRC.git code to generate calls into JNI native code... --- diff --git a/Robust/src/IR/ClassDescriptor.java b/Robust/src/IR/ClassDescriptor.java index 136d64c3..6a8c2108 100644 --- a/Robust/src/IR/ClassDescriptor.java +++ b/Robust/src/IR/ClassDescriptor.java @@ -99,6 +99,10 @@ public class ClassDescriptor extends Descriptor { return fieldvec; } + public String getPackage() { + return packagename; + } + public SymbolTable getFlagTable() { return flags; } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index a981d9de..7a2950b9 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -78,7 +78,6 @@ public class BuildCode { * versions of the methods must already be generated and stored in * the State object. */ - public void buildCode() { /* Create output streams to write to */ PrintWriter outclassdefs=null; @@ -522,6 +521,8 @@ public class BuildCode { FlatMethod fm=state.getMethodFlat(md); if (!md.getModifiers().isNative()) { generateFlatMethod(fm, outmethod); + } else if (state.JNI) { + generateNativeFlatMethod(fm, outmethod); } } } @@ -1824,6 +1825,64 @@ public class BuildCode { headersout.println(");\n"); } } + + protected void generateNativeFlatMethod(FlatMethod fm, PrintWriter outmethod) { + MethodDescriptor md=fm.getMethod(); + ClassDescriptor cd=md.getClassDesc(); + generateHeader(fm, md, outmethod); + int startindex=0; + + if (md.getModifiers().isStatic()) { + outmethod.println("jobject rec=JNIWRAP(((void **)(((char *) &(global_defs_p->classobjs->___length___))+sizeof(int)))[" + cd.getId() + "]);"); + } else { + outmethod.println("jobject rec=JNIWRAP("+generateTemp(fm, fm.getParameter(0))+");"); + startindex=1; + } + for(int i=startindex;i output/$ARG1.output diff output/$ARG1.output output/$ARG1.output.goal rm $ARG1.bin diff --git a/Robust/src/buildscript b/Robust/src/buildscript index e328f0c8..b50930c4 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -258,14 +258,13 @@ elif [[ $1 = '-jni' ]] then JNI=true JAVAOPTS="$JAVAOPTS -jni" +EXTRAOPTIONS="$EXTRAOPTIONS -DJNI" elif [[ $1 = '-justanalyze' ]] then EXITAFTERANALYSIS=true - elif [[ $1 = '-src-after-pp' ]] then SRCAFTERPP=true - elif [[ $1 = '-assembly' ]] then ASSEMBLY=true