<commit_before>// next gen iris 64-bit implementation
package iris2

import (
	"fmt"
	"math"
	"reflect"
)

type Word uint64

type Register struct {
	value Word
}

func (this Register) Bool() bool {
	return this.value != 0
}
func (this Register) RawBits() Word {
	return this.value
}
func (this *Register) SetRawBits(value Word) {
	this.value = value
}
func (this *Register) SetValue(value interface{}) error {
	switch t := value.(type) {
	case bool:
		if value.(bool) {
			this.value = 1
		} else {
			this.value = 0
		}
	case int8:
		this.value = Word(value.(int8))
	case uint8:
		this.value = Word(value.(uint8))
	case int16:
		this.value = Word(value.(int16))
	case uint16:
		this.value = Word(value.(uint16))
	case int32:
		this.value = Word(value.(int32))
	case uint32:
		this.value = Word(value.(uint32))
	case int64:
		this.value = Word(value.(int64))
	case uint64:
		this.value = Word(value.(uint64))
	case int:
		this.value = Word(value.(int))
	case uint:
		this.value = Word(value.(uint))
	case Word:
		this.value = value.(Word)
	case float32:
		this.value = Word(math.Float32bits(value.(float32)))
	case float64:
		this.value = Word(math.Float64bits(value.(float64)))
	default:
		return fmt.Errorf("Illegal value of type: %t", t)
	}
	return nil
}

func (this *Register) GetValueAs(valueType reflect.Type) (interface{}, error) {
	k := valueType.Kind()
	switch k {
	case reflect.Bool:
		return this.value != 0, nil
	case reflect.Int8:
		return int8(this.value), nil
	case reflect.Uint8:
		return uint8(this.value), nil
	case reflect.Int16:
		return int16(this.value), nil
	case reflect.Uint16:
		return uint16(this.value), nil
	case reflect.Int32:
		return int32(this.value), nil
	case reflect.Uint32:
		return uint32(this.value), nil
	case reflect.Int64:
		return int64(this.value), nil
	case reflect.Uint64:
		return uint64(this.value), nil
	case reflect.Float32:
		return math.Float32frombits(uint32(this.value)), nil
	case reflect.Float64:
		return math.Float64frombits(uint64(this.value)), nil
	default:
		return nil, fmt.Errorf("Illegal type: %s", k.String())
	}
}<commit_msg>Finished implementing the register type<commit_after>// next gen iris 64-bit implementation
package iris2

import (
	"fmt"
	"math"
	"reflect"
)

const (
	IPMask = 0xFFFFFFFFF000000F // last four bits offset for instruction pointer

	RegisterKindWord = iota
	RegisterKindHalfWord
	RegisterKindQuarterWord
	RegisterKindByte
	RegisterKindBool
	RegisterKindFloat32
	RegisterKindFloat64
)

type Cell byte
type Word uint64

type Register struct {
	unsigned  bool
	valueType byte
	value     Word
}

func (this *Register) Kind() byte {
	return this.valueType
}
func (this *Register) RawBits() Word {
	return this.value
}
func (this *Register) SetRawBits(value Word) {
	this.value = value
}
func (this *Register) SetValue(value interface{}) error {
	switch t := value.(type) {
	case bool:
		this.unsigned = false
		this.valueType = RegisterKindBool
		if value.(bool) {
			this.value = 1
		} else {
			this.value = 0
		}
	case int8:
		this.value = Word(value.(int8))
		this.unsigned = false
		this.valueType = RegisterKindByte
	case uint8:
		this.value = Word(value.(uint8))
		this.unsigned = true
		this.valueType = RegisterKindByte
	case int16:
		this.unsigned = false
		this.value = Word(value.(int16))
		this.valueType = RegisterKindQuarterWord
	case uint16:
		this.unsigned = true
		this.value = Word(value.(uint16))
		this.valueType = RegisterKindQuarterWord
	case int32:
		this.unsigned = false
		this.value = Word(value.(int32))
		this.valueType = RegisterKindHalfWord
	case uint32:
		this.unsigned = true
		this.value = Word(value.(uint32))
		this.valueType = RegisterKindHalfWord
	case int64:
		this.unsigned = false
		this.value = Word(value.(int64))
		this.valueType = RegisterKindWord
	case uint64:
		this.unsigned = true
		this.value = Word(value.(uint64))
		this.valueType = RegisterKindWord
	case int:
		this.unsigned = false
		this.valueType = RegisterKindWord
		this.value = Word(value.(int))
	case uint:
		this.unsigned = true
		this.valueType = RegisterKindWord
		this.value = Word(value.(uint))
	case Word:
		this.unsigned = true
		this.valueType = RegisterKindWord
		this.value = value.(Word)
	case float32:
		this.unsigned = false
		this.valueType = RegisterKindFloat32
		this.value = Word(math.Float32bits(value.(float32)))
	case float64:
		this.unsigned = false
		this.valueType = RegisterKindFloat64
		this.value = Word(math.Float64bits(value.(float64)))
	default:
		return fmt.Errorf("Illegal value of type: %t", t)
	}
	return nil
}

func (this *Register) GetValue() (interface{}, error) {
	switch this.valueType {
	case RegisterKindWord:
		if this.unsigned {
			return this.value, nil
		} else {
			return int64(this.value), nil
		}
	case RegisterKindHalfWord:
		if this.unsigned {
			return uint32(this.value), nil
		} else {
			return int32(this.value), nil
		}
	case RegisterKindQuarterWord:
		if this.unsigned {
			return uint16(this.value), nil
		} else {
			return int16(this.value), nil
		}
	case RegisterKindBool:
		return this.value != 0, nil
	case RegisterKindByte:
		if this.unsigned {
			return uint8(this.value), nil
		} else {
			return int8(this.value), nil
		}
	case RegisterKindFloat32:
		return math.Float32frombits(uint32(this.value)), nil
	case RegisterKindFloat64:
		return math.Float64frombits(uint64(this.value)), nil
	default:
		return nil, fmt.Errorf("Unknown type code: %d", this.valueType)
	}
}
func (this *Register) GetValueAs(valueType reflect.Type) (interface{}, error) {
	k := valueType.Kind()
	switch k {
	case reflect.Bool:
		return this.value != 0, nil
	case reflect.Int8:
		return int8(this.value), nil
	case reflect.Uint8:
		return uint8(this.value), nil
	case reflect.Int16:
		return int16(this.value), nil
	case reflect.Uint16:
		return uint16(this.value), nil
	case reflect.Int32:
		return int32(this.value), nil
	case reflect.Uint32:
		return uint32(this.value), nil
	case reflect.Int64:
		return int64(this.value), nil
	case reflect.Uint64:
		return uint64(this.value), nil
	case reflect.Float32:
		return math.Float32frombits(uint32(this.value)), nil
	case reflect.Float64:
		return math.Float64frombits(uint64(this.value)), nil
	default:
		return nil, fmt.Errorf("Illegal type: %s", k.String())
	}
}

func MaskInstructionPointer(value Word) Word {
	return value &^ IPMask
}
{'fraction_non_alphanumeric': 0.11873517786561265, 'fraction_numerical': 0.03430830039525692, 'mean_word_length': 4.097502014504432, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '4178489', 'n_tokens_mistral': 2407, 'n_tokens_neox': 2166, 'n_words': 559}