Skip to content

Commit

Permalink
Refactored ast nodes into seperate package.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoeyfyi committed Apr 16, 2017
1 parent c7b9916 commit 75540be
Show file tree
Hide file tree
Showing 68 changed files with 769 additions and 595 deletions.
163 changes: 0 additions & 163 deletions ast.go

This file was deleted.

6 changes: 5 additions & 1 deletion always_inline_attr.go → ast/always_inline_attr.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package ast

type AlwaysInlineAttr struct {
Address string
Expand All @@ -18,3 +18,7 @@ func parseAlwaysInlineAttr(line string) *AlwaysInlineAttr {
Children: []interface{}{},
}
}

func (n *AlwaysInlineAttr) render(ast *Ast) (string, string) {
return "", ""
}
14 changes: 8 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,14 @@ 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"
}
6 changes: 5 additions & 1 deletion asm_label_attr.go → ast/asm_label_attr.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package ast

type AsmLabelAttr struct {
Address string
Expand All @@ -20,3 +20,7 @@ func parseAsmLabelAttr(line string) *AsmLabelAttr {
Children: []interface{}{},
}
}

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

0 comments on commit 75540be

Please sign in to comment.