CloneSet259


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
84260.983class_body_declarations[3]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
18421
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java
28423
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FloatLiteral.java
Clone Instance
1
Line Count
84
Source Line
21
Source File
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java

        public DoubleLiteral(char[] token, int s, int e) {
                super(token, s, e);
        }

        public void computeConstant() {
                Double computedValue;
                try {
                        computedValue = Double.valueOf(String.valueOf(source));
                } catch (NumberFormatException e) {
                        // hex floating point literal
                        // being rejected by 1.4 libraries where Double.valueOf(...) doesn't handle hex decimal floats
                        try {
                                double v = FloatUtil.valueOfHexDoubleLiteral(source);
                                if (v == Double.POSITIVE_INFINITY) {
                                        // error: the number is too large to represent
                                        return;
                                }
                                if (Double.isNaN(v)) {
                                        // error: the number is too small to represent
                                        return;
                                }
                                value = v;
                                constant = DoubleConstant.fromValue(v);
                        } catch (NumberFormatException e1) {
                                // if the computation of the constant fails
                          }
                        return;
                  }

                final double doubleValue = computedValue.doubleValue();
                if (doubleValue > Double.MAX_VALUE) {
                        // error: the number is too large to represent
                        return;
                }
                if (doubleValue < Double.MIN_VALUE) {
                        // see 1F6IGUU
                        // a true 0 only has '0' and '.' in mantissa
                        // 1.0e-5000d is non-zero, but underflows to 0
                        boolean isHexaDecimal = false;
                        label:  for (int i = 0; i < source.length; i++) { //it is welled formated so just test against '0' and potential . D d  
                                switch (source[i]) {
                                        case '0':
                                        case '.':
                                                break;
                                        case 'x':
                                        case 'X':
                                                isHexaDecimal = true;
                                                break;
                                        case 'e':
                                        case 'E':
                                        case 'f':
                                        case 'F':
                                        case 'd':
                                        case 'D':
                                                if (isHexaDecimal) {
                                                        return;
                                                }
                                                // starting the exponent - mantissa is all zero
                                                // no exponent - mantissa is all zero
                                                break label;
                                        case 'p':
                                        case 'P':
                                                break label;
                                        default:
                                                // error: the number is too small to represent
                                                return;
                                      }
                                }
                }
                value = doubleValue;
                constant = DoubleConstant.fromValue(value);
        }

        /**
         * Code generation for the double literak
         *
         * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
         * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
         * @param valueRequired boolean
         */
        public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
                int pc = codeStream.position;
                if (valueRequired) {
                        codeStream.generateConstant(constant, implicitConversion);
                }
                codeStream.recordPositionsFrom(pc, this.sourceStart);
        }


Clone Instance
2
Line Count
84
Source Line
23
Source File
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FloatLiteral.java

        public FloatLiteral(char[] token, int s, int e) {
                super(token, s, e);
        }

        public void computeConstant() {
                Float computedValue;
                try {
                        computedValue = Float.valueOf(String.valueOf(source));
                } catch (NumberFormatException e) {
                        // hex floating point literal
                        // being rejected by 1.4 libraries where Float.valueOf(...) doesn't handle hex decimal floats
                        try {
                                float v = FloatUtil.valueOfHexFloatLiteral(source);
                                if (v == Float.POSITIVE_INFINITY) {
                                        // error: the number is too large to represent
                                        return;
                                }
                                if (Float.isNaN(v)) {
                                        // error: the number is too small to represent
                                        return;
                                }
                                value = v;
                                constant = FloatConstant.fromValue(v);
                        } catch (NumberFormatException e1) {
                                // if the computation of the constant fails
                          }
                        return;
                  }

                final float floatValue = computedValue.floatValue();
                if (floatValue > Float.MAX_VALUE) {
                        // error: the number is too large to represent
                        return;
                }
                if (floatValue < Float.MIN_VALUE) {
                        // see 1F6IGUU
                        // a true 0 only has '0' and '.' in mantissa
                        // 1.0e-5000d is non-zero, but underflows to 0
                        boolean isHexaDecimal = false;
                        label:  for (int i = 0; i < source.length; i++) { //it is welled formated so just test against '0' and potential . D d  
                                switch (source[i]) {
                                        case '0':
                                        case '.':
                                                break;
                                        case 'x':
                                        case 'X':
                                                isHexaDecimal = true;
                                                break;
                                        case 'e':
                                        case 'E':
                                        case 'f':
                                        case 'F':
                                        case 'd':
                                        case 'D':
                                                if (isHexaDecimal) {
                                                        return;
                                                }
                                                // starting the exponent - mantissa is all zero
                                                // no exponent - mantissa is all zero
                                                break label;
                                        case 'p':
                                        case 'P':
                                                break label;
                                        default:
                                                // error: the number is too small to represent
                                                return;
                                      }
                                }
                }
                value = floatValue;
                constant = FloatConstant.fromValue(value);
        }

        /**
         * Code generation for float literal
         *
         * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
         * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
         * @param valueRequired boolean
         */
        public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
                int pc = codeStream.position;
                if (valueRequired) {
                        codeStream.generateConstant(constant, implicitConversion);
                }
                codeStream.recordPositionsFrom(pc, this.sourceStart);
        }


