equal
deleted
inserted
replaced
1 (* Title: HOL/MicroJava/JVM/JVMInstructions.thy |
1 (* Title: HOL/MicroJava/JVM/JVMInstructions.thy |
2 ID: $Id$ |
2 ID: $Id$ |
3 Author: Gerwin Klein |
3 Author: Gerwin Klein |
4 Copyright 2000 Technische Universitaet Muenchen |
4 Copyright 2000 Technische Universitaet Muenchen |
5 |
|
6 Instructions of the JVM |
|
7 *) |
5 *) |
8 |
6 |
9 JVMInstructions = JVMState + |
7 header {* Instructions of the JVM *} |
|
8 |
|
9 |
|
10 theory JVMInstructions = JVMState: |
10 |
11 |
11 |
12 |
12 datatype |
13 datatype |
13 instr = Load nat (* load from local variable *) |
14 instr = Load nat (* load from local variable *) |
14 | Store nat (* store into local variable *) |
15 | Store nat (* store into local variable *) |
17 | New cname (* create object *) |
18 | New cname (* create object *) |
18 | Getfield vname cname (* Fetch field from object *) |
19 | Getfield vname cname (* Fetch field from object *) |
19 | Putfield vname cname (* Set field in object *) |
20 | Putfield vname cname (* Set field in object *) |
20 | Checkcast cname (* Check whether object is of given type *) |
21 | Checkcast cname (* Check whether object is of given type *) |
21 | Invoke cname mname "(ty list)" (* inv. instance meth of an object *) |
22 | Invoke cname mname "(ty list)" (* inv. instance meth of an object *) |
22 | Return |
23 | Return (* return from method *) |
23 | Pop |
24 | Pop (* pop top element from opstack *) |
24 | Dup |
25 | Dup (* duplicate top element of opstack *) |
25 | Dup_x1 |
26 | Dup_x1 (* duplicate next to top element *) |
26 | Dup_x2 |
27 | Dup_x2 (* duplicate 3rd element *) |
27 | Swap |
28 | Swap (* swap top and next to top element *) |
28 | IAdd |
29 | IAdd (* integer addition *) |
29 | Goto int |
30 | Goto int (* goto relative address *) |
30 | Ifcmpeq int (* Branch if int/ref comparison succeeds *) |
31 | Ifcmpeq int (* Branch if int/ref comparison succeeds *) |
31 |
32 |
32 |
33 |
33 types |
34 types |
34 bytecode = "instr list" |
35 bytecode = "instr list" |
35 jvm_prog = "(nat \\<times> bytecode) prog" |
36 jvm_prog = "(nat \<times> bytecode) prog" |
36 |
37 |
37 end |
38 end |