// Copyright 2015 Project Vogue. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_
#define ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_

#include "base/basictypes.h"

namespace elang {
namespace lir {

class CodeBuffer;
struct Value;

//////////////////////////////////////////////////////////////////////
//
// CodeBufferUser
//
class CodeBufferUser {
 protected:
  explicit CodeBufferUser(CodeBuffer* code_buffer);
  ~CodeBufferUser();

  void AssociateValue(Value value);
  void Emit16(int data);
  void Emit32(uint32_t data);
  void Emit64(uint64_t data);
  void Emit8(int data);

 private:
  CodeBuffer* const code_buffer_;

  DISALLOW_COPY_AND_ASSIGN(CodeBufferUser);
};

}  // namespace lir
}  // namespace elang

#endif  // ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_

// Copyright 2015 Project Vogue. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_
#define ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_

#include "base/basictypes.h"

namespace elang {
namespace lir {

class CodeBuffer;
struct Value;

//////////////////////////////////////////////////////////////////////
//
// CodeBufferUser
//
class CodeBufferUser {
 protected:
  explicit CodeBufferUser(CodeBuffer* code_buffer);
  ~CodeBufferUser();

  CodeBuffer* code_buffer() const { return code_buffer_; }

  void AssociateValue(Value value);
  void Emit16(int data);
  void Emit32(uint32_t data);
  void Emit64(uint64_t data);
  void Emit8(int data);

 private:
  CodeBuffer* const code_buffer_;

  DISALLOW_COPY_AND_ASSIGN(CodeBufferUser);
};

}  // namespace lir
}  // namespace elang

#endif  // ELANG_LIR_EMITTERS_CODE_BUFFER_USER_H_

Introduce |CodeBufferUser::code_buffer()| to use |CodeBuffer::EmitJump()| for 'br' instruction emitter.
elang/lir/emitters: Introduce |CodeBufferUser::code_buffer()| to use |CodeBuffer::EmitJump()| for 'br' instruction emitter.