Clone AbstractionParameter Count: 6Parameter Bindings

public [[#variablebf96a660]](char[] token, int s, int e) {
  super(token, s, e);
}

public void computeConstant() {
   [[#variablebf96a5c0]] computedValue;
  try {
    computedValue = [[#variablebf96a5c0]].valueOf(String.valueOf(source));
  }
  catch (NumberFormatException e) {
    // hex floating point literal
    // being rejected by 1.4 libraries where Double.valueOf(...) doesn't handle hex decimal floats
    // being rejected by 1.4 libraries where Float.valueOf(...) doesn't handle hex decimal floats
    try {
       [[#variablebf96a560]] v = FloatUtil. [[#variablebf96a460]](source);
      if (v == [[#variablebf96a5c0]].POSITIVE_INFINITY) {
        // error: the number is too large to represent
        return;
      }
      if ( [[#variablebf96a5c0]].isNaN(v)) {
        // error: the number is too small to represent
        return;
      }
      value = v;
      constant = [[#variablebf96a2e0]].fromValue(v);
    }
    catch (NumberFormatException e1) {
    // if the computation of the constant fails
    }
    return;
  }
  final [[#variablebf96a560]]  [[#variablebf96a3e0]]= computedValue. [[#variablebf96a3e0]]();
  if ( [[#variablebf96a3e0]] >  [[#variablebf96a5c0]].MAX_VALUE) {
    // error: the number is too large to represent
    return;
  }
  if ( [[#variablebf96a3e0]] <  [[#variablebf96a5c0]].MIN_VALUE) {
    // see 1F6IGUU
    // a true 0 only has '0' and '.' in mantissa
    // 1.0e-5000d is non-zero, but underflows to 0
    boolean isHexaDecimal = false;
    label:
      for (int i = 0; i < source.length; i++) { //it is welled formated so just test against '0' and potential . D d  
        switch (source[i]) {
          case '0':
          case '.':
            break;
          case 'x':
          case 'X':
            isHexaDecimal = true;
            break;
          case 'e':
          case 'E':
          case 'f':
          case 'F':
          case 'd':
          case 'D':
            if (isHexaDecimal) {
              return;
            }
            // starting the exponent - mantissa is all zero
            // no exponent - mantissa is all zero
            break label;
          case 'p':
          case 'P':
            break label;
          default:
            // error: the number is too small to represent
            return;
        }
      }
  }
  value = [[#variablebf96a3e0]];
  constant = [[#variablebf96a2e0]].fromValue(value);
}

/**
         * Code generation for the double literak
         *
         * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
         * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
         * @param valueRequired boolean
         */
/**
         * Code generation for float literal
         *
         * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
         * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
         * @param valueRequired boolean
         */
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
  int pc = codeStream.position;
  if (valueRequired) {
    codeStream.generateConstant(constant, implicitConversion);
  }
  codeStream.recordPositionsFrom(pc, this.sourceStart);
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#bf96a660]]
DoubleLiteral 
12[[#bf96a660]]
FloatLiteral 
21[[#bf96a5c0]]
Double 
22[[#bf96a5c0]]
Float 
31[[#bf96a560]]
double 
32[[#bf96a560]]
float 
41[[#bf96a460]]
valueOfHexDoubleLiteral 
42[[#bf96a460]]
valueOfHexFloatLiteral 
51[[#bf96a2e0]]
DoubleConstant 
52[[#bf96a2e0]]
FloatConstant 
61[[#bf96a3e0]]
doubleValue 
62[[#bf96a3e0]]
floatValue