Example #1
0
  mymemory() {
    mem = new int[65536];
    for (int i = 0; i < 65536; i++) mem[i] = 0;

    try {
      DataInput in = new DataInputStream(new FileInputStream("zexdoc.com"));
      for (int i = 0; i < 8704; i++) mem[i + 0x100] = (int) (in.readByte() & 0xFF);
    } catch (Exception e) {
      System.out.println("Cannot read mc1000.rom");
      System.exit(1);
    }

    mem[5] = 0x32;
    mem[6] = 0x00;
    mem[7] = 0x00;
    mem[8] = 0x79;
    mem[9] = 0x32;
    mem[10] = 0x81;
    mem[11] = 0x00;
    mem[12] = 0x7b;
    mem[13] = 0x32;
    mem[14] = 0x82;
    mem[15] = 0x00;
    mem[16] = 0x7a;
    mem[17] = 0x32;
    mem[18] = 0x83;
    mem[19] = 0x00;
    mem[20] = 0xc9;
  }
Example #2
0
 void read(DataInput in) throws IOException {
   setStartPc(in.readUnsignedShort());
   setLength(in.readUnsignedShort());
   setNameIndex(in.readUnsignedShort());
   setTypeIndex(in.readUnsignedShort());
   setLocal(in.readUnsignedShort());
 }
  private CharStringCommand readCommand(int b0, DataInput input) throws IOException {

    if (b0 == 1 || b0 == 18) {
      hstemCount += peekNumbers().size() / 2;
    } else if (b0 == 3 || b0 == 19 || b0 == 20 || b0 == 23) {
      vstemCount += peekNumbers().size() / 2;
    } // End if

    if (b0 == 12) {
      int b1 = input.readUnsignedByte();

      return new CharStringCommand(b0, b1);
    } else if (b0 == 19 || b0 == 20) {
      int[] value = new int[1 + getMaskLength()];
      value[0] = b0;

      for (int i = 1; i < value.length; i++) {
        value[i] = input.readUnsignedByte();
      }

      return new CharStringCommand(value);
    }

    return new CharStringCommand(b0);
  }
  private static Integer readNumber(int b0, DataInput input) throws IOException {

    if (b0 == 28) {
      int b1 = input.readUnsignedByte();
      int b2 = input.readUnsignedByte();

      return (int) (short) (b1 << 8 | b2);
    } else if (b0 >= 32 && b0 <= 246) {
      return b0 - 139;
    } else if (b0 >= 247 && b0 <= 250) {
      int b1 = input.readUnsignedByte();

      return (b0 - 247) * 256 + b1 + 108;
    } else if (b0 >= 251 && b0 <= 254) {
      int b1 = input.readUnsignedByte();

      return -(b0 - 251) * 256 - b1 - 108;
    } else if (b0 == 255) {
      int b1 = input.readUnsignedByte();
      int b2 = input.readUnsignedByte();
      // The lower bytes are representing the digits after
      // the decimal point and aren't needed in this context
      input.readUnsignedByte();
      input.readUnsignedByte();
      return (int) (short) (b1 << 8 | b2);
    } else {
      throw new IllegalArgumentException();
    }
  }
 @Override
 public void readFields(DataInput in) throws IOException {
   RowKeySchema schema = new RowKeySchema();
   schema.readFields(in);
   int maxLength = getTerminatorCount(schema);
   int andLen = in.readInt();
   List<List<KeyRange>> slots = Lists.newArrayListWithExpectedSize(andLen);
   for (int i = 0; i < andLen; i++) {
     int orlen = in.readInt();
     List<KeyRange> orclause = Lists.newArrayListWithExpectedSize(orlen);
     slots.add(orclause);
     int maxSlotLength = 0;
     for (int j = 0; j < orlen; j++) {
       KeyRange range = new KeyRange();
       range.readFields(in);
       if (range.getLowerRange().length > maxSlotLength) {
         maxSlotLength = range.getLowerRange().length;
       }
       if (range.getUpperRange().length > maxSlotLength) {
         maxSlotLength = range.getUpperRange().length;
       }
       orclause.add(range);
     }
     maxLength += maxSlotLength;
   }
   this.init(slots, schema, maxLength);
 }
