node: implement stmt.ConstList
This commit is contained in:
parent
51ca4ecd77
commit
885d100fbf
26
node.go
26
node.go
@ -621,6 +621,32 @@ func (this *conversionState) convertNoFreeFloating(n_ node.Node) (string, error)
|
||||
|
||||
return "fmt.Print(" + quoted + ")\n", nil // newline - standalone statement
|
||||
|
||||
case *stmt.ConstList:
|
||||
consts := make([]string, 0, len(n.Consts))
|
||||
for _, c_ := range n.Consts {
|
||||
c, ok := c_.(*stmt.Constant)
|
||||
if !ok {
|
||||
return "", parseErr{c_, fmt.Errorf("expected stmt.Constant")}
|
||||
}
|
||||
|
||||
// TODO c.PhpDocComment
|
||||
|
||||
constName := c.ConstantName.(*node.Identifier).Value
|
||||
|
||||
rvalue, err := this.convert(c.Expr)
|
||||
if err != nil {
|
||||
return "", parseErr{c, err}
|
||||
}
|
||||
|
||||
consts = append(consts, constName+" = "+rvalue)
|
||||
}
|
||||
|
||||
if len(n.Consts) == 1 {
|
||||
return "const " + consts[0] + "\n", nil
|
||||
} else {
|
||||
return "const (\n" + strings.Join(consts, "\n") + ")\n", nil
|
||||
}
|
||||
|
||||
case *stmt.If:
|
||||
|
||||
hasCondAssign, err := hasInteriorAssignment(n.Cond)
|
||||
|
Loading…
Reference in New Issue
Block a user