001// ***** This file is automatically generated from SequencesUnion.java.jpp 002 003package daikon.derive.binary; 004 005import org.checkerframework.dataflow.qual.SideEffectFree; 006import org.checkerframework.dataflow.qual.Pure; 007import org.checkerframework.checker.interning.qual.Interned; 008import daikon.*; 009import daikon.derive.*; 010import org.plumelib.util.ArraysPlume; 011import org.plumelib.util.Intern; 012 013/** 014 * Represents the setwise union of two base variables, each of which is a collection. This variable 015 * contains every element that is in either of the base variables, but this variable contains no 016 * duplicate elements. Elements are in order of first appearance in the base variables (base1 017 * first). 018 */ 019public final class SequenceFloatUnion extends BinaryDerivation { 020 // We are Serializable, so we specify a version to allow changes to 021 // method signatures without breaking serialization. If you add or 022 // remove fields, you should change this number to the current date. 023 static final long serialVersionUID = 20020122L; 024 025 // Variables starting with dkconfig_ should only be set via the 026 // daikon.config.Configuration interface. 027 /** Boolean. True iff SequenceFloatUnion derived variables should be generated. */ 028 public static boolean dkconfig_enabled = false; 029 030 SequenceFloatUnion(VarInfo vi1, VarInfo vi2) { 031 super(vi1, vi2); 032 } 033 034 @Override 035 public ValueAndModified computeValueAndModifiedImpl(ValueTuple full_vt) { 036 int mod1 = base1.getModified(full_vt); 037 if (mod1 == ValueTuple.MISSING_NONSENSICAL) { 038 return ValueAndModified.MISSING_NONSENSICAL; 039 } 040 int mod2 = base2.getModified(full_vt); 041 if (mod2 == ValueTuple.MISSING_NONSENSICAL) { 042 return ValueAndModified.MISSING_NONSENSICAL; 043 } 044 Object val1 = base1.getValue(full_vt); 045 if (val1 == null) { 046 return ValueAndModified.MISSING_NONSENSICAL; 047 } 048 double[] val1_array = (double[]) val1; 049 Object val2 = base2.getValue(full_vt); 050 if (val2 == null) { 051 return ValueAndModified.MISSING_NONSENSICAL; 052 } 053 double[] val2_array = (double[]) val2; 054 055 double[] tmp = new double[val1_array.length + val2_array.length]; 056 int size = 0; 057 for (int i = 0; i < val1_array.length; i++) { 058 double v = val1_array[i]; 059 if ((size == 0) || (ArraysPlume.indexOf(ArraysPlume.subarray(tmp, 0, size), v) == -1)) { 060 tmp[size++] = v; 061 } 062 } 063 for (int i = 0; i < val2_array.length; i++) { 064 double v = val2_array[i]; 065 if ((size == 0) || (ArraysPlume.indexOf(ArraysPlume.subarray(tmp, 0, size), v) == -1)) { 066 tmp[size++] = v; 067 } 068 } 069 070 double[] union = ArraysPlume.subarray(tmp, 0, size); 071 union = Intern.intern(union); 072 073 int mod = 074 (((mod1 == ValueTuple.UNMODIFIED) && (mod2 == ValueTuple.UNMODIFIED)) 075 ? ValueTuple.UNMODIFIED 076 : ValueTuple.MODIFIED); 077 return new ValueAndModified(union, mod); 078 } 079 080 @Override 081 protected VarInfo makeVarInfo() { 082 return VarInfo.make_function("union", base1, base2); 083 } 084 085 @Pure 086 @Override 087 public boolean isSameFormula(Derivation other) { 088 return (other instanceof SequenceFloatUnion); 089 } 090 091 /** Returns the ESC name. */ 092 @SideEffectFree 093 @Override 094 public String esc_name(String index) { 095 return String.format("union(%s,%s)", var1().esc_name(), var2().esc_name()); 096 } 097}