Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 1 | // 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 | |
| 10 | namespace art { |
| 11 | |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 12 | class Instruction { |
| 13 | public: |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 14 | enum Code { |
Carl Shapiro | d84f49c | 2011-06-29 00:27:46 -0700 | [diff] [blame^] | 15 | #define INSTRUCTION_ENUM(cname, opcode) cname = opcode, |
| 16 | #include "src/dex_instruction_list.h" |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 17 | DEX_INSTRUCTION_LIST(INSTRUCTION_ENUM) |
Carl Shapiro | d84f49c | 2011-06-29 00:27:46 -0700 | [diff] [blame^] | 18 | #undef DEX_INSTRUCTION_LIST |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 19 | #undef INSTRUCTION_ENUM |
Carl Shapiro | d84f49c | 2011-06-29 00:27:46 -0700 | [diff] [blame^] | 20 | }; |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 21 | |
| 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_ |