Skip to content

Commit

Permalink
Add Edge type + Fix slice of pointer Attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Rasquier committed Dec 14, 2017
1 parent 4ae2d74 commit 96bf68c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions asm/classreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ func (c ClassReader) GetInterfaces() []string {

// Accept Makes the given visitor visit the JVMS ClassFile structure passed to the constructor of this {@link ClassReader}.
func (c ClassReader) Accept(classVisitor ClassVisitor, parsingOptions int) {
c.AcceptB(classVisitor, make([]Attribute, 0), parsingOptions)
c.AcceptB(classVisitor, make([]*Attribute, 0), parsingOptions)
}

// AcceptB Makes the given visitor visit the JVMS ClassFile structure passed to the constructor of this {@link ClassReader}.
func (c ClassReader) AcceptB(classVisitor ClassVisitor, attributePrototypes []Attribute, parsingOptions int) {
func (c ClassReader) AcceptB(classVisitor ClassVisitor, attributePrototypes []*Attribute, parsingOptions int) {
context := &Context{
attributePrototypes: attributePrototypes,
parsingOptions: parsingOptions,
Expand Down Expand Up @@ -1480,7 +1480,7 @@ func (c ClassReader) getFirstAttributeOffset() int {
return currentOffset + 2
}

func (c ClassReader) readAttribute(attributePrototypes []Attribute, typed string, offset int, length int, charBuffer []rune, codeAttributeOffset int, labels []*Label) *Attribute {
func (c ClassReader) readAttribute(attributePrototypes []*Attribute, typed string, offset int, length int, charBuffer []rune, codeAttributeOffset int, labels []*Label) *Attribute {
for i := 0; i < len(attributePrototypes); i++ {
if attributePrototypes[i].typed == typed {
return attributePrototypes[i].read(&c, offset, length, charBuffer, codeAttributeOffset, labels)
Expand Down
2 changes: 1 addition & 1 deletion asm/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package asm

// Context information about a class being parsed in a {@link ClassReader}.
type Context struct {
attributePrototypes []Attribute
attributePrototypes []*Attribute
parsingOptions int
charBuffer []rune
bootstrapMethodOffsets []int
Expand Down
17 changes: 17 additions & 0 deletions asm/edge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package asm

const (
JUMP = 0
EXCEPTION = 0x7FFFFFFF
)

// Edge An edge in the control flow graph of a method. Each node of this graph is a basic block,
// represented with the Label corresponding to its first instruction. Each edge goes from one node
// to another, i.e. from one basic block to another (called the predecessor and successor blocks,
// respectively). An edge corresponds either to a jump or ret instruction or to an exception
// handler.
type Edge struct {
info int
successor *Label
nextEdge *Edge
}
2 changes: 1 addition & 1 deletion asm/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Label struct {
outputStackMax int16
frame *Frame
nextBasicBlock *Label
outgoingEdges interface{} //Edge
outgoingEdges *Edge
nextListElement *Label
}

Expand Down

0 comments on commit 96bf68c

Please sign in to comment.