Skip to content

Feature reuse result of common expr #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
11 changes: 11 additions & 0 deletions ast/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (

// Node represents items of abstract syntax tree.
type Node interface {
SubExpr() string
SetSubExpr(string)
Location() file.Location
SetLocation(file.Location)
Type() reflect.Type
Expand All @@ -24,13 +26,22 @@ func Patch(node *Node, newNode Node) {

type base struct {
loc file.Location
subExpr string
nodeType reflect.Type
}

func (n *base) Location() file.Location {
return n.loc
}

func (n *base) SubExpr() string {
return n.subExpr
}

func (n *base) SetSubExpr(s string) {
n.subExpr = s
}

func (n *base) SetLocation(loc file.Location) {
n.loc = loc
}
Expand Down
35 changes: 28 additions & 7 deletions bench_test.go

Large diffs are not rendered by default.

Loading