Example #1
0
 void genReadMethod(
     @Tainted JType.JavaType this,
     @Tainted CodeBuffer cb,
     @Tainted String fname,
     @Tainted String tag,
     @Tainted boolean decl) {
   if (decl) {
     cb.append(name + " " + fname + ";\n");
   }
   cb.append(
       fname + "=" + Consts.RECORD_INPUT + ".read" + methodSuffix + "(\"" + tag + "\");\n");
 }
Example #2
0
 void genCompareBytes(CodeBuffer cb) {
   cb.append("{\n");
   cb.append("if (l1<8 || l2<8) {\n");
   cb.append(
       "throw new java.io.IOException(\"Double is exactly 8 bytes."
           + " Provided buffer is smaller.\");\n");
   cb.append("}\n");
   cb.append("double d1 = org.apache.hadoop.record.Utils.readDouble(b1, s1);\n");
   cb.append("double d2 = org.apache.hadoop.record.Utils.readDouble(b2, s2);\n");
   cb.append("if (d1 != d2) {\n");
   cb.append("return ((d1-d2) < 0) ? -1 : 0;\n");
   cb.append("}\n");
   cb.append("s1+=8; s2+=8; l1-=8; l2-=8;\n");
   cb.append("}\n");
 }
Example #3
0
 void genCompareBytes(CodeBuffer cb) {
   cb.append("{\n");
   cb.append("if (l1<4 || l2<4) {\n");
   cb.append(
       "throw new java.io.IOException(\"Float is exactly 4 bytes."
           + " Provided buffer is smaller.\");\n");
   cb.append("}\n");
   cb.append("float f1 = org.apache.hadoop.record.Utils.readFloat(b1, s1);\n");
   cb.append("float f2 = org.apache.hadoop.record.Utils.readFloat(b2, s2);\n");
   cb.append("if (f1 != f2) {\n");
   cb.append("return ((f1-f2) < 0) ? -1 : 0;\n");
   cb.append("}\n");
   cb.append("s1+=4; s2+=4; l1-=4; l2-=4;\n");
   cb.append("}\n");
 }
Example #4
0
 void genEquals(
     @Tainted JType.JavaType this,
     @Tainted CodeBuffer cb,
     @Tainted String fname,
     @Tainted String peer) {
   cb.append(Consts.RIO_PREFIX + "ret = (" + fname + "==" + peer + ");\n");
 }
Example #5
0
 // In Binary format, boolean is written as byte. true = 1, false = 0
 void genCompareBytes(CodeBuffer cb) {
   cb.append("{\n");
   cb.append("if (l1<1 || l2<1) {\n");
   cb.append(
       "throw new java.io.IOException(\"Boolean is exactly 1 byte."
           + " Provided buffer is smaller.\");\n");
   cb.append("}\n");
   cb.append("if (b1[s1] != b2[s2]) {\n");
   cb.append("return (b1[s1]<b2[s2])? -1 : 0;\n");
   cb.append("}\n");
   cb.append("s1++; s2++; l1--; l2--;\n");
   cb.append("}\n");
 }
Example #6
0
 void genWriteMethod(
     @Tainted JType.JavaType this,
     @Tainted CodeBuffer cb,
     @Tainted String fname,
     @Tainted String tag) {
   cb.append(
       Consts.RECORD_OUTPUT + ".write" + methodSuffix + "(" + fname + ",\"" + tag + "\");\n");
 }
Example #7
0
 void genCompareTo(CodeBuffer cb, String fname, String other) {
   cb.append(
       Consts.RIO_PREFIX
           + "ret = ("
           + fname
           + " == "
           + other
           + ")? 0 : ("
           + fname
           + "?1:-1);\n");
 }
Example #8
0
 void genGetSet(@Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) {
   cb.append("public " + name + " get" + toCamelCase(fname) + "() {\n");
   cb.append("return " + fname + ";\n");
   cb.append("}\n");
   cb.append("public void set" + toCamelCase(fname) + "(final " + name + " " + fname + ") {\n");
   cb.append("this." + fname + "=" + fname + ";\n");
   cb.append("}\n");
 }
