| 1 | // Copyright © 2004-2006 University of Helsinki, Department of Computer Science | |
| 2 | // Copyright © 2012 various contributors | |
| 3 | // This software is released under GNU Lesser General Public License 2.1. | |
| 4 | // The license text is at http://www.gnu.org/licenses/lgpl-2.1.html | |
| 5 | ||
| 6 | package fi.helsinki.cs.ttk91; | |
| 7 | ||
| 8 | /** | |
| 9 | * enum containing the opcodes. | |
| 10 | */ | |
| 11 | public enum OpCode { | |
| 12 | Invalid(-1), | |
| 13 | NOP(0), | |
| 14 | STORE(1), | |
| 15 | LOAD(2), | |
| 16 | IN(3), | |
| 17 | OUT(4), | |
| 18 | //--- | |
| 19 | ADD(17), | |
| 20 | SUB(18), | |
| 21 | MUL(19), | |
| 22 | DIV(20), | |
| 23 | MOD(21), | |
| 24 | AND(22), | |
| 25 | OR(23), | |
| 26 | XOR(24), | |
| 27 | SHL(25), | |
| 28 | SHR(26), | |
| 29 | NOT(27), | |
| 30 | SHRA(28), | |
| 31 | COMP(31), | |
| 32 | JUMP(32), | |
| 33 | JNEG(33), | |
| 34 | JZER(34), | |
| 35 | JPOS(35), | |
| 36 | JNNEG(36), | |
| 37 | JNZER(37), | |
| 38 | JNPOS(38), | |
| 39 | JLES(39), | |
| 40 | JEQU(40), | |
| 41 | JGRE(41), | |
| 42 | JNLES(42), | |
| 43 | JNEQU(43), | |
| 44 | JNGRE(44), | |
| 45 | //-- | |
| 46 | CALL(49), | |
| 47 | EXIT(50), | |
| 48 | PUSH(51), | |
| 49 | POP(52), | |
| 50 | PUSHR(53), | |
| 51 | POPR(54), | |
| 52 | //-- | |
| 53 | SVC(112); | |
| 54 | ||
| 55 | private final int code; | |
| 56 | ||
| 57 | private OpCode(int code) { | |
| 58 | 1 | this.code = code; |
| 59 | } | |
| 60 | ||
| 61 | public int code() { | |
| 62 | 1 | return code; |
| 63 | } | |
| 64 | ||
| 65 | public static OpCode getOpCode(int code) { | |
| 66 | 6 | for (OpCode o : OpCode.values()) { |
| 67 | 2 | if (code == o.code()) { |
| 68 | 1 | return o; |
| 69 | } | |
| 70 | } | |
| 71 | 1 | return OpCode.Invalid; |
| 72 | } | |
| 73 | } | |
Mutations | ||
| 58 |
Removed assignment to member variable code : NO_COVERAGE |
|
| 62 |
replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE |
|
| 66 |
Substituted 0 with 1 : NO_COVERAGE Substituted 0 with 1 : NO_COVERAGE Changed increment from 1 to -1 : NO_COVERAGE changed conditional boundary : NO_COVERAGE negated conditional : NO_COVERAGE removed call to fi/helsinki/cs/ttk91/OpCode::values : NO_COVERAGE |
|
| 67 |
removed call to fi/helsinki/cs/ttk91/OpCode::code : NO_COVERAGE negated conditional : NO_COVERAGE |
|
| 68 |
mutated return of Object value for fi/helsinki/cs/ttk91/OpCode::getOpCode to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE |
|
| 71 |
mutated return of Object value for fi/helsinki/cs/ttk91/OpCode::getOpCode to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE |