-
Notifications
You must be signed in to change notification settings - Fork 2
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
Vincent Rasquier
committed
Dec 13, 2017
0 parents
commit 5a43fb5
Showing
14 changed files
with
1,171 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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,11 @@ | ||
import java.util.function.Consumer; | ||
|
||
final class ExampleClass implements Consumer<String> { | ||
public int toInt() { | ||
return 1; | ||
} | ||
|
||
public void accept(String t) { | ||
|
||
} | ||
} |
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,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() | ||
} |
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,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 | ||
} | ||
} |
Oops, something went wrong.