node: rename ret variable

This commit is contained in:
mappu 2020-04-08 20:33:37 +12:00
parent 2a9d079216
commit fc41691e4a

16
node.go
View File

@ -1284,9 +1284,9 @@ func removeParens(expr string) string {
func (this *conversionState) resolveName(n node.Node) (string, error) { func (this *conversionState) resolveName(n node.Node) (string, error) {
// TODO support namespace lookups // TODO support namespace lookups
paramType := unknownVarType ret := unknownVarType
if n == nil || n == node.Node(nil) { if n == nil || n == node.Node(nil) {
return paramType, nil return ret, nil
} }
switch n := n.(type) { switch n := n.(type) {
@ -1294,26 +1294,26 @@ func (this *conversionState) resolveName(n node.Node) (string, error) {
if len(n.Parts) != 1 { if len(n.Parts) != 1 {
return "", parseErr{n, fmt.Errorf("name has %d parts, expected 1", len(n.Parts))} return "", parseErr{n, fmt.Errorf("name has %d parts, expected 1", len(n.Parts))}
} }
paramType = n.Parts[0].(*name.NamePart).Value ret = n.Parts[0].(*name.NamePart).Value
case *name.Name: case *name.Name:
if len(n.Parts) != 1 { if len(n.Parts) != 1 {
return "", parseErr{n, fmt.Errorf("name has %d parts, expected 1", len(n.Parts))} return "", parseErr{n, fmt.Errorf("name has %d parts, expected 1", len(n.Parts))}
} }
paramType = n.Parts[0].(*name.NamePart).Value ret = n.Parts[0].(*name.NamePart).Value
default: default:
return "", fmt.Errorf("unexpected name type %#v", n) return "", fmt.Errorf("unexpected name type %#v", n)
} }
// Handle class lookups // Handle class lookups
if strings.ToLower(paramType) == "parent" { if strings.ToLower(ret) == "parent" {
if this.currentClassParentName == "" { if this.currentClassParentName == "" {
return "", parseErr{n, fmt.Errorf("Lookup of 'parent' while not in an inherited child class context")} return "", parseErr{n, fmt.Errorf("Lookup of 'parent' while not in an inherited child class context")}
} }
return `this.` + this.currentClassParentName, nil return `this.` + this.currentClassParentName, nil
} else if strings.ToLower(paramType) == "self" { } else if strings.ToLower(ret) == "self" {
// Let it through as-is // Let it through as-is
// return "", parseErr{n, fmt.Errorf("Lookup of 'self::' should have been resolved already")} // return "", parseErr{n, fmt.Errorf("Lookup of 'self::' should have been resolved already")}
/* /*
@ -1322,12 +1322,12 @@ func (this *conversionState) resolveName(n node.Node) (string, error) {
} }
return `this`, nil return `this`, nil
*/ */
} else if strings.ToLower(paramType) == "static" { } else if strings.ToLower(ret) == "static" {
return "", parseErr{n, fmt.Errorf("'static::' is not yet supported")} return "", parseErr{n, fmt.Errorf("'static::' is not yet supported")}
} }
return paramType, nil return ret, nil
} }
func (this *conversionState) convertAssignment(n *assign.Assign, isTopLevelStatement bool) (string, error) { func (this *conversionState) convertAssignment(n *assign.Assign, isTopLevelStatement bool) (string, error) {