Skip to content

Commit

Permalink
Remove Node.Kind() method
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Jun 1, 2024
1 parent 73cb42d commit efa006a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
10 changes: 0 additions & 10 deletions ast/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type Node interface {
SetLocation(file.Location)
Nature() nature.Nature
SetNature(nature.Nature)
Kind() reflect.Kind
Type() reflect.Type
SetType(reflect.Type)
String() string
Expand Down Expand Up @@ -57,15 +56,6 @@ func (n *base) SetNature(nature nature.Nature) {
n.nature = nature
}

// Kind returns the kind of the node.
// If the type is nil (meaning unknown) then it returns reflect.Interface.
func (n *base) Kind() reflect.Kind {
if n.nature.Type == nil {
return reflect.Interface
}
return n.nature.Type.Kind()
}

// Type returns the type of the node.
func (n *base) Type() reflect.Type {
if n.nature.Type == nil {
Expand Down
4 changes: 2 additions & 2 deletions compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (c *compiler) IntegerNode(node *ast.IntegerNode) {
}

func (c *compiler) FloatNode(node *ast.FloatNode) {
switch node.Kind() {
switch node.Type().Kind() {
case reflect.Float32:
c.emitPush(float32(node.Value))
case reflect.Float64:
Expand Down Expand Up @@ -1199,7 +1199,7 @@ func (c *compiler) PairNode(node *ast.PairNode) {
}

func (c *compiler) derefInNeeded(node ast.Node) {
switch node.Kind() {
switch node.Type().Kind() {
case reflect.Ptr, reflect.Interface:
c.emit(OpDeref)
}
Expand Down

0 comments on commit efa006a

Please sign in to comment.