Package wyfs.io

Examples of wyfs.io.BinaryOutputStream


        }
        index++;
      }

      if(binary) {
        BinaryOutputStream bos = new BinaryOutputStream(out);
        writer = new BinaryTypeWriter(bos);
      } else {
        writer = new TextTypeWriter(out);
      }
View Full Code Here


    myOut();

    for (int i = 0; i != typeRegister.size(); ++i) {
      Type t = typeRegister.get(i);
      JavaIdentifierOutputStream jout = new JavaIdentifierOutputStream();
      BinaryOutputStream bout = new BinaryOutputStream(jout);
      bout.write(t.toBytes());
      bout.flush();
      bout.close();
      // FIXME: strip out nominal types (and any other unneeded types).
      myOut(1, "// " + t);
      myOut(1, "private static Type type" + i + " = Runtime.Type(\""
          + jout.toString() + "\");");
    }
View Full Code Here

  private final HashMap<Value,Integer> constantCache = new HashMap<Value,Integer>();
  private final ArrayList<SemanticType> typePool = new ArrayList<SemanticType>();
  private final HashMap<SemanticType,Integer> typeCache = new HashMap<SemanticType,Integer>();

  public WycsFileWriter(OutputStream output) {
    this.out = new BinaryOutputStream(output);
  }
View Full Code Here

   * @throws IOException
   */
  private byte[] generateHeaderBlock(WycsFile module)
      throws IOException {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    BinaryOutputStream output = new BinaryOutputStream(bytes);

    // second, write the file version number
    output.write_uv(MAJOR_VERSION);
    output.write_uv(MINOR_VERSION);

    // third, write the various pool sizes
    output.write_uv(stringPool.size());
    output.write_uv(pathPool.size());
    output.write_uv(namePool.size());
    output.write_uv(typePool.size());
    output.write_uv(constantPool.size());

    // finally, write the number of remaining blocks
    output.write_uv(module.declarations().size());

    writeStringPool(output);
    writePathPool(output);
    writeNamePool(output);
    writeTypePool(output);
    writeConstantPool(output);

    output.close();

    return bytes.toByteArray();
  }
View Full Code Here

    return bytes.toByteArray();
  }

  private byte[] generateModuleBlock(WycsFile module) throws IOException {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    BinaryOutputStream output = new BinaryOutputStream(bytes);

    output.write_uv(pathCache.get(module.id())); // FIXME: BROKEN!
    output.write_uv(module.declarations().size());

    for (WycsFile.Declaration d : module.declarations()) {
      writeModuleBlock(d, output);
    }

    output.close();

    return bytes.toByteArray();
  }
View Full Code Here

    }
  }

  private byte[] generateMacroBlock(WycsFile.Macro md) throws IOException {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    BinaryOutputStream output = new BinaryOutputStream(bytes);

    output.write_uv(stringCache.get(md.name()));
    output.write_uv(typeCache.get(md.type));
    output.write_uv(1);
    writeBlock(BLOCK_Code,md.condition,output);

    output.close();
    return bytes.toByteArray();
  }
View Full Code Here

    return bytes.toByteArray();
  }

  private byte[] generateFunctionBlock(WycsFile.Function fd) throws IOException {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    BinaryOutputStream output = new BinaryOutputStream(bytes);

    output.write_uv(stringCache.get(fd.name()));
    output.write_uv(typeCache.get(fd.type));
    if(fd.constraint == null) {
      output.write_uv(0); // no sub-blocks
    } else {
      output.write_uv(1); // one sub-block
      writeBlock(BLOCK_Code,fd.constraint,output);
    }

    output.close();
    return bytes.toByteArray();
  }
View Full Code Here

    return bytes.toByteArray();
  }

  private byte[] generateAssertBlock(WycsFile.Assert td) throws IOException {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    BinaryOutputStream output = new BinaryOutputStream(bytes);

    output.write_uv(stringCache.get(td.name()));
    output.write_uv(1); // one sub-block
    writeBlock(BLOCK_Code,td.condition,output);

    output.close();
    return bytes.toByteArray();
  }
View Full Code Here

   * @return
   * @throws IOException
   */
  private byte[] generateCodeBlock(Code<?> code) throws IOException {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    BinaryOutputStream output = new BinaryOutputStream(bytes);

    writeCode(code,output);

    output.close();
    return bytes.toByteArray();
  }
View Full Code Here

  }

  protected void translate(Constant.Type e, int freeSlot,
      ArrayList<Bytecode> bytecodes) {
    JavaIdentifierOutputStream jout = new JavaIdentifierOutputStream();
    BinaryOutputStream bout = new BinaryOutputStream(jout);
    Type.BinaryWriter writer = new Type.BinaryWriter(bout);
    try {
      writer.write(e.type);
      writer.close();
    } catch(IOException ex) {
View Full Code Here

TOP

Related Classes of wyfs.io.BinaryOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.