Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
gxk committed Dec 31, 2019
1 parent 07fd5a1 commit 6ecd2b6
Show file tree
Hide file tree
Showing 5 changed files with 425 additions and 2 deletions.
8 changes: 8 additions & 0 deletions interpreter-demo/HelloWorld.java
@@ -0,0 +1,8 @@
public class HelloWorld {

public static void main(String[] args) {
int val = 1;
System.out.println(val);
}

}
23 changes: 23 additions & 0 deletions interpreter-demo/README.md
Expand Up @@ -43,4 +43,27 @@ $ java -cp target/interpreter-demo.jar com.gxk.demo.hybrid.HybridDemo
> 2
```

## class 文件解释

### Hello world
```bash
$ java -jar target/interpreter-demo.jar jvm HelloWorld
> 1

# or
$ java -cp target/interpreter-demo.jar com.gxk.demo.jvm.JvmDemo HelloWorld
> 1

```

### Sum100

```bash
$ java -jar target/interpreter-demo.jar jvm Sum100
> 5050

# or
$ java -cp target/interpreter-demo.jar com.gxk.demo.jvm.JvmDemo Sum100
> 5050

```
9 changes: 9 additions & 0 deletions interpreter-demo/Sum100.java
@@ -0,0 +1,9 @@
public class Sum100 {
public static void main(String[] args) {
int sum = 0;
for (int i = 1; i <= 100; i++) {
sum += i;
}
System.out.println(sum);
}
}
10 changes: 8 additions & 2 deletions interpreter-demo/src/main/java/com/gxk/demo/Main.java
@@ -1,12 +1,14 @@
package com.gxk.demo;

import com.gxk.demo.hybrid.HybridDemo;
import com.gxk.demo.jvm.JvmDemo;
import com.gxk.demo.register.RegisterDemo;
import com.gxk.demo.stack.StackDemo;
import java.io.IOException;

public class Main{

public static void main(String[] args){
public static void main(String[] args) throws IOException {
String demo = "";
if (args.length >= 1) {
demo = args[0];
Expand All @@ -21,10 +23,14 @@ public static void main(String[] args){
StackDemo stackDemo = new StackDemo();
stackDemo.run();
return;
default:
case "HYBRID":
HybridDemo hybridDemo = new HybridDemo();
hybridDemo.run();
return;
default:
JvmDemo jvmDemo = new JvmDemo();
jvmDemo.run(args[1]);
return;
}
}
}

0 comments on commit 6ecd2b6

Please sign in to comment.