blob: b233ad588d3037e2c8c17d7f31a12ee89031309b [file] [log] [blame]
Carl Shapiro12eb78e2011-06-24 14:51:06 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#ifndef ART_SRC_DEX_INSTRUCTION_H_
4#define ART_SRC_DEX_INSTRUCTION_H_
5
6#include "src/globals.h"
7#include "src/logging.h"
8#include "src/macros.h"
9
10namespace art {
11
Carl Shapiro12eb78e2011-06-24 14:51:06 -070012class Instruction {
13 public:
Carl Shapiro12eb78e2011-06-24 14:51:06 -070014 enum Code {
Carl Shapirod84f49c2011-06-29 00:27:46 -070015#define INSTRUCTION_ENUM(cname, opcode) cname = opcode,
16#include "src/dex_instruction_list.h"
Carl Shapiro12eb78e2011-06-24 14:51:06 -070017 DEX_INSTRUCTION_LIST(INSTRUCTION_ENUM)
Carl Shapirod84f49c2011-06-29 00:27:46 -070018#undef DEX_INSTRUCTION_LIST
Carl Shapiro12eb78e2011-06-24 14:51:06 -070019#undef INSTRUCTION_ENUM
Carl Shapirod84f49c2011-06-29 00:27:46 -070020 };
Carl Shapiro12eb78e2011-06-24 14:51:06 -070021
22 // Returns the size in bytes of this instruction.
23 size_t Size();
24
25 // Returns a pointer to the next instruction in the stream.
26 const Instruction* Next();
27
28 // Returns the opcode field of the instruction.
29 Code Opcode();
30
31 // Reads an instruction out of the stream at the specified address.
32 static Instruction* At(byte* code) {
33 CHECK(code != NULL);
34 return reinterpret_cast<Instruction*>(code);
35 }
36
37 private:
38 DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction);
39};
40
41} // namespace art
42
43#endif // ART_SRC_DEX_INSTRUCTION_H_