Some AST tweaks and add astfile: config option to read AST from a file
instead of running Clang. Attempt to port to MacOS Mojave.
This commit is contained in:
@@ -3,7 +3,7 @@ package ast
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.wow.st/gmp/nswrap/util"
|
||||
//"git.wow.st/gmp/nswrap/util"
|
||||
)
|
||||
|
||||
// AllocSizeAttr is a type of attribute that is optionally attached to a variable
|
||||
@@ -12,8 +12,8 @@ type AllocSizeAttr struct {
|
||||
Addr Address
|
||||
Pos Position
|
||||
Inherited bool
|
||||
A int
|
||||
B int
|
||||
A string
|
||||
B string
|
||||
ChildNodes []Node
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ func parseAllocSizeAttr(line string) *AllocSizeAttr {
|
||||
Addr: ParseAddress(groups["address"]),
|
||||
Pos: NewPositionFromString(groups["position"]),
|
||||
Inherited: len(groups["inherited"]) > 0,
|
||||
A: util.Atoi(strings.TrimSpace(groups["a"])),
|
||||
B: util.Atoi(strings.TrimSpace(groups["b"])),
|
||||
A: strings.TrimSpace(groups["a"]),
|
||||
B: strings.TrimSpace(groups["b"]),
|
||||
ChildNodes: []Node{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ func parseImplicitCastExpr(line string) *ImplicitCastExpr {
|
||||
`<(?P<position>.*)>
|
||||
'(?P<type>.*?)'
|
||||
(:'(?P<type2>.*?)')?
|
||||
<(?P<kind>.*)>`,
|
||||
<(?P<kind>.*)>
|
||||
( part_of_explicit_cast)?`,
|
||||
line,
|
||||
)
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ func parseUnaryOperator(line string) *UnaryOperator {
|
||||
(?P<lvalue> lvalue)?
|
||||
(?P<prefix> prefix)?
|
||||
(?P<postfix> postfix)?
|
||||
'(?P<operator>.*?)'`,
|
||||
'(?P<operator>.*?)'
|
||||
( .*)?`,
|
||||
line,
|
||||
)
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ type VarDecl struct {
|
||||
Type2 string
|
||||
IsExtern bool
|
||||
IsUsed bool
|
||||
IsRange bool
|
||||
IsCInit bool
|
||||
IsReferenced bool
|
||||
IsStatic bool
|
||||
@@ -28,6 +29,7 @@ func parseVarDecl(line string) *VarDecl {
|
||||
(?:parent (?P<parent>0x[0-9a-f]+) )?
|
||||
<(?P<position>.*)>(?P<position2> .+:\d+)?
|
||||
(?P<used> used)?
|
||||
(?P<range> range)?
|
||||
(?P<referenced> referenced)?
|
||||
(?P<name> \w+)?
|
||||
'(?P<type>.+?)'
|
||||
@@ -36,6 +38,7 @@ func parseVarDecl(line string) *VarDecl {
|
||||
(?P<static> static)?
|
||||
(?P<cinit> cinit)?
|
||||
(?P<register> register)?
|
||||
(.*)
|
||||
`,
|
||||
line,
|
||||
)
|
||||
@@ -55,6 +58,7 @@ func parseVarDecl(line string) *VarDecl {
|
||||
Type2: type2,
|
||||
IsExtern: len(groups["extern"]) > 0,
|
||||
IsUsed: len(groups["used"]) > 0,
|
||||
IsRange: len(groups["range"]) > 0,
|
||||
IsCInit: len(groups["cinit"]) > 0,
|
||||
IsReferenced: len(groups["referenced"]) > 0,
|
||||
IsStatic: len(groups["static"]) > 0,
|
||||
|
||||
Reference in New Issue
Block a user