-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalue_lambda.go
48 lines (38 loc) · 990 Bytes
/
value_lambda.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package codegen
import "strings"
type lambdaValue struct {
block *funcBlock
}
// Lambda creates a new lambda function value
func Lambda() *lambdaValue {
block := newFunc("")
block.newLine = false
return &lambdaValue{
block: block,
}
}
// Params appends parameters to the lambda definition
func (l *lambdaValue) Params(params ...*ParamDecl) *lambdaValue {
l.block.Params(params...)
return l
}
// ReturnTypes appends return parameters to the lambda definition
func (l *lambdaValue) ReturnTypes(returnTypes ...*TypeDecl) *lambdaValue {
l.block.ReturnTypes(returnTypes...)
return l
}
// Block appends the block to the lambda definition
func (l *lambdaValue) Block(stmts ...Stmt) *lambdaValue {
l.block.Block(stmts...)
return l
}
// Call calls the lambda definition
func (l *lambdaValue) Call() *callValue {
return newCallValue(l, "")
}
func (l *lambdaValue) writeValue(sb *strings.Builder) {
l.block.write(sb)
}
func (l *lambdaValue) isPointer() bool {
return false
}