constantrecord.java

来自「专业汽车级嵌入式操作系统OSEK的源代码」· Java 代码 · 共 93 行

JAVA
93
字号
package js.tinyvm;import java.io.IOException;import js.tinyvm.io.IByteWriter;import js.tinyvm.io.IOUtilities;import org.apache.bcel.classfile.Constant;import org.apache.bcel.classfile.ConstantPool;public class ConstantRecord implements WritableData{   /**    * Constant.    */   Constant _constant;   /**    * Deferenced value.    */   ConstantValue _constantValue;   /**    * Constructor.    *     * @param pool constant pool    * @param constant constant    */   public ConstantRecord (ConstantPool pool, Constant constant)   {      _constantValue = new ConstantValue(pool, constant);   }   /**    * Get dereferenced value.    */   public ConstantValue constantValue ()   {      assert _constantValue != null: "Postconditon: result != null";      return _constantValue;   }   /**    * Equals based on equality of referenced value.    */   public boolean equals (Object object)   {      return object instanceof ConstantRecord         && _constantValue.value().equals(            ((ConstantRecord) object)._constantValue.value());   }   /**    * hashCode based on referenced value.    */   public int hashCode ()   {      return _constantValue.value().hashCode();   }   /**    * Get length of this record.    */   public int getLength ()   {      return IOUtilities.adjustedSize(2 + // offset         1 + // type         1, // size         2);   }   /**    * Dump.    *     * @param writer byte writer    */   public void dump (IByteWriter writer) throws TinyVMException   {      assert writer != null: "Precondition: writer != null";      try      {         writer.writeU2(_constantValue.getOffset());         writer.writeU1(_constantValue.getType().type());         writer.writeU1(_constantValue.getLength());         IOUtilities.writePadding(writer, 2);      }      catch (IOException e)      {         throw new TinyVMException(e.getMessage(), e);      }   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?