1 /*
   2  * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.core.common.util;
  26 
  27 /**
  28  * Provides low-level sequential write access for signed and unsigned values of size 1, 2, 4, and 8
  29  * bytes.
  30  */
  31 public interface TypeWriter {
  32     /**
  33      * Returns the number of bytes that have been written, i.e., the byte index of the next byte to
  34      * be written.
  35      */
  36     long getBytesWritten();
  37 
  38     /** Writes a signed 1 byte value. */
  39     void putS1(long value);
  40 
  41     /** Writes an unsigned 1 byte value. */
  42     void putU1(long value);
  43 
  44     /** Writes a signed 2 byte value. */
  45     void putS2(long value);
  46 
  47     /** Writes an unsigned 2 byte value. */
  48     void putU2(long value);
  49 
  50     /** Writes a signed 4 byte value. */
  51     void putS4(long value);
  52 
  53     /** Patches a previously written signed 4 byte value at a given offset. */
  54     void patchS4(long value, long offset);
  55 
  56     /** Writes an unsigned 4 byte value. */
  57     void putU4(long value);
  58 
  59     /** Writes a signed 8 byte value. */
  60     void putS8(long value);
  61 
  62     /** Writes a signed value in a variable byte size encoding. */
  63     void putSV(long value);
  64 
  65     /** Writes an unsigned value in a variable byte size encoding. */
  66     void putUV(long value);
  67 }