<commit_before>package typeinfer

import (
	"fmt"
	"go/constant"

	"golang.org/x/tools/go/ssa"
)

// VarInstance is an interface for an instance of a defined value.
type VarInstance interface {
	Var() ssa.Value
	IsConcrete() bool
	GetInstance() int
	GetIndex() int64
	String() string
}

// Instance captures a specific instance of a SSA value by counting the
// number of instantiations.
type Instance struct {
	ssa.Value
	Instance int   // Instance number (default: 0)
	Index    int64 // Loop index associated with var (default: 0)
}

// Var returns the SSA value.
func (i *Instance) Var() ssa.Value { return i.Value }

func (i *Instance) IsConcrete() bool { return true }

// GetInstance() returns the instance number.
func (i *Instance) GetInstance() int { return i.Instance }

// GetIndex() returns the loop index.
func (i *Instance) GetIndex() int64 { return i.Index }
func (i *Instance) String() string {
	var parent string
	if i.Parent() != nil {
		parent = i.Parent().String()
	} else {
		parent = "__main__"
	}
	return fmt.Sprintf("%s.%s_%d_%d", parent, i.Name(), i.Instance, i.Index)
}

// ExtInstance captures an external instance of a SSA value by counting the
// instantiations.
//
// An external instance is one without ssa.Value, usually if the creating body
// is in runtime or not built as SSA.
type ExtInstance struct {
	parent   *ssa.Function
	Instance int
	Index    int64
}

// Var returns the SSA value (always nil).
func (i *ExtInstance) Var() ssa.Value { return nil }

func (i *ExtInstance) IsConcrete() bool { return false }

// GetInstance() returns the instance number.
func (i *ExtInstance) GetInstance() int { return i.Instance }

// GetIndex() returns the loop index.
func (i *ExtInstance) GetIndex() int64 { return i.Index }

func (i *ExtInstance) String() string {
	return fmt.Sprintf("%s.%s_%d_%d", i.parent, "_retval_", i.Instance, i.Index)
}

// ConstInstance captures a constant value.
//
// This is just a wrapper.
type ConstInstance struct {
	Const *ssa.Const
}

// Var returns the SSA value (always nil).
func (i *ConstInstance) Var() ssa.Value { return i.Const }

// IsConcrete always return true.
func (i *ConstInstance) IsConcrete() bool { return true }

// GetInstance returns the instance number.
func (i *ConstInstance) GetInstance() int { return 0 }

// GetIndex returns the loop index.
func (i *ConstInstance) GetIndex() int64 { return 0 }

func (i *ConstInstance) String() string {
	switch i.Const.Value.Kind() {
	case constant.Int:
		return fmt.Sprintf("%d", i.Const.Int64())
	case constant.Bool:
		return fmt.Sprintf("%s", i.Const.String())
	default:
		return fmt.Sprintf("__unimplemented__ %s", i.Const.Type())
	}
}<commit_msg>Show stringt<commit_after>package typeinfer

import (
	"fmt"
	"go/constant"

	"golang.org/x/tools/go/ssa"
)

// VarInstance is an interface for an instance of a defined value.
type VarInstance interface {
	Var() ssa.Value
	IsConcrete() bool
	GetInstance() int
	GetIndex() int64
	String() string
}

// Instance captures a specific instance of a SSA value by counting the
// number of instantiations.
type Instance struct {
	ssa.Value
	Instance int   // Instance number (default: 0)
	Index    int64 // Loop index associated with var (default: 0)
}

// Var returns the SSA value.
func (i *Instance) Var() ssa.Value { return i.Value }

func (i *Instance) IsConcrete() bool { return true }

// GetInstance() returns the instance number.
func (i *Instance) GetInstance() int { return i.Instance }

// GetIndex() returns the loop index.
func (i *Instance) GetIndex() int64 { return i.Index }
func (i *Instance) String() string {
	var parent string
	if i.Parent() != nil {
		parent = i.Parent().String()
	} else {
		parent = "__main__"
	}
	return fmt.Sprintf("%s.%s_%d_%d", parent, i.Name(), i.Instance, i.Index)
}

// ExtInstance captures an external instance of a SSA value by counting the
// instantiations.
//
// An external instance is one without ssa.Value, usually if the creating body
// is in runtime or not built as SSA.
type ExtInstance struct {
	parent   *ssa.Function
	Instance int
	Index    int64
}

// Var returns the SSA value (always nil).
func (i *ExtInstance) Var() ssa.Value { return nil }

func (i *ExtInstance) IsConcrete() bool { return false }

// GetInstance() returns the instance number.
func (i *ExtInstance) GetInstance() int { return i.Instance }

// GetIndex() returns the loop index.
func (i *ExtInstance) GetIndex() int64 { return i.Index }

func (i *ExtInstance) String() string {
	return fmt.Sprintf("%s.%s_%d_%d", i.parent, "_retval_", i.Instance, i.Index)
}

// ConstInstance captures a constant value.
//
// This is just a wrapper.
type ConstInstance struct {
	Const *ssa.Const
}

// Var returns the SSA value (always nil).
func (i *ConstInstance) Var() ssa.Value { return i.Const }

// IsConcrete always return true.
func (i *ConstInstance) IsConcrete() bool { return true }

// GetInstance returns the instance number.
func (i *ConstInstance) GetInstance() int { return 0 }

// GetIndex returns the loop index.
func (i *ConstInstance) GetIndex() int64 { return 0 }

func (i *ConstInstance) String() string {
	switch i.Const.Value.Kind() {
	case constant.Int:
		return fmt.Sprintf("%d", i.Const.Int64())
	case constant.Bool:
		return fmt.Sprintf("%s", i.Const.String())
	case constant.String:
		return fmt.Sprintf("%s", i.Const.String())
	default:
		return fmt.Sprintf("__unimplemented__ %s", i.Const.Type())
	}
}
{'fraction_non_alphanumeric': 0.12746725696365985, 'fraction_numerical': 0.006640841173215274, 'mean_word_length': 3.7897526501766783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5135346', 'n_tokens_mistral': 1766, 'n_tokens_neox': 1715, 'n_words': 632}