mirror of
https://github.com/FranzHaidnor/haidnorJVM.git
synced 2026-03-13 21:43:42 +08:00
update IFEQ
This commit is contained in:
@@ -19,16 +19,24 @@ public class IFEQ extends Instruction {
|
||||
@Override
|
||||
public void execute(Frame frame) {
|
||||
StackValue v1 = frame.pop();
|
||||
if ((int) v1.getValue() == 0) {
|
||||
super.setOffSet(offSet);
|
||||
if (v1.getValue() instanceof Boolean) {
|
||||
if (!((boolean) v1.getValue())) {
|
||||
super.setOffSet(offSet);
|
||||
} else {
|
||||
super.setOffSet(3);
|
||||
}
|
||||
} else {
|
||||
super.setOffSet(3);
|
||||
if ((int) v1.getValue() == 0) {
|
||||
super.setOffSet(offSet);
|
||||
} else {
|
||||
super.setOffSet(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.index() + " " + this.getClass().getSimpleName() + " " + offSet;
|
||||
return super.index() + " " + this.getClass().getSimpleName() + " " + offSet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,6 +92,11 @@ public class TestJVM {
|
||||
runMainClass(demo_foreach.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void demo_foreach_2() throws Exception {
|
||||
runMainClass(demo_foreach_2.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_8() throws Exception {
|
||||
runMainClass(Demo8.class);
|
||||
|
||||
20
src/test/java/haidnor/jvm/test/demo/demo_foreach_2.java
Normal file
20
src/test/java/haidnor/jvm/test/demo/demo_foreach_2.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package haidnor.jvm.test.demo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 需要添加启动参数
|
||||
* --add-opens java.base/java.util=ALL-UNNAMED
|
||||
*/
|
||||
public class demo_foreach_2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ArrayList<Integer> list = new ArrayList<>();
|
||||
list.add(1);
|
||||
list.add(2);
|
||||
for (Integer integer : list) {
|
||||
System.out.println(integer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user