Skip to content

Commit 40bdc3c

Browse files
author
Randall C. O'Reilly
committed
remove testing println and expt with const enum type scoping -- not successful. better to just use .value manually as needed.
1 parent 86b55cd commit 40bdc3c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

pyedits.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package main
66

77
import (
88
"bytes"
9-
"fmt"
109
"strings"
1110

1211
"github.com/goki/gotopy/pyprint"
@@ -177,7 +176,6 @@ func pyEdits(src []byte) []byte {
177176
nln = append(nln, ln[pi+1:pi+comi]...)
178177
nln = append(nln, '.')
179178
meth := bytes.ToLower(ln[idx+len(stringsdot) : pi+1])
180-
fmt.Println(string(meth))
181179
if bytes.Equal(meth, []byte("fields(")) {
182180
meth = []byte("split(")
183181
}

pyprint/nodes.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,17 @@ func isBinary(expr ast.Expr) bool {
792792
return ok
793793
}
794794

795+
func (p *printer) ident(id *ast.Ident) {
796+
// if id.Name == "AlphaCycle" {
797+
// fmt.Printf("%+V\n", id)
798+
// }
799+
// todo: seems like Obj is typically nil.. not sure how to fix this..
800+
if id.Obj != nil && id.Obj.Kind == ast.Con { // constants are assumed to be Enums -- use type scoping for python
801+
p.print(id.Obj.Name, token.PERIOD)
802+
}
803+
p.print(id.Pos(), id)
804+
}
805+
795806
func (p *printer) expr1(expr ast.Expr, prec1, depth int) {
796807
p.print(expr.Pos())
797808

@@ -800,7 +811,7 @@ func (p *printer) expr1(expr ast.Expr, prec1, depth int) {
800811
p.print("BadExpr")
801812

802813
case *ast.Ident:
803-
p.print(x)
814+
p.ident(x)
804815

805816
case *ast.BinaryExpr:
806817
if depth < 1 {
@@ -1115,7 +1126,10 @@ func (p *printer) selectorExpr(x *ast.SelectorExpr, depth int, isMethod bool) bo
11151126
}
11161127
return true
11171128
}
1118-
p.print(x.Sel.Pos(), x.Sel)
1129+
// if x.Sel.Name == "AlphaCycle" {
1130+
// fmt.Printf("%+V\n", x)
1131+
// }
1132+
p.ident(x.Sel)
11191133
return false
11201134
}
11211135

0 commit comments

Comments
 (0)