-
Notifications
You must be signed in to change notification settings - Fork 52
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
Showing
6 changed files
with
140 additions
and
3 deletions.
There are no files selected for viewing
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 class | ||
|
||
import ( | ||
"fmt" | ||
"github.com/phith0n/zkar/commons" | ||
) | ||
|
||
// AttrAnnotations | ||
// https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.7.16 | ||
// https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.7.17 | ||
// https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.7.18 | ||
// https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.7.19 | ||
// https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.7.20 | ||
// https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.7.21 | ||
type AttrAnnotations struct { | ||
*AttributeBase | ||
|
||
Data []byte | ||
} | ||
|
||
// readInfo TODO: not implement | ||
func (a *AttrAnnotations) readInfo(stream *commons.Stream) error { | ||
var err error | ||
a.Data, err = stream.ReadN(int(a.AttributeLength)) | ||
if err != nil { | ||
return fmt.Errorf("read AttrAnnotations failed, no enough data in the stream") | ||
} | ||
|
||
return nil | ||
} |
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 class | ||
|
||
import "github.com/phith0n/zkar/commons" | ||
|
||
// AttrDeprecated https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.7.15 | ||
type AttrDeprecated struct { | ||
*AttributeBase | ||
} | ||
|
||
func (a *AttrDeprecated) readInfo(stream *commons.Stream) error { | ||
return nil | ||
} |
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
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,46 @@ | ||
package class | ||
|
||
import ( | ||
"encoding/binary" | ||
"fmt" | ||
"github.com/phith0n/zkar/commons" | ||
) | ||
|
||
type AttrLocalVariableTable struct { | ||
*AttributeBase | ||
|
||
Tables []*LocalVariableTable | ||
} | ||
|
||
type LocalVariableTable struct { | ||
StartPC uint16 | ||
Length uint16 | ||
NameIndex uint16 | ||
DescriptorIndex uint16 | ||
Index uint16 | ||
} | ||
|
||
func (a *AttrLocalVariableTable) readInfo(stream *commons.Stream) error { | ||
bs, err := stream.ReadN(2) | ||
if err != nil { | ||
return fmt.Errorf("read AttrLocalVariableTable failed, no enough data in the stream") | ||
} | ||
|
||
for i := uint16(0); i < binary.BigEndian.Uint16(bs); i++ { | ||
bs, err = stream.ReadN(10) | ||
if err != nil { | ||
return fmt.Errorf("read AttrLocalVariableTable tables failed, no enough data in the stream") | ||
} | ||
|
||
table := &LocalVariableTable{ | ||
StartPC: binary.BigEndian.Uint16(bs[:2]), | ||
Length: binary.BigEndian.Uint16(bs[2:4]), | ||
NameIndex: binary.BigEndian.Uint16(bs[4:6]), | ||
DescriptorIndex: binary.BigEndian.Uint16(bs[6:8]), | ||
Index: binary.BigEndian.Uint16(bs[8:]), | ||
} | ||
a.Tables = append(a.Tables, table) | ||
} | ||
|
||
return nil | ||
} |
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,48 @@ | ||
package class | ||
|
||
import ( | ||
"encoding/binary" | ||
"fmt" | ||
"github.com/phith0n/zkar/commons" | ||
) | ||
|
||
// AttrLocalVariableTypeTable https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.7.14 | ||
type AttrLocalVariableTypeTable struct { | ||
*AttributeBase | ||
|
||
Tables []*LocalVariableTypeTable | ||
} | ||
|
||
type LocalVariableTypeTable struct { | ||
StartPC uint16 | ||
Length uint16 | ||
NameIndex uint16 | ||
SignatureIndex uint16 | ||
Index uint16 | ||
} | ||
|
||
func (a *AttrLocalVariableTypeTable) readInfo(stream *commons.Stream) error { | ||
bs, err := stream.ReadN(2) | ||
if err != nil { | ||
return fmt.Errorf("read AttrLocalVariableTypeTable failed, no enough data in the stream") | ||
} | ||
|
||
for i := uint16(0); i < binary.BigEndian.Uint16(bs); i++ { | ||
bs, err = stream.ReadN(10) | ||
if err != nil { | ||
return fmt.Errorf("read AttrLocalVariableTypeTable tables failed, no enough data in the stream") | ||
} | ||
|
||
table := &LocalVariableTypeTable{ | ||
StartPC: binary.BigEndian.Uint16(bs[:2]), | ||
Length: binary.BigEndian.Uint16(bs[2:4]), | ||
NameIndex: binary.BigEndian.Uint16(bs[4:6]), | ||
SignatureIndex: binary.BigEndian.Uint16(bs[6:8]), | ||
Index: binary.BigEndian.Uint16(bs[8:]), | ||
} | ||
a.Tables = append(a.Tables, table) | ||
} | ||
|
||
return nil | ||
} | ||
|
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