Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Rasquier committed Dec 13, 2017
0 parents commit 5a43fb5
Show file tree
Hide file tree
Showing 14 changed files with 1,171 additions and 0 deletions.
Binary file added ExampleClass.class
Binary file not shown.
11 changes: 11 additions & 0 deletions ExampleClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import java.util.function.Consumer;

final class ExampleClass implements Consumer<String> {
public int toInt() {
return 1;
}

public void accept(String t) {

}
}
12 changes: 12 additions & 0 deletions asm/annotation-visitor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package asm

// AnnotationVisitor a visitor to visit a Java annotation. The methods of this class must be called in the following
// order: ( <tt>visit</tt> | <tt>visitEnum</tt> | <tt>visitAnnotation</tt> | <tt>visitArray</tt> )*
// <tt>visitEnd</tt>.
type AnnotationVisitor interface {
visit(name string, value interface{})
visitEnum(name, descriptor, value string)
visitAnnotation(name, descriptor string) AnnotationVisitor
visitArray(name string) AnnotationVisitor
visitEnd()
}
85 changes: 85 additions & 0 deletions asm/attribute.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package asm

type Attribute struct {
typed string
content []byte
nextAttribute *Attribute
}

func NewAttribute(typed string) *Attribute {
return &Attribute{
typed: typed,
}
}

func (a Attribute) isUnknow() bool {
return true
}

func (a Attribute) isCodeAttribute() bool {
return false
}

func (a Attribute) getLabels() []Label {
return nil
}

func (a Attribute) read(classReader *ClassReader, offset int, length int, charBuffer []rune, codeAttributeOffset int, labels []*Label) *Attribute {
attribute := NewAttribute(a.typed)
attribute.content = make([]byte, length)
//System.arraycopy(classReader.b, offset, attribute.content, 0, length)
return attribute
}

//ClassWriter
func (a Attribute) write(classWriter interface{}, code []byte, codeLength int, maxStack int, maxLocals int) {
//return new ByteVector(content)
}

func (a Attribute) getAttributeCount() int {
count := 0
attribute := &a
for attribute != nil {
count++
attribute = attribute.nextAttribute
}
return count
}

func (a Attribute) computeAttributesSize(symbolTable interface{}) int {
codeLength := 0
maxStack := -1
maxLocals := -1
return a._computeAttributesSize(symbolTable, nil, codeLength, maxStack, maxLocals)
}

func (a Attribute) _computeAttributesSize(symbolTable interface{}, code []byte, codeLength int, maxStack int, maxLocals int) int {
//ClassWriter classWrite = symbolTable.classWriter
size := 0
attribute := &a
for attribute != nil {
//symbolTable.addConstantUtf8(attribute.typed)
//size += 6 + attribute.write(classWriter, code, codeLength, maxStack, maxLocals).length
attribute = attribute.nextAttribute
}
return size
}

//SymbolTable, ByteVector
func (a Attribute) putAttribute(symbolTable interface{}, output interface{}) {
codeLength := 0
maxStack := -1
maxLocals := -1
a._putAttribute(symbolTable, nil, codeLength, maxStack, maxLocals, output)
}

func (a Attribute) _putAttribute(symbolTable interface{}, code []byte, codeLength int, maxStack int, maxLocals int, output interface{}) {
//ClassWriter classWrite = symbolTable.classWriter
attribute := &a
for attribute != nil {
//ByteVector attributeContent = attribute.write(classWriter, code, codeLength, maxStack, maxLocals)
//output.putShort(symbolTable.addConstantUtf8(attribute.typed)).putInt(attributeContent.length)
//output.putByteArray(attributeContent.data, 0, attributeContent.length)
attribute = attribute.nextAttribute
}
}
Loading

0 comments on commit 5a43fb5

Please sign in to comment.