-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pan
committed
Apr 11, 2017
1 parent
06fce9c
commit f62dd15
Showing
13 changed files
with
729 additions
and
112 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
group11/252308879/mini-jvm/src/main/java/com/pan/jvm/attr/AttributeInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.pan.jvm.attr; | ||
|
||
public abstract class AttributeInfo { | ||
public static final String CODE = "Code"; | ||
public static final String CONST_VALUE = "ConstantValue"; | ||
public static final String EXCEPTIONS = "Exceptions"; | ||
public static final String LINE_NUM_TABLE = "LineNumberTable"; | ||
public static final String LOCAL_VAR_TABLE = "LocalVariableTable"; | ||
public static final String STACK_MAP_TABLE = "StackMapTable"; | ||
int attrNameIndex; | ||
int attrLen ; | ||
public AttributeInfo(int attrNameIndex, int attrLen) { | ||
|
||
this.attrNameIndex = attrNameIndex; | ||
this.attrLen = attrLen; | ||
} | ||
|
||
|
||
} |
56 changes: 56 additions & 0 deletions
56
group11/252308879/mini-jvm/src/main/java/com/pan/jvm/attr/CodeAttr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.pan.jvm.attr; | ||
|
||
import com.pan.jvm.clz.ClassFile; | ||
import com.pan.jvm.constant.ConstantPool; | ||
import com.pan.jvm.loader.ByteCodeIterator; | ||
|
||
|
||
public class CodeAttr extends AttributeInfo { | ||
private int maxStack ; | ||
private int maxLocals ; | ||
private int codeLen ; | ||
private String code; | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
//private ByteCodeCommand[] cmds ; | ||
//public ByteCodeCommand[] getCmds() { | ||
// return cmds; | ||
//} | ||
private LineNumberTable lineNumTable; | ||
private LocalVariableTable localVarTable; | ||
private StackMapTable stackMapTable; | ||
|
||
public CodeAttr(int attrNameIndex, int attrLen, int maxStack, int maxLocals, int codeLen,String code /*ByteCodeCommand[] cmds*/) { | ||
super(attrNameIndex, attrLen); | ||
this.maxStack = maxStack; | ||
this.maxLocals = maxLocals; | ||
this.codeLen = codeLen; | ||
this.code = code; | ||
//this.cmds = cmds; | ||
} | ||
|
||
public void setLineNumberTable(LineNumberTable t) { | ||
this.lineNumTable = t; | ||
} | ||
|
||
public void setLocalVariableTable(LocalVariableTable t) { | ||
this.localVarTable = t; | ||
} | ||
|
||
public static CodeAttr parse(ClassFile clzFile, ByteCodeIterator iter){ | ||
|
||
|
||
return null; | ||
} | ||
private void setStackMapTable(StackMapTable t) { | ||
this.stackMapTable = t; | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
42 changes: 42 additions & 0 deletions
42
group11/252308879/mini-jvm/src/main/java/com/pan/jvm/attr/LineNumberTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.pan.jvm.attr; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.pan.jvm.loader.ByteCodeIterator; | ||
|
||
public class LineNumberTable extends AttributeInfo { | ||
List<LineNumberItem> items = new ArrayList<LineNumberItem>(); | ||
|
||
private static class LineNumberItem{ | ||
int startPC; | ||
int lineNum; | ||
public int getStartPC() { | ||
return startPC; | ||
} | ||
public void setStartPC(int startPC) { | ||
this.startPC = startPC; | ||
} | ||
public int getLineNum() { | ||
return lineNum; | ||
} | ||
public void setLineNum(int lineNum) { | ||
this.lineNum = lineNum; | ||
} | ||
} | ||
public void addLineNumberItem(LineNumberItem item){ | ||
this.items.add(item); | ||
} | ||
public LineNumberTable(int attrNameIndex, int attrLen) { | ||
super(attrNameIndex, attrLen); | ||
|
||
} | ||
|
||
public static LineNumberTable parse(ByteCodeIterator iter){ | ||
|
||
return null; | ||
} | ||
|
||
|
||
|
||
} |
39 changes: 39 additions & 0 deletions
39
group11/252308879/mini-jvm/src/main/java/com/pan/jvm/attr/LocalVariableItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.pan.jvm.attr; | ||
|
||
public class LocalVariableItem { | ||
private int startPC; | ||
private int length; | ||
private int nameIndex; | ||
private int descIndex; | ||
private int index; | ||
public int getStartPC() { | ||
return startPC; | ||
} | ||
public void setStartPC(int startPC) { | ||
this.startPC = startPC; | ||
} | ||
public int getLength() { | ||
return length; | ||
} | ||
public void setLength(int length) { | ||
this.length = length; | ||
} | ||
public int getNameIndex() { | ||
return nameIndex; | ||
} | ||
public void setNameIndex(int nameIndex) { | ||
this.nameIndex = nameIndex; | ||
} | ||
public int getDescIndex() { | ||
return descIndex; | ||
} | ||
public void setDescIndex(int descIndex) { | ||
this.descIndex = descIndex; | ||
} | ||
public int getIndex() { | ||
return index; | ||
} | ||
public void setIndex(int index) { | ||
this.index = index; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
group11/252308879/mini-jvm/src/main/java/com/pan/jvm/attr/LocalVariableTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.pan.jvm.attr; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.pan.jvm.constant.ConstantPool; | ||
|
||
import com.pan.jvm.loader.ByteCodeIterator; | ||
|
||
public class LocalVariableTable extends AttributeInfo{ | ||
|
||
List<LocalVariableItem> items = new ArrayList<LocalVariableItem>(); | ||
|
||
public LocalVariableTable(int attrNameIndex, int attrLen) { | ||
super(attrNameIndex, attrLen); | ||
} | ||
|
||
public static LocalVariableTable parse(ByteCodeIterator iter){ | ||
|
||
return null; | ||
} | ||
private void addLocalVariableItem(LocalVariableItem item) { | ||
this.items.add(item); | ||
} | ||
|
||
|
||
} |
30 changes: 30 additions & 0 deletions
30
group11/252308879/mini-jvm/src/main/java/com/pan/jvm/attr/StackMapTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.pan.jvm.attr; | ||
|
||
|
||
import com.pan.jvm.loader.ByteCodeIterator; | ||
|
||
public class StackMapTable extends AttributeInfo{ | ||
|
||
private String originalCode; | ||
|
||
public StackMapTable(int attrNameIndex, int attrLen) { | ||
super(attrNameIndex, attrLen); | ||
} | ||
|
||
public static StackMapTable parse(ByteCodeIterator iter){ | ||
int index = iter.nextU2ToInt(); | ||
int len = iter.nextU4ToInt(); | ||
StackMapTable t = new StackMapTable(index,len); | ||
|
||
//后面的StackMapTable太过复杂, 不再处理, 只把原始的代码读进来保存 | ||
String code = iter.nextUxToHexString(len); | ||
t.setOriginalCode(code); | ||
|
||
return t; | ||
} | ||
|
||
private void setOriginalCode(String code) { | ||
this.originalCode = code; | ||
|
||
} | ||
} |
37 changes: 18 additions & 19 deletions
37
group11/252308879/mini-jvm/src/main/java/com/pan/jvm/clz/AccessFlag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
package com.pan.jvm.clz; | ||
|
||
public class AccessFlag { | ||
private int flagValue; | ||
private int flagValue; | ||
|
||
public AccessFlag(int value) { | ||
this.flagValue = value; | ||
} | ||
public AccessFlag(int value) { | ||
this.flagValue = value; | ||
} | ||
|
||
public int getFlagValue() { | ||
return flagValue; | ||
} | ||
|
||
public void setFlagValue(int flag) { | ||
this.flagValue = flag; | ||
} | ||
|
||
public boolean isPublicClass() { | ||
return (this.flagValue & 0x0001) != 0; | ||
} | ||
|
||
public boolean isFinalClass() { | ||
return (this.flagValue & 0x0010) != 0; | ||
} | ||
public int getFlagValue() { | ||
return flagValue; | ||
} | ||
|
||
public void setFlagValue(int flag) { | ||
this.flagValue = flag; | ||
} | ||
|
||
public boolean isPublicClass(){ | ||
return (this.flagValue & 0x0001) != 0; | ||
} | ||
public boolean isFinalClass(){ | ||
return (this.flagValue & 0x0010) != 0; | ||
} | ||
|
||
} |
Oops, something went wrong.