Example #6
0
  private static Node deserializeNode(DataInput input) throws IOException {
    int level = input.readUnsignedByte();
    long value = input.readLong();
    double weight = input.readDouble();

    return new Node(value, level, weight);
  }
 @Override
 public void fromData(DataInput in) throws IOException, ClassNotFoundException {
   this.prId = in.readInt();
   this.scope = Scope.fromOrdinal(in.readByte());
   this.pAttrs = PartitionAttributesImpl.createFromData(in);
   this.isDestroying = in.readBoolean();
   this.isColocationComplete = in.readBoolean();
   this.nodes = new VersionedArrayList();
   InternalDataSerializer.invokeFromData(this.nodes, in);
   this.partitionResolver = DataSerializer.readString(in);
   this.colocatedWith = DataSerializer.readString(in);
   this.fullPath = DataSerializer.readString(in);
   this.ea = EvictionAttributesImpl.createFromData(in);
   this.regionIdleTimeout = ExpirationAttributes.createFromData(in);
   this.regionTimeToLive = ExpirationAttributes.createFromData(in);
   this.entryIdleTimeout = ExpirationAttributes.createFromData(in);
   this.entryTimeToLive = ExpirationAttributes.createFromData(in);
   this.firstDataStoreCreated = in.readBoolean();
   this.elderFPAs = DataSerializer.readObject(in);
   if (this.elderFPAs == null) {
     this.elderFPAs = new LinkedHashSet<FixedPartitionAttributesImpl>();
   }
   this.partitionListenerClassNames = DataSerializer.readArrayList(in);
   this.gatewaySenderIds = DataSerializer.readObject(in);
   if (this.gatewaySenderIds == null) {
     this.gatewaySenderIds = Collections.emptySet();
   }
 }
Example #8
0
 /*
  * Read a String as a Network Int n, followed by n Bytes
  * Alternative to 16 bit read/writeUTF.
  * Encoding standard is... ?
  *
  */
 public static String readString(DataInput in) throws IOException {
   int length = in.readInt();
   if (length == -1) return null;
   byte[] buffer = new byte[length];
   in.readFully(buffer); // could/should use readFully(buffer,0,length)?
   return new String(buffer, "UTF-8");
 }
 @Override
 public void fromData(DataInput in) throws IOException, ClassNotFoundException {
   super.fromData(in);
   this.attributeCode = in.readByte();
   this.newValue = in.readInt();
   this.cacheId = in.readInt();
 }
Example #10
0
    @Override
    public String deserialize(DataInput in, int available) throws IOException {
      int nsize = in.readInt();
      byte[] buf = new byte[nsize];
      in.readFully(buf);

      return bytArrayToHex(buf);
    }
 public static String readLongString(DataInput in) throws IOException {
   int count = in.readInt();
   StringBuilder sb = new StringBuilder();
   for (int i = 0; i < count; i++) {
     sb.append(in.readUTF());
   }
   return sb.toString();
 }
 public Set<String> read(DataInput s) throws IOException {
   int count = s.readInt();
   Set<String> result = new THashSet<String>(count);
   while (count-- > 0) {
     result.add(s.readUTF());
   }
   return result;
 }
Example #13
0
 public void readFields(DataInput in) throws IOException {
   this.blockId = in.readLong();
   this.numBytes = in.readLong();
   this.generationStamp = in.readLong();
   if (numBytes < 0) {
     throw new IOException("Unexpected block size: " + numBytes);
   }
 }
Example #14
0
  public void readObject(DataInput in) throws IOException {
    super.readObject(in);

    ((Node) node).setBounds(control.readBounds(in));

    ((Node) node).setPickable(in.readBoolean());
    ((Node) node).setCollidable(in.readBoolean());
    ((Node) node).setBoundsAutoCompute(in.readBoolean());
  }
  private void readCapabilities(DataInput in) throws IOException {
    long capabilities = in.readLong();
    long frequentCapabilities = in.readLong();

    for (int i = 0; i < 64; i++) {
      if ((capabilities & (1L << i)) != 0L) node.setCapability(i);
      if ((frequentCapabilities & (1L << i)) != 0L) node.clearCapabilityIsFrequent(i);
    }
  }
Example #16
0
 public void readFrom(DataInput in) throws Exception {
   status = in.readInt();
   classname = Bits.readString(in);
   name = Bits.readString(in);
   start_time = in.readLong();
   stop_time = in.readLong();
   failure_type = Bits.readString(in);
   failure_msg = Bits.readString(in);
   stack_trace = Bits.readString(in);
 }
