Skip to content

Commit

Permalink
[feature] main method execution added
Browse files Browse the repository at this point in the history
  • Loading branch information
lvntky committed Jun 22, 2024
1 parent 2d4d448 commit f92a997
Show file tree
Hide file tree
Showing 11 changed files with 322 additions and 83 deletions.
Binary file added sample/AddMain.class
Binary file not shown.
12 changes: 12 additions & 0 deletions sample/AddMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class AddMain {

public static int main(String args[]) {
int a = 14;
int b = 15;
return add(a, b);
}

public static int add(int a, int b) {
return a + b;
}
}
Binary file removed sample/Hello.class
Binary file not shown.
5 changes: 0 additions & 5 deletions sample/Hello.java

This file was deleted.

Binary file removed sample/HelloMain.class
Binary file not shown.
6 changes: 0 additions & 6 deletions sample/HelloMain.java

This file was deleted.

51 changes: 0 additions & 51 deletions sample/javap_Add.txt

This file was deleted.

298 changes: 298 additions & 0 deletions sample/javap_AddMain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
Classfile /home/levent/Projects/CVM/sample/AddMain.class
Last modified Jun 22, 2024; size 347 bytes
SHA-256 checksum 14811c1816314b13c819db3a96c61676607f69186573fc379f79bd6562982da8
Compiled from "AddMain.java"
class AddMain
minor version: 0
major version: 66
flags: (0x0020) ACC_SUPER
this_class: #8 // AddMain
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 3, attributes: 1
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
#7 = Methodref #8.#9 // AddMain.add:(II)I
#8 = Class #10 // AddMain
#9 = NameAndType #11:#12 // add:(II)I
#10 = Utf8 AddMain
#11 = Utf8 add
#12 = Utf8 (II)I
#13 = Utf8 Code
#14 = Utf8 LineNumberTable
#15 = Utf8 main
#16 = Utf8 ([Ljava/lang/String;)V
#17 = Utf8 SourceFile
#18 = Utf8 AddMain.java
{
AddMain();
descriptor: ()V
flags: (0x0000)
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0

public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=3, args_size=1
0: iconst_1
1: istore_1
2: iconst_2
3: istore_2
4: iload_1
5: iload_2
6: invokestatic #7 // Method add:(II)I
9: pop
10: return
LineNumberTable:
line 4: 0
line 5: 2
line 6: 4
line 7: 10

public static int add(int, int);
descriptor: (II)I
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=2
0: iload_0
1: iload_1
2: iadd
3: ireturn
LineNumberTable:
line 10: 0
}
SourceFile: "AddMain.java"
Classfile /home/levent/Projects/CVM/sample/AddMain.class
Last modified Jun 22, 2024; size 349 bytes
SHA-256 checksum 51968c311d074303b8bebc57dd66676d30055945651608ab6a2a303dd3204ac7
Compiled from "AddMain.java"
class AddMain
minor version: 0
major version: 66
flags: (0x0020) ACC_SUPER
this_class: #8 // AddMain
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 3, attributes: 1
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
#7 = Methodref #8.#9 // AddMain.add:(II)I
#8 = Class #10 // AddMain
#9 = NameAndType #11:#12 // add:(II)I
#10 = Utf8 AddMain
#11 = Utf8 add
#12 = Utf8 (II)I
#13 = Utf8 Code
#14 = Utf8 LineNumberTable
#15 = Utf8 main
#16 = Utf8 ([Ljava/lang/String;)V
#17 = Utf8 SourceFile
#18 = Utf8 AddMain.java
{
AddMain();
descriptor: ()V
flags: (0x0000)
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0

public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=3, args_size=1
0: bipush 14
2: istore_1
3: bipush 25
5: istore_2
6: iload_1
7: iload_2
8: invokestatic #7 // Method add:(II)I
11: pop
12: return
LineNumberTable:
line 4: 0
line 5: 3
line 6: 6
line 7: 12

public static int add(int, int);
descriptor: (II)I
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=2
0: iload_0
1: iload_1
2: iadd
3: ireturn
LineNumberTable:
line 10: 0
}
SourceFile: "AddMain.java"
Classfile /home/levent/Projects/CVM/sample/AddMain.class
Last modified Jun 22, 2024; size 349 bytes
SHA-256 checksum 539564bfbc4e1351399408117b2917887b1fa54f643692643b467d55aaa76bd9
Compiled from "AddMain.java"
class AddMain
minor version: 0
major version: 66
flags: (0x0020) ACC_SUPER
this_class: #8 // AddMain
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 3, attributes: 1
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
#7 = Methodref #8.#9 // AddMain.add:(II)I
#8 = Class #10 // AddMain
#9 = NameAndType #11:#12 // add:(II)I
#10 = Utf8 AddMain
#11 = Utf8 add
#12 = Utf8 (II)I
#13 = Utf8 Code
#14 = Utf8 LineNumberTable
#15 = Utf8 main
#16 = Utf8 ([Ljava/lang/String;)V
#17 = Utf8 SourceFile
#18 = Utf8 AddMain.java
{
AddMain();
descriptor: ()V
flags: (0x0000)
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0

public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=3, args_size=1
0: bipush 14
2: istore_1
3: bipush 15
5: istore_2
6: iload_1
7: iload_2
8: invokestatic #7 // Method add:(II)I
11: pop
12: return
LineNumberTable:
line 4: 0
line 5: 3
line 6: 6
line 7: 12

public static int add(int, int);
descriptor: (II)I
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=2
0: iload_0
1: iload_1
2: iadd
3: ireturn
LineNumberTable:
line 10: 0
}
SourceFile: "AddMain.java"
Classfile /home/levent/Projects/CVM/sample/AddMain.class
Last modified Jun 22, 2024; size 344 bytes
SHA-256 checksum cfc5738c9de9d7cd704372a808960c2c054d836aa52edb6b489e47d0d2ced72f
Compiled from "AddMain.java"
class AddMain
minor version: 0
major version: 66
flags: (0x0020) ACC_SUPER
this_class: #8 // AddMain
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 3, attributes: 1
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
#7 = Methodref #8.#9 // AddMain.add:(II)I
#8 = Class #10 // AddMain
#9 = NameAndType #11:#12 // add:(II)I
#10 = Utf8 AddMain
#11 = Utf8 add
#12 = Utf8 (II)I
#13 = Utf8 Code
#14 = Utf8 LineNumberTable
#15 = Utf8 main
#16 = Utf8 ([Ljava/lang/String;)I
#17 = Utf8 SourceFile
#18 = Utf8 AddMain.java
{
AddMain();
descriptor: ()V
flags: (0x0000)
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0

public static int main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)I
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=3, args_size=1
0: bipush 14
2: istore_1
3: bipush 15
5: istore_2
6: iload_1
7: iload_2
8: invokestatic #7 // Method add:(II)I
11: ireturn
LineNumberTable:
line 4: 0
line 5: 3
line 6: 6

public static int add(int, int);
descriptor: (II)I
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=2
0: iload_0
1: iload_1
2: iadd
3: ireturn
LineNumberTable:
line 10: 0
}
SourceFile: "AddMain.java"
15 changes: 0 additions & 15 deletions sample/javap_output.txt

This file was deleted.

Loading

0 comments on commit f92a997

Please sign in to comment.