OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/interpreter/bytecodes.h" |
| 6 |
| 7 namespace v8 { |
| 8 namespace internal { |
| 9 namespace interpreter { |
| 10 |
| 11 // static |
| 12 const char* Bytecodes::ToString(Bytecode bytecode) { |
| 13 switch (bytecode) { |
| 14 #define CASE(Name, _) \ |
| 15 case Bytecode::k##Name: \ |
| 16 return #Name; |
| 17 BYTECODE_LIST(CASE) |
| 18 #undef CASE |
| 19 } |
| 20 UNREACHABLE(); |
| 21 return ""; |
| 22 } |
| 23 |
| 24 |
| 25 // static |
| 26 const int Bytecodes::NumberOfArguments(Bytecode bytecode) { |
| 27 switch (bytecode) { |
| 28 #define CASE(Name, arg_count) \ |
| 29 case Bytecode::k##Name: \ |
| 30 return arg_count; |
| 31 BYTECODE_LIST(CASE) |
| 32 #undef CASE |
| 33 } |
| 34 UNREACHABLE(); |
| 35 return 0; |
| 36 } |
| 37 |
| 38 |
| 39 // static |
| 40 const int Bytecodes::Size(Bytecode bytecode) { |
| 41 return NumberOfArguments(bytecode) + 1; |
| 42 } |
| 43 |
| 44 |
| 45 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { |
| 46 return os << Bytecodes::ToString(bytecode); |
| 47 } |
| 48 |
| 49 } // namespace interpreter |
| 50 } // namespace internal |
| 51 } // namespace v8 |
OLD | NEW |