Example #9
0
 void genGetSet(@Tainted JType.CppType this, @Tainted CodeBuffer cb, @Tainted String fname) {
   cb.append("virtual " + name + " get" + toCamelCase(fname) + "() const {\n");
   cb.append("return " + fname + ";\n");
   cb.append("}\n");
   cb.append("virtual void set" + toCamelCase(fname) + "(" + name + " m_) {\n");
   cb.append(fname + "=m_;\n");
   cb.append("}\n");
 }
Example #10
0
 // In Binary format, boolean is written as byte. true = 1, false = 0
 void genSlurpBytes(CodeBuffer cb, String b, String s, String l) {
   cb.append("{\n");
   cb.append("if (" + l + "<1) {\n");
   cb.append(
       "throw new java.io.IOException(\"Boolean is exactly 1 byte."
           + " Provided buffer is smaller.\");\n");
   cb.append("}\n");
   cb.append(s + "++; " + l + "--;\n");
   cb.append("}\n");
 }
Example #11
0
 void genSlurpBytes(CodeBuffer cb, String b, String s, String l) {
   cb.append("{\n");
   cb.append("if (" + l + "<8) {\n");
   cb.append(
       "throw new java.io.IOException(\"Double is exactly 8 bytes."
           + " Provided buffer is smaller.\");\n");
   cb.append("}\n");
   cb.append(s + "+=8; " + l + "-=8;\n");
   cb.append("}\n");
 }
Example #12
0
 @Override
 void genSlurpBytes(CodeBuffer cb, String b, String s, String l) {
   cb.append("{\n");
   cb.append("if (" + l + "<4) {\n");
   cb.append(
       "throw new java.io.IOException(\"Float is exactly 4 bytes."
           + " Provided buffer is smaller.\");\n");
   cb.append("}\n");
   cb.append(s + "+=4; " + l + "-=4;\n");
   cb.append("}\n");
 }
Example #13
0
 void genCompareTo(
     @Tainted JType.JavaType this,
     @Tainted CodeBuffer cb,
     @Tainted String fname,
     @Tainted String other) {
   cb.append(
       Consts.RIO_PREFIX
           + "ret = ("
           + fname
           + " == "
           + other
           + ")? 0 :(("
           + fname
           + "<"
           + other
           + ")?-1:1);\n");
 }
Example #14
0
 void genDecl(@Tainted JType.CppType this, @Tainted CodeBuffer cb, @Tainted String fname) {
   cb.append(name + " " + fname + ";\n");
 }
Example #15
0
 @Override
 void genHashCode(CodeBuffer cb, String fname) {
   cb.append(Consts.RIO_PREFIX + "ret = Float.floatToIntBits(" + fname + ");\n");
 }
Example #16
0
 void genHashCode(CodeBuffer cb, String fname) {
   cb.append(Consts.RIO_PREFIX + "ret = (" + fname + ")?0:1;\n");
 }
Example #17
0
 void genHashCode(@Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) {
   cb.append(Consts.RIO_PREFIX + "ret = (int)" + fname + ";\n");
 }
Example #18
0
 void genConstructorParam(
     @Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) {
   cb.append("final " + name + " " + fname);
 }
Example #19
0
 void genConstructorSet(
     @Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) {
   cb.append("this." + fname + " = " + fname + ";\n");
 }
Example #20
0
 void genStaticTypeInfo(
     @Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) {
   cb.append(
       Consts.RTI_VAR + ".addField(\"" + fname + "\", " + getTypeIDObjectString() + ");\n");
 }
Example #21
0
 void genDecl(@Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) {
   cb.append("private " + name + " " + fname + ";\n");
 }
Example #22
0
 void genClone(@Tainted JType.JavaType this, @Tainted CodeBuffer cb, @Tainted String fname) {
   cb.append(Consts.RIO_PREFIX + "other." + fname + " = this." + fname + ";\n");
 }
Example #23
0
 void genStaticTypeInfo(
     @Tainted JType.CppType this, @Tainted CodeBuffer cb, @Tainted String fname) {
   cb.append(
       "p->addField(new ::std::string(\"" + fname + "\"), " + getTypeIDObjectString() + ");\n");
 }
Example #24
0
 void genHashCode(CodeBuffer cb, String fname) {
   String tmp = "Double.doubleToLongBits(" + fname + ")";
   cb.append(Consts.RIO_PREFIX + "ret = (int)(" + tmp + "^(" + tmp + ">>>32));\n");
 }