Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CallExpr: use util.NewCallExpr (#244)
* CallExpr: use util.NewCallExpr * fix test * fix code style
- Loading branch information
1 parent
2cd005b
commit 7ac939d
Showing
12 changed files
with
111 additions
and
91 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
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,50 @@ | ||
package ast | ||
|
||
import "strings" | ||
|
||
// StaticAssertDecl | ||
type StaticAssertDecl struct { | ||
Addr Address | ||
Pos Position | ||
Position2 string | ||
ChildNodes []Node | ||
} | ||
|
||
func parseStaticAssertDecl(line string) *StaticAssertDecl { | ||
groups := groupsFromRegex( | ||
`<(?P<position>.*)> | ||
(?P<position2> col:\d+| line:\d+:\d+)? | ||
`, | ||
line, | ||
) | ||
|
||
return &StaticAssertDecl{ | ||
Addr: ParseAddress(groups["address"]), | ||
Pos: NewPositionFromString(groups["position"]), | ||
Position2: strings.TrimSpace(groups["position2"]), | ||
ChildNodes: []Node{}, | ||
} | ||
} | ||
|
||
// AddChild adds a new child node. Child nodes can then be accessed with the | ||
// Children attribute. | ||
func (n *StaticAssertDecl) AddChild(node Node) { | ||
n.ChildNodes = append(n.ChildNodes, node) | ||
} | ||
|
||
// Address returns the numeric address of the node. See the documentation for | ||
// the Address type for more information. | ||
func (n *StaticAssertDecl) Address() Address { | ||
return n.Addr | ||
} | ||
|
||
// Children returns the child nodes. If this node does not have any children or | ||
// this node does not support children it will always return an empty slice. | ||
func (n *StaticAssertDecl) Children() []Node { | ||
return n.ChildNodes | ||
} | ||
|
||
// Position returns the position in the original source code. | ||
func (n *StaticAssertDecl) Position() Position { | ||
return n.Pos | ||
} |
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,18 @@ | ||
package ast | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestStaticAssertDecl(t *testing.T) { | ||
nodes := map[string]Node{ | ||
`0x3526a70 <line:3108:1, col:80> col:1`: &StaticAssertDecl{ | ||
Addr: 0x3526a70, | ||
Pos: NewPositionFromString("line:3108:1, col:80"), | ||
Position2: "col:1", | ||
ChildNodes: []Node{}, | ||
}, | ||
} | ||
|
||
runNodeTests(t, nodes) | ||
} |
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