Skip to content

Commit

Permalink
Add support for "volatile" property modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
rinsuki committed Dec 20, 2018
1 parent d706231 commit cfe5bf4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion java/modifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package java
var Modifiers = map[string]bool{"public": true, "private": true, "protected": true}

const (
Final = "final"
Final = "final"
Volatile = "volatile"
)
13 changes: 12 additions & 1 deletion parser/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ package parser

import (
"fmt"
"strings"

"github.com/alexeysoshin/smali2java/java"
"github.com/alexeysoshin/smali2java/smali"
"strings"
)

type FieldParser struct {
accessor string
static bool
synthetic bool
final bool
volatile bool
}

func (p *FieldParser) Parse(javaFile *JavaFile, currentLine Line) error {
Expand All @@ -38,6 +40,11 @@ func (p *FieldParser) Parse(javaFile *JavaFile, currentLine Line) error {
memberAndClassIndex++
}

if currentLine[memberAndClassIndex] == smali.Volatile {
p.volatile = true
memberAndClassIndex++
}

// For Java enum field is just another class
if currentLine[memberAndClassIndex] == smali.Enum {
memberAndClassIndex++
Expand Down Expand Up @@ -69,6 +76,10 @@ func (p *FieldParser) Parse(javaFile *JavaFile, currentLine Line) error {
line = append(line, java.Final)
}

if p.volatile {
line = append(line, java.Volatile)
}

line = append(line, className, memberName, ";")

if p.synthetic {
Expand Down
1 change: 1 addition & 0 deletions smali/literals.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ const (
Enum = "enum"
IPutObject = "iput-object"
IGetObject = "iget-object"
Volatile = "volatile"
)

0 comments on commit cfe5bf4

Please sign in to comment.