Ejemplo n.º 1
0
    @Override
    public void apply(OpStack opStack, LocalVariableTypes localVarTypes)
        throws IncompatibleStackEffectException, IncompatibleVariableException,
            ClassesNotLoadedException {

      Type itemType;
      try {
        itemType = opStack.content.pop();
      } catch (EmptyStackException e) {
        throw new IncompatibleStackEffectException("OpStack Underflow", e);
      }

      Type indexType;
      try {
        indexType = opStack.content.pop();
      } catch (EmptyStackException e) {
        throw new IncompatibleStackEffectException("OpStack Underflow", e);
      }
      if (!ScalarType.scalar(TypeType.INT).isAssignableFrom(indexType))
        throw new IncompatibleStackEffectException();

      Type valueType;
      try {
        valueType = opStack.content.pop();
      } catch (EmptyStackException e) {
        throw new IncompatibleStackEffectException("OpStack Underflow", e);
      }
      if (valueType.type != TypeType.ARRAY_REF) throw new IncompatibleStackEffectException();
      ArrayRefType arrayRefType = (ArrayRefType) valueType;
      if (arrayRefType.elemType.type != this.type) throw new IncompatibleStackEffectException();

      if (!itemType.isAssignableFrom(arrayRefType.elemType))
        throw new IncompatibleStackEffectException();
    }
Ejemplo n.º 2
0
  /**
   * Returns the hash code for this ScalarMap. If <code>scalarMap1.equals(
   * scalarMap2)</code> is true, then <code>scalarMap1.hashCode() ==
   * scalarMap2.hashCode()</code>.
   *
   * @return The hash code for this ScalarMap.
   */
  public int hashCode() {
    ScalarType s = getScalar();
    DisplayRealType ds = getDisplayScalar();

    int hash = 0;
    if (s != null) {
      if (ds != null) {
        hash = s.hashCode() ^ ds.hashCode();
      } else {
        hash = s.hashCode();
      }
    } else if (ds != null) {
      hash = ds.hashCode();
    }

    return hash;
  }
Ejemplo n.º 3
0
 public TableJumpInstruction(
     InstructionCode code,
     InstructionReference instrRef,
     SortedMap<Integer, InstructionReference> jumpTable) {
   super(code);
   this.defaultInstr = instrRef;
   this.jumpTable = jumpTable;
   this.effect = Effect.make().get(ScalarType.scalar(TypeType.INT));
 }
Ejemplo n.º 4
0
 /**
  * Change underscore characters (_) in the Scalar name to blanks. Can be used to change the
  * displayed scalar name on the axis.
  *
  * @param u2b true to change, false to change back
  * @see #setScalarName as an alternative
  */
 public void setUnderscoreToBlank(boolean u2b) {
   underscore_to_blank = u2b;
   if (Scalar != null) {
     scalarName = Scalar.getName();
     if (underscore_to_blank) {
       scalarName = scalarName.replace('_', ' ');
     }
     // set the label on the scale as well.  DRM 17-Nov-2000
     if (axisScale != null) axisScale.setTitle(scalarName);
   }
 }
Ejemplo n.º 5
0
 ScalarMap(ScalarType scalar, DisplayRealType display_scalar, boolean needNonNullScalar)
     throws VisADException {
   if (scalar == null && needNonNullScalar) {
     throw new DisplayException("ScalarMap: scalar is null");
   }
   if (display_scalar == null) {
     throw new DisplayException("ScalarMap: display_scalar is null");
   }
   if (display_scalar.equals(Display.List)) {
     throw new DisplayException("ScalarMap: display_scalar may not be List");
   }
   boolean text = display_scalar.getText();
   if (scalar != null) {
     /* WLH 15 June 2000
           if (text && !(scalar instanceof TextType)) {
             throw new DisplayException("ScalarMap: RealType scalar cannot be " +
                                        "used with TextType display_scalar");
           }
     */
     if (!text && !(scalar instanceof RealType)) {
       throw new DisplayException(
           "ScalarMap: TextType scalar cannot be " + "used with RealType display_scalar");
     }
   }
   control = null;
   Scalar = scalar;
   DisplayScalar = display_scalar;
   display = null;
   ScalarIndex = -1;
   DisplayScalarIndex = -1;
   isScaled = DisplayScalar.getRange(displayRange);
   isManual = false;
   dataRange[0] = Double.NaN;
   dataRange[1] = Double.NaN;
   defaultUnitRange[0] = dataRange[0];
   defaultUnitRange[1] = dataRange[1];
   OldTick = Long.MIN_VALUE;
   NewTick = Long.MIN_VALUE + 1;
   tickFlag = false;
   if (Scalar != null) scalarName = Scalar.getName();
   if (DisplayScalar.equals(Display.XAxis)
       || DisplayScalar.equals(Display.YAxis)
       || DisplayScalar.equals(Display.ZAxis)) {
     axisScale = new AxisScale(this);
   }
 }
Ejemplo n.º 6
0
 public static Effect.Static makeUnOp(TypeType type) {
   return Effect.make().get(ScalarType.scalar(type)).put(ScalarType.scalar(type));
   // return new Effect.Static(new Effect.Static.StackOp[] { new
   // Effect.Static.StackOp(Type.scalar(type), Effect.Direction.GET), new
   // Effect.Static.StackOp(Type.scalar(type), Effect.Direction.PUT) });
 }
Ejemplo n.º 7
0
 /**
  * Returns a string representation of the ScalarMap with the specified prefix prepended.
  *
  * @param pre prefix to prepend to the representation
  * @return a string that "textually represents" this ScalarMap with <CODE>pre</CODE> prepended.
  */
 public String toString(String pre) {
   return pre + "ScalarMap: " + Scalar.toString() + " -> " + DisplayScalar.toString() + "\n";
 }