Example #17
0
 /**
  * {@inheritDoc}
  *
  * @see Writable#readFields(DataInput)
  */
 public void readFields(DataInput in) throws IOException {
   BSONDecoder dec = new BSONDecoder();
   BSONCallback cb = new BasicBSONCallback();
   // Read the BSON length from the start of the record
   int dataLen = in.readInt();
   byte[] buf = new byte[dataLen];
   in.readFully(buf);
   dec.decode(buf, cb);
   _doc = (BSONObject) cb.get();
   log.info("Decoded a BSON Object: " + _doc);
 }
Example #18
0
 ObjectModelValue(final DataInput in) throws IOException {
   super(ModelType.OBJECT);
   final int count = in.readInt();
   final LinkedHashMap<String, ModelNode> map = new LinkedHashMap<String, ModelNode>();
   for (int i = 0; i < count; i++) {
     final String key = in.readUTF();
     final ModelNode value = new ModelNode();
     value.readExternal(in);
     map.put(key, value);
   }
   this.map = map;
 }
Example #19
0
  @SuppressWarnings("unchecked")
  void load(DataInput dis) throws IOException {
    type = dis.readByte();
    int size = dis.readInt();

    list = new ArrayList<T>();
    for (int i = 0; i < size; i++) {
      Tag tag = Tag.newTag(type, null);
      tag.load(dis);
      list.add((T) tag);
    }
  }
Example #20
0
    @Override
    public GeobufFeature deserialize(DataInput dataInput, int i) throws IOException {
      int len = dataInput.readInt();
      byte[] feat = new byte[len];
      dataInput.readFully(feat);
      Geobuf.Data data = Geobuf.Data.parseFrom(feat);

      return new GeobufFeature(
          data.getFeatureCollection().getFeatures(0),
          data.getKeysList(),
          Math.pow(10, data.getPrecision()));
    }
Example #21
0
    public IndexScanCommand deserialize(DataInput in, int version) throws IOException {
      String keyspace = in.readUTF();
      String columnFamily = in.readUTF();

      TDeserializer dser = new TDeserializer(new TBinaryProtocol.Factory());
      IndexClause indexClause = new IndexClause();
      FBUtilities.deserialize(dser, indexClause, in);
      SlicePredicate predicate = new SlicePredicate();
      FBUtilities.deserialize(dser, predicate, in);
      AbstractBounds<RowPosition> range =
          AbstractBounds.serializer().deserialize(in, version).toRowBounds();
      return new IndexScanCommand(keyspace, columnFamily, indexClause, predicate, range);
    }
Example #22
0
 public void readFrom(DataInput in) throws Exception {
   type = in.readByte();
   boolean isMergeView = in.readBoolean();
   if (isMergeView) view = (View) Util.readStreamable(MergeView.class, in);
   else view = (View) Util.readStreamable(View.class, in);
   mbr = Util.readAddress(in);
   mbrs = Util.readAddresses(in, ArrayList.class);
   join_rsp = (JoinRsp) Util.readStreamable(JoinRsp.class, in);
   my_digest = (Digest) Util.readStreamable(Digest.class, in);
   merge_id = (MergeId) Util.readStreamable(MergeId.class, in);
   merge_rejected = in.readBoolean();
   useFlushIfPresent = in.readBoolean();
 }
 public void readFields(DataInput in) throws IOException {
   blockToken.readFields(in);
   this.corrupt = in.readBoolean();
   offset = in.readLong();
   this.b = new Block();
   b.readFields(in);
   int count = in.readInt();
   this.locs = new DatanodeInfo[count];
   for (int i = 0; i < locs.length; i++) {
     locs[i] = new DatanodeInfo();
     locs[i].readFields(in);
   }
 }
Example #24
0
 /**
  * Reads a zero-compressed encoded long from input stream and returns it.
  *
  * @param stream Binary input stream
  * @throws java.io.IOException
  * @return deserialized long from stream.
  */
 public static long readVLong(DataInput stream) throws IOException {
   byte firstByte = stream.readByte();
   int len = decodeVIntSize(firstByte);
   if (len == 1) {
     return firstByte;
   }
   long i = 0;
   for (int idx = 0; idx < len - 1; idx++) {
     byte b = stream.readByte();
     i = i << 8;
     i = i | (b & 0xFF);
   }
   return (isNegativeVInt(firstByte) ? (i ^ -1L) : i);
 }
Example #25
0
 // Used for internal Hadoop purposes
 // Describes how to read this node from across a network
 public void readFields(DataInput in) throws IOException {
   nodeid = in.readLong();
   pageRank = in.readDouble();
   long next = in.readLong();
   ArrayList<Long> ins = new ArrayList<Long>();
   while (next != -1) {
     ins.add(next);
     next = in.readLong();
   }
   outgoing = new long[ins.size()];
   for (int i = 0; i < ins.size(); i++) {
     outgoing[i] = ins.get(i);
   }
 }
  /**
   * Read a long previously written by writeLong().
   *
   * @exception IOException an exception was thrown by a method on in.
   */
  public static final long readLong(DataInput in) throws IOException {

    int int_value = in.readUnsignedByte();

    if ((int_value & ~0x3f) == 0) {
      // test for small case first - assuming this is usual case.
      // this is stored in 2 bytes.

      return ((int_value << 8) | in.readUnsignedByte());
    } else if ((int_value & 0x80) == 0) {
      // value is stored in 4 bytes.  only use low 6 bits from 1st byte.

      return (((int_value & 0x3f) << 24)
          | (in.readUnsignedByte() << 16)
          | (in.readUnsignedByte() << 8)
          | (in.readUnsignedByte()));
    } else {
      // value is stored in 8 bytes.  only use low 7 bits from 1st byte.
      return ((((long) (int_value & 0x7f)) << 56)
          | (((long) in.readUnsignedByte()) << 48)
          | (((long) in.readUnsignedByte()) << 40)
          | (((long) in.readUnsignedByte()) << 32)
          | (((long) in.readUnsignedByte()) << 24)
          | (((long) in.readUnsignedByte()) << 16)
          | (((long) in.readUnsignedByte()) << 8)
          | (((long) in.readUnsignedByte())));
    }
  }
  public LocalVariableTable_attribute(ConstantPool constantPool, Visitable owner, DataInput in)
      throws IOException {
    super(constantPool, owner);

    int byteCount = in.readInt();
    Logger.getLogger(getClass()).debug("Attribute length: " + byteCount);

    int localVariableTableLength = in.readUnsignedShort();
    Logger.getLogger(getClass())
        .debug("Reading " + localVariableTableLength + " local variable(s) ...");
    for (int i = 0; i < localVariableTableLength; i++) {
      Logger.getLogger(getClass()).debug("Local variable " + i + ":");
      localVariables.add(new LocalVariable(this, in));
    }
  }
Example #28
0
 @SuppressWarnings("deprecation")
 public void readFields(DataInput in) throws IOException {
   rpcVersion = in.readLong();
   declaringClassProtocolName = UTF8.readString(in);
   methodName = UTF8.readString(in);
   clientVersion = in.readLong();
   clientMethodsHash = in.readInt();
   parameters = new Object[in.readInt()];
   parameterClasses = new Class[parameters.length];
   ObjectWritable objectWritable = new ObjectWritable();
   for (int i = 0; i < parameters.length; i++) {
     parameters[i] = ObjectWritable.readObject(in, objectWritable, this.conf);
     parameterClasses[i] = objectWritable.getDeclaredClass();
   }
 }
    public TreeRequest deserialize(DataInput dis, int version) throws IOException {
      String sessId = dis.readUTF();
      InetAddress endpoint = CompactEndpointSerializationHelper.deserialize(dis);
      CFPair cfpair = new CFPair(dis.readUTF(), dis.readUTF());
      Range<Token> range;
      if (version > MessagingService.VERSION_07)
        range = (Range<Token>) AbstractBounds.serializer().deserialize(dis, version);
      else
        range =
            new Range<Token>(
                StorageService.getPartitioner().getMinimumToken(),
                StorageService.getPartitioner().getMinimumToken());

      return new TreeRequest(sessId, endpoint, range, cfpair);
    }
  static Attribute define(ConstantPool cp, String name, int length, DataInput din)
      throws IOException {

    LineNumberTableAttr lineNumbers = new LineNumberTableAttr(cp);

    int size = din.readUnsignedShort();
    for (int i = 0; i < size; i++) {
      int start_pc = din.readUnsignedShort();
      int line_number = din.readUnsignedShort();

      lineNumbers.addEntry(new FixedLocation(start_pc), line_number);
    }

    return lineNumbers;
  }