<commit_before>package otto

import (
	"reflect"
	"strconv"
)

type _runtime struct {
	Stack [](*_executionContext)

	GlobalObject      *_object
	GlobalEnvironment *_objectEnvironment

	Global struct {
		Object   *_object // Object( ... ), new Object( ... ) - 1 (length)
		Function *_object // Function( ... ), new Function( ... ) - 1
		Array    *_object // Array( ... ), new Array( ... ) - 1
		String   *_object // String( ... ), new String( ... ) - 1
		Boolean  *_object // Boolean( ... ), new Boolean( ... ) - 1
		Number   *_object // Number( ... ), new Number( ... ) - 1
		Math     *_object
		Date     *_object // Date( ... ), new Date( ... ) - 7
		RegExp   *_object // RegExp( ... ), new RegExp( ... ) - 2
		Error    *_object // Error( ... ), new Error( ... ) - 1
		// JSON

		ObjectPrototype   *_object // Object.prototype
		FunctionPrototype *_object // Function.prototype
		ArrayPrototype    *_object // Array.prototype
		StringPrototype   *_object // String.prototype
		BooleanPrototype  *_object // Boolean.prototype
		NumberPrototype   *_object // Number.prototype
		DatePrototype     *_object // Date.prototype
		RegExpPrototype   *_object // RegExp.prototype
		ErrorPrototype    *_object // Error.prototype
	}

	_newError map[string]func(Value) *_object
	eval      *_object // The builtin eval, for determine indirect versus direct invocation
}

func (self *_runtime) EnterGlobalExecutionContext() {
	self.EnterExecutionContext(newExecutionContext(self.GlobalEnvironment, self.GlobalEnvironment, self.GlobalObject))
}

func (self *_runtime) EnterExecutionContext(scope *_executionContext) {
	self.Stack = append(self.Stack, scope)
}

func (self *_runtime) LeaveExecutionContext() {
	self.Stack = self.Stack[:len(self.Stack)-1]
}

func (self *_runtime) _executionContext(depth int) *_executionContext {
	if depth == 0 {
		return self.Stack[len(self.Stack)-1]
	}
	if len(self.Stack)-1+depth >= 0 {
		return self.Stack[len(self.Stack)-1+depth]
	}
	return nil
}

func (self *_runtime) EnterFunctionExecutionContext(function *_object, this Value) *_functionEnvironment {
	scopeEnvironment := function._Function.Call.ScopeEnvironment()
	if scopeEnvironment == nil {
		scopeEnvironment = self.GlobalEnvironment
	}
	environment := self.newFunctionEnvironment(scopeEnvironment)
	var thisObject *_object
	switch this._valueType {
	case valueUndefined, valueNull:
		thisObject = self.GlobalObject
	default:
		thisObject = self.toObject(this)
	}
	self.EnterExecutionContext(newExecutionContext(environment, environment, thisObject))
	return environment
}

func (self *_runtime) EnterEvalExecutionContext(call FunctionCall) {
	// Skip the current function lexical/variable environment, which is of the function execution context call
	// to eval (the global execution context). Instead, execute in the context of where the eval was called,
	// which is essentially dynamic scoping
	parent := self._executionContext(-1)
	new := newExecutionContext(parent.LexicalEnvironment, parent.VariableEnvironment, nil)
	new.eval = true
	self.EnterExecutionContext(new)
}

func (self *_runtime) Return(value Value) {
	panic(newReturnResult(value))
}

func (self *_runtime) Continue(target string) {<commit_msg>Establish eval execution context with the global object<commit_after>package otto

import (
	"reflect"
	"strconv"
)

type _runtime struct {
	Stack [](*_executionContext)

	GlobalObject      *_object
	GlobalEnvironment *_objectEnvironment

	Global struct {
		Object   *_object // Object( ... ), new Object( ... ) - 1 (length)
		Function *_object // Function( ... ), new Function( ... ) - 1
		Array    *_object // Array( ... ), new Array( ... ) - 1
		String   *_object // String( ... ), new String( ... ) - 1
		Boolean  *_object // Boolean( ... ), new Boolean( ... ) - 1
		Number   *_object // Number( ... ), new Number( ... ) - 1
		Math     *_object
		Date     *_object // Date( ... ), new Date( ... ) - 7
		RegExp   *_object // RegExp( ... ), new RegExp( ... ) - 2
		Error    *_object // Error( ... ), new Error( ... ) - 1
		// JSON

		ObjectPrototype   *_object // Object.prototype
		FunctionPrototype *_object // Function.prototype
		ArrayPrototype    *_object // Array.prototype
		StringPrototype   *_object // String.prototype
		BooleanPrototype  *_object // Boolean.prototype
		NumberPrototype   *_object // Number.prototype
		DatePrototype     *_object // Date.prototype
		RegExpPrototype   *_object // RegExp.prototype
		ErrorPrototype    *_object // Error.prototype
	}

	_newError map[string]func(Value) *_object
	eval      *_object // The builtin eval, for determine indirect versus direct invocation
}

func (self *_runtime) EnterGlobalExecutionContext() {
	self.EnterExecutionContext(newExecutionContext(self.GlobalEnvironment, self.GlobalEnvironment, self.GlobalObject))
}

func (self *_runtime) EnterExecutionContext(scope *_executionContext) {
	self.Stack = append(self.Stack, scope)
}

func (self *_runtime) LeaveExecutionContext() {
	self.Stack = self.Stack[:len(self.Stack)-1]
}

func (self *_runtime) _executionContext(depth int) *_executionContext {
	if depth == 0 {
		return self.Stack[len(self.Stack)-1]
	}
	if len(self.Stack)-1+depth >= 0 {
		return self.Stack[len(self.Stack)-1+depth]
	}
	return nil
}

func (self *_runtime) EnterFunctionExecutionContext(function *_object, this Value) *_functionEnvironment {
	scopeEnvironment := function._Function.Call.ScopeEnvironment()
	if scopeEnvironment == nil {
		scopeEnvironment = self.GlobalEnvironment
	}
	environment := self.newFunctionEnvironment(scopeEnvironment)
	var thisObject *_object
	switch this._valueType {
	case valueUndefined, valueNull:
		thisObject = self.GlobalObject
	default:
		thisObject = self.toObject(this)
	}
	self.EnterExecutionContext(newExecutionContext(environment, environment, thisObject))
	return environment
}

func (self *_runtime) EnterEvalExecutionContext(call FunctionCall) {
	// Skip the current function lexical/variable environment, which is of the function execution context call
	// to eval (the global execution context). Instead, execute in the context of where the eval was called,
	// which is essentially dynamic scoping
	parent := self._executionContext(-1)
	new := newExecutionContext(parent.LexicalEnvironment, parent.VariableEnvironment, self.GlobalObject)
	// FIXME Make passing through of self.GlobalObject more general? Whenever newExecutionContext is passed a nil object?
	new.eval = true
	self.EnterExecutionContext(new)
}

func (self *_runtime) Return(value Value) {
	panic(newReturnResult(value))
}

func (self *_runtime) Continue(target string) {
{'fraction_non_alphanumeric': 0.12056629623991474, 'fraction_numerical': 0.00487136550464302, 'mean_word_length': 3.8415622697126013, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5670173', 'n_tokens_mistral': 1952, 'n_tokens_neox': 1866, 'n_words': 522}