-
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
22 changed files
with
144 additions
and
105 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 |
---|---|---|
@@ -1,14 +1,30 @@ | ||
linters: | ||
disable-all: true | ||
enable: | ||
- deadcode | ||
- unused | ||
- errcheck | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- structcheck | ||
- unused | ||
- varcheck | ||
- gofmt | ||
- goconst | ||
- misspell | ||
- nolintlint | ||
- tagliatelle | ||
linters-settings: | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
allow-unused: false # report any unused nolint directives | ||
require-explanation: false # don't require an explanation for nolint directives | ||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped | ||
tagliatelle: | ||
case: | ||
rules: | ||
json: snake | ||
yaml: snake | ||
xml: snake | ||
form: snake | ||
msgpack: snake |
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
package class | ||
|
||
type AttrAccessFlag uint16 | ||
|
||
const ( | ||
AttrAccPublic AttrAccessFlag = 0x0001 // Declared public; may be accessed from outside its package. | ||
AttrAccPrivate AttrAccessFlag = 0x0002 // Declared private; accessible only within the defining class and other classes belonging to the same nest (§5.4.4). | ||
AttrAccProtected AttrAccessFlag = 0x0004 // Declared protected; may be accessed within subclasses. | ||
AttrAccStatic AttrAccessFlag = 0x0008 // Declared static. | ||
AttrAccFinal AttrAccessFlag = 0x0010 // Declared final; must not be overridden (§5.4.5). | ||
AttrAccSynchronized AttrAccessFlag = 0x0020 // Declared synchronized; invocation is wrapped by a monitor use. | ||
AttrAccBridge AttrAccessFlag = 0x0040 // A bridge method, generated by the compiler. | ||
AttrAccVarargs AttrAccessFlag = 0x0080 // Declared with variable number of arguments. | ||
AttrAccNative AttrAccessFlag = 0x0100 // Declared native; implemented in a language other than the Java programming language. | ||
AttrAccAbstract AttrAccessFlag = 0x0400 // Declared abstract; no implementation is provided. | ||
AttrAccStrict AttrAccessFlag = 0x0800 // In a class file whose major version number is at least 46 and at most 60: Declared strictfp. | ||
AttrAccSynthetic AttrAccessFlag = 0x1000 // Declared synthetic; not present in the source code. | ||
) | ||
|
||
func (aaf AttrAccessFlag) HasAccessFlag(flag AttrAccessFlag) bool { | ||
return (flag & aaf) == flag | ||
} |
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,50 @@ | ||
package class | ||
|
||
import ( | ||
"encoding/binary" | ||
"fmt" | ||
"github.com/phith0n/zkar/commons" | ||
) | ||
|
||
type ClassAccessFlag uint16 | ||
|
||
const ( | ||
ClassAccPublic ClassAccessFlag = 0x0001 // Declared public; may be accessed from outside its package. | ||
ClassAccPrivate ClassAccessFlag = 0x0002 // Marked private in source. | ||
ClassAccProtected ClassAccessFlag = 0x0004 // Marked protected in source. | ||
ClassAccStatic ClassAccessFlag = 0x0008 // Marked or implicitly static in source. | ||
ClassAccFinal ClassAccessFlag = 0x0010 // Declared final; no subclasses allowed. | ||
ClassAccSuper ClassAccessFlag = 0x0020 // Treat superclass methods specially when invoked by the invokespecial instruction. | ||
ClassAccInterface ClassAccessFlag = 0x0200 // Is an interface, not a class. | ||
ClassAccAbstract ClassAccessFlag = 0x0400 // Declared abstract; must not be instantiated. | ||
ClassAccSynthetic ClassAccessFlag = 0x1000 // Declared synthetic; not present in the source code. | ||
ClassAccAnnotation ClassAccessFlag = 0x2000 // Declared as an annotation type. | ||
ClassAccEnum ClassAccessFlag = 0x4000 // Declared as an enum type. | ||
ClassAccModule ClassAccessFlag = 0x8000 // Is a module, not a class or interface. | ||
) | ||
|
||
func (caf ClassAccessFlag) HasAccessFlag(flag ClassAccessFlag) bool { | ||
return (flag & caf) == flag | ||
} | ||
|
||
func (cf *ClassFile) readAccessFlag(stream *commons.Stream) error { | ||
bs, err := stream.ReadN(2) | ||
if err != nil { | ||
return fmt.Errorf("read access flag failed, no enough data in the stream") | ||
} | ||
|
||
var i = binary.BigEndian.Uint16(bs) | ||
cf.AccessFlag = ClassAccessFlag(i) | ||
|
||
// check access flag valid | ||
if cf.AccessFlag.HasAccessFlag(ClassAccFinal) && cf.AccessFlag.HasAccessFlag(ClassAccAbstract) { | ||
return fmt.Errorf("ACC_FINAL and ACC_ABSTRACT are not able to set at the same time") | ||
} | ||
|
||
if cf.AccessFlag.HasAccessFlag(ClassAccAnnotation) && !cf.AccessFlag.HasAccessFlag(ClassAccInterface) { | ||
return fmt.Errorf("if ACC_ANNOTATION is set, ACC_ANNOTATION must also be set") | ||
} | ||
|
||
// TODO: maybe need more check | ||
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
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
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
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
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
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
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
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
Oops, something went wrong.