<commit_before>package main

import (
	"bytes"
	"fmt"
	"reflect"
)

func ensureMap(args []Object, index int) *ArrayMap {
	switch obj := args[index].(type) {
	case *ArrayMap:
		return obj
	default:
		panic(RT.newArgTypeError(index, "Map"))
	}
}

var procMeta Proc = func(args []Object) Object {
	switch obj := args[0].(type) {
	case Meta:
		meta := obj.GetMeta()
		if meta != nil {
			return meta
		}
	}
	return NIL
}

var procWithMeta Proc = func(args []Object) Object {
	checkArity(args, 2, 2)
	return ensureMeta(args, 0).WithMeta(ensureMap(args, 1))
}

var procIsZero Proc = func(args []Object) Object {
	n := ensureNumber(args, 0)
	ops := GetOps(n)
	return Bool{b: ops.IsZero(n)}
}

var procIsPos Proc = func(args []Object) Object {
	n := ensureNumber(args, 0)
	ops := GetOps(n)
	return Bool{b: ops.Gt(n, Int{i: 0})}
}

var procIsNeg Proc = func(args []Object) Object {
	n := ensureNumber(args, 0)
	ops := GetOps(n)
	return Bool{b: ops.Lt(n, Int{i: 0})}
}

var procAdd Proc = func(args []Object) Object {
	x := assertNumber(args[0], "")
	y := assertNumber(args[1], "")
	ops := GetOps(x).Combine(GetOps(y))
	return ops.Add(x, y)
}

var procAddEx Proc = func(args []Object) Object {
	x := assertNumber(args[0], "")
	y := assertNumber(args[1], "")
	ops := GetOps(x).Combine(GetOps(y)).Combine(BIGINT_OPS)
	return ops.Add(x, y)
}

var procMultiply Proc = func(args []Object) Object {
	x := assertNumber(args[0], "")
	y := assertNumber(args[1], "")
	ops := GetOps(x).Combine(GetOps(y))
	return ops.Multiply(x, y)
}

var procMultiplyEx Proc = func(args []Object) Object {
	x := assertNumber(args[0], "")
	y := assertNumber(args[1], "")
	ops := GetOps(x).Combine(GetOps(y)).Combine(BIGINT_OPS)
	return ops.Multiply(x, y)
}

var procSubtract Proc = func(args []Object) Object {
	var a, b Object
	if len(args) == 1 {
		a = Int{i: 0}
		b = args[0]
	} else {
		a = args[0]
		b = args[1]
	}
	ops := GetOps(a).Combine(GetOps(b))
	return ops.Subtract(assertNumber(a, ""), assertNumber(b, ""))
}

var procSubtractEx Proc = func(args []Object) Object {
	var a, b Object
	if len(args) == 1 {
		a = Int{i: 0}
		b = args[0]
	} else {
		a = args[0]
		b = args[1]
	}
	ops := GetOps(a).Combine(GetOps(b)).Combine(BIGINT_OPS)
	return ops.Subtract(assertNumber(a, ""), assertNumber(b, ""))
}

var procDivide Proc = func(args []Object) Object {
	x := ensureNumber(args, 0)
	y := ensureNumber(args, 1)
	ops := GetOps(x).Combine(GetOps(y))
	return ops.Divide(x, y)
}

var procQuot Proc = func(args []Object) Object {
	x := ensureNumber(args, 0)
	y := ensureNumber(args, 1)
	ops := GetOps(x).Combine(GetOps(y))
	return ops.Quotient(x, y)
}

var procRem Proc = func(args []Object) Object {
	x := ensureNumber(args, 0)
	y := ensureNumber(args, 1)
	ops := GetOps(x).Combine(GetOps(y))
	return ops.Rem(x, y)
}

var procBitNot Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	return Int{i: ^x.i}
}

var procBitAnd Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Int{i: x.i & y.i}
}

var procBitOr Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Int{i: x.i | y.i}
}

var procBitXor Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Int{i: x.i ^ y.i}
}

var procBitAndNot Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Int{i: x.i &^ y.i}
}

var procBitClear Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Int{i: x.i &^ (1 << uint(y.i))}
}

var procBitSet Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Int{i: x.i | (1 << uint(y.i))}
}

var procBitFlip Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Int{i: x.i ^ (1 << uint(y.i))}
}

var procBitTest Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Bool{b: x.i&(1<<uint(y.i)) != 0}
}

var procBitShiftLeft Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Int{i: x.i << uint(y.i)}
}

var procBitShiftRight Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Int{i: x.i >> uint(y.i)}
}

var procUnsignedBitShiftRight Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return Int{i: int(uint(x.i) >> uint(y.i))}
}

var procExInfo Proc = func(args []Object) Object {
	checkArity(args, 2, 2)
	return &ExInfo{
		msg:  ensureString(args, 0),
		data: ensureMap(args, 1),
		rt:   RT.clone(),<commit_msg>Refactor<commit_after>package main

import (
	"bytes"
	"fmt"
	"reflect"
)

func ensureMap(args []Object, index int) *ArrayMap {
	switch obj := args[index].(type) {
	case *ArrayMap:
		return obj
	default:
		panic(RT.newArgTypeError(index, "Map"))
	}
}

var procMeta Proc = func(args []Object) Object {
	switch obj := args[0].(type) {
	case Meta:
		meta := obj.GetMeta()
		if meta != nil {
			return meta
		}
	}
	return NIL
}

var procWithMeta Proc = func(args []Object) Object {
	checkArity(args, 2, 2)
	return ensureMeta(args, 0).WithMeta(ensureMap(args, 1))
}

var procIsZero Proc = func(args []Object) Object {
	n := ensureNumber(args, 0)
	ops := GetOps(n)
	return Bool{b: ops.IsZero(n)}
}

var procIsPos Proc = func(args []Object) Object {
	n := ensureNumber(args, 0)
	ops := GetOps(n)
	return Bool{b: ops.Gt(n, Int{i: 0})}
}

var procIsNeg Proc = func(args []Object) Object {
	n := ensureNumber(args, 0)
	ops := GetOps(n)
	return Bool{b: ops.Lt(n, Int{i: 0})}
}

var procAdd Proc = func(args []Object) Object {
	x := assertNumber(args[0], "")
	y := assertNumber(args[1], "")
	ops := GetOps(x).Combine(GetOps(y))
	return ops.Add(x, y)
}

var procAddEx Proc = func(args []Object) Object {
	x := assertNumber(args[0], "")
	y := assertNumber(args[1], "")
	ops := GetOps(x).Combine(GetOps(y)).Combine(BIGINT_OPS)
	return ops.Add(x, y)
}

var procMultiply Proc = func(args []Object) Object {
	x := assertNumber(args[0], "")
	y := assertNumber(args[1], "")
	ops := GetOps(x).Combine(GetOps(y))
	return ops.Multiply(x, y)
}

var procMultiplyEx Proc = func(args []Object) Object {
	x := assertNumber(args[0], "")
	y := assertNumber(args[1], "")
	ops := GetOps(x).Combine(GetOps(y)).Combine(BIGINT_OPS)
	return ops.Multiply(x, y)
}

var procSubtract Proc = func(args []Object) Object {
	var a, b Object
	if len(args) == 1 {
		a = Int{i: 0}
		b = args[0]
	} else {
		a = args[0]
		b = args[1]
	}
	ops := GetOps(a).Combine(GetOps(b))
	return ops.Subtract(assertNumber(a, ""), assertNumber(b, ""))
}

var procSubtractEx Proc = func(args []Object) Object {
	var a, b Object
	if len(args) == 1 {
		a = Int{i: 0}
		b = args[0]
	} else {
		a = args[0]
		b = args[1]
	}
	ops := GetOps(a).Combine(GetOps(b)).Combine(BIGINT_OPS)
	return ops.Subtract(assertNumber(a, ""), assertNumber(b, ""))
}

var procDivide Proc = func(args []Object) Object {
	x := ensureNumber(args, 0)
	y := ensureNumber(args, 1)
	ops := GetOps(x).Combine(GetOps(y))
	return ops.Divide(x, y)
}

var procQuot Proc = func(args []Object) Object {
	x := ensureNumber(args, 0)
	y := ensureNumber(args, 1)
	ops := GetOps(x).Combine(GetOps(y))
	return ops.Quotient(x, y)
}

var procRem Proc = func(args []Object) Object {
	x := ensureNumber(args, 0)
	y := ensureNumber(args, 1)
	ops := GetOps(x).Combine(GetOps(y))
	return ops.Rem(x, y)
}

var procBitNot Proc = func(args []Object) Object {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	return Int{i: ^x.i}
}

func assertInts(args []Object) (Int, Int) {
	x := assertInt(args[0], "Bit operation not supported for "+args[0].GetType().ToString(false))
	y := assertInt(args[1], "Bit operation not supported for "+args[1].GetType().ToString(false))
	return x, y
}

var procBitAnd Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Int{i: x.i & y.i}
}

var procBitOr Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Int{i: x.i | y.i}
}

var procBitXor Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Int{i: x.i ^ y.i}
}

var procBitAndNot Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Int{i: x.i &^ y.i}
}

var procBitClear Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Int{i: x.i &^ (1 << uint(y.i))}
}

var procBitSet Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Int{i: x.i | (1 << uint(y.i))}
}

var procBitFlip Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Int{i: x.i ^ (1 << uint(y.i))}
}

var procBitTest Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Bool{b: x.i&(1<<uint(y.i)) != 0}
}

var procBitShiftLeft Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Int{i: x.i << uint(y.i)}
}

var procBitShiftRight Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Int{i: x.i >> uint(y.i)}
}

var procUnsignedBitShiftRight Proc = func(args []Object) Object {
	x, y := assertInts(args)
	return Int{i: int(uint(x.i) >> uint(y.i))}
}

var procExInfo Proc = func(args []Object) Object {
	checkArity(args, 2, 2)
	return &ExInfo{
		msg:  ensureString(args, 0),
		data: ensureMap(args, 1),
		rt:   RT.clone(),
{'fraction_non_alphanumeric': 0.18424676397686587, 'fraction_numerical': 0.012668686312310658, 'mean_word_length': 4.668054110301769, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 11, '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': '150993', 'n_tokens_mistral': 4347, 'n_tokens_neox': 4174, 'n_words': 1066}