Skip to content

Commit 3f30228

Browse files
committed
refactor: move common func methods to dsl/ops/func.go
1 parent 03e732d commit 3f30228

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

dsl/ops/func.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ops
2+
3+
type funcBase string
4+
5+
func (f *funcBase) String() string {
6+
return string(*f)
7+
}
8+
9+
func (*funcBase) IsMacro() bool {
10+
return false
11+
}

dsl/ops/func_do.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,15 @@ import (
88
)
99

1010
func init() {
11-
opName := doOp("do")
12-
DoOp = &opName
1311
opsMap["do"] = DoOp
1412
}
1513

16-
type doOp string
17-
18-
// DoOp is "do" operation
19-
var DoOp *doOp
20-
21-
func (*doOp) String() string {
22-
return string(*DoOp)
14+
type doOp struct {
15+
funcBase
2316
}
2417

25-
func (*doOp) IsMacro() bool {
26-
return false
27-
}
18+
// DoOp is "do" operation
19+
var DoOp = &doOp{funcBase("do")}
2820

2921
func (*doOp) Bind(args ...types.Value) (types.Expr, error) {
3022
sig := make([]types.Type, 0, len(args))

0 commit comments

Comments
 (0)