Skip to content

Commit

Permalink
Merge pull request #45 from bongo227/master
Browse files Browse the repository at this point in the history
Refactored ast nodes into separate package
  • Loading branch information
elliotchance authored Apr 17, 2017
2 parents 572710e + 802065d commit 9bb200e
Show file tree
Hide file tree
Showing 72 changed files with 1,208 additions and 835 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ script:
set -e
echo "" > coverage.txt
for d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
go test -race -coverprofile=profile.out -coverpkg ./...
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
# These steps are from the README to verify it can be installed and run as
# documented.
Expand Down
163 changes: 0 additions & 163 deletions ast.go

This file was deleted.

14 changes: 11 additions & 3 deletions always_inline_attr.go → ast/always_inline_attr.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package main
package ast

type AlwaysInlineAttr struct {
Address string
Position string
Children []interface{}
Children []Node
}

func parseAlwaysInlineAttr(line string) *AlwaysInlineAttr {
Expand All @@ -15,6 +15,14 @@ func parseAlwaysInlineAttr(line string) *AlwaysInlineAttr {
return &AlwaysInlineAttr{
Address: groups["address"],
Position: groups["position"],
Children: []interface{}{},
Children: []Node{},
}
}

func (n *AlwaysInlineAttr) render(ast *Ast) (string, string) {
return "", ""
}

func (n *AlwaysInlineAttr) AddChild(node Node) {
n.Children = append(n.Children, node)
}
18 changes: 12 additions & 6 deletions array_subscript_expr.go → ast/array_subscript_expr.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package ast

import "fmt"

Expand All @@ -7,7 +7,7 @@ type ArraySubscriptExpr struct {
Position string
Type string
Kind string
Children []interface{}
Children []Node
}

func parseArraySubscriptExpr(line string) *ArraySubscriptExpr {
Expand All @@ -21,12 +21,18 @@ func parseArraySubscriptExpr(line string) *ArraySubscriptExpr {
Position: groups["position"],
Type: groups["type"],
Kind: groups["kind"],
Children: []interface{}{},
Children: []Node{},
}
}

func (n *ArraySubscriptExpr) Render() []string {
func (n *ArraySubscriptExpr) render(ast *Ast) (string, string) {
children := n.Children
return []string{fmt.Sprintf("%s[%s]", renderExpression(children[0])[0],
renderExpression(children[1])[0]), "unknown1"}
expression, _ := renderExpression(ast, children[0])
index, _ := renderExpression(ast, children[1])
src := fmt.Sprintf("%s[%s]", expression, index)
return src, "unknown1"
}

func (n *ArraySubscriptExpr) AddChild(node Node) {
n.Children = append(n.Children, node)
}
14 changes: 11 additions & 3 deletions asm_label_attr.go → ast/asm_label_attr.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package main
package ast

type AsmLabelAttr struct {
Address string
Position string
FunctionName string
Children []interface{}
Children []Node
}

func parseAsmLabelAttr(line string) *AsmLabelAttr {
Expand All @@ -17,6 +17,14 @@ func parseAsmLabelAttr(line string) *AsmLabelAttr {
Address: groups["address"],
Position: groups["position"],
FunctionName: groups["function"],
Children: []interface{}{},
Children: []Node{},
}
}

func (n *AsmLabelAttr) render(ast *Ast) (string, string) {
return "", ""
}

func (n *AsmLabelAttr) AddChild(node Node) {
n.Children = append(n.Children, node)
}
Loading

0 comments on commit 9bb200e

Please sign in to comment.