<commit_before>// JSObjectBase.java

package ed.js;

import java.io.*;
import java.util.*;

import ed.db.*;
import ed.js.func.*;
import ed.js.engine.*;

public class JSObjectBase implements JSObject {

    static {
        JS._debugSIStart( "JSObjectBase" );
    }

    static final String OBJECT_STRING = "Object";

    public JSObjectBase(){
    }

    public JSObjectBase( JSFunction constructor ){
        setConstructor( constructor );
    }

    public void prefunc(){}

    public Object set( Object n , Object v ){
        _readOnlyCheck();
        prefunc();
        if ( n == null )
            n = "null";
        
        if ( v != null && v instanceof String )
            v = new JSString( v.toString() );
        
        if ( n instanceof JSString )
            n = n.toString();
        
        if ( v != null &&  "_id".equals( n ) &&
	     ( ( v instanceof String ) || ( v instanceof JSString ) )
	     ){
            v = new ObjectId( v.toString() );
        }
            
        
        if ( n instanceof String ){
            String name = (String)n;
            
            if ( _map == null ){
                _map = new TreeMap<String,Object>();
                _keys = new ArrayList<String>();
            }
            
            
            if ( ! ( name.equals( "__proto__" ) || 
                     name.equals( "__constructor__" ) || 
                     name.equals( "constructor" ) || 
                     name.equals( "__parent__" ) ) )
                if ( ! _map.containsKey( n ) )
                    _keys.add( name );
            
            _map.put( name , v );
            return v;
        }
        
        if ( n instanceof Number ){
            setInt( ((Number)n).intValue() , v );
            return v;
        }
        
        throw new RuntimeException( "object key can't be a [" + n.getClass() + "]" );
    }

    public Object get( Object n ){

        prefunc();

        if ( n == null )
            n = "null";
        
        if ( n instanceof JSString )
            n = n.toString();
        
        if ( ! "__preGet".equals( n ) ){
            Object foo = _simpleGet( "__preGet" );
            if ( foo != null && foo instanceof JSFunction ){
                Scope s = Scope.getLastCreated();
                if ( s != null ){
                    try {
                        s.setThis( this );
                        ((JSFunction)foo).call( s , n );
                    }
                    finally {
                        s.clearThisNormal( null );
                    }
                }
            }
        }

        if ( n instanceof String )
            return _simpleGet( (String)n );
        
        if ( n instanceof Number )
            return getInt( ((Number)n).intValue() );
        
        throw new RuntimeException( "object key can't be a [" + n.getClass() + "]" );
    }

    public Object _simpleGet( String s ){
        Object res = null;
        
        if ( _map != null )
            res = _map.get( s );
        
        if ( res == null && _map != null ){
            JSObject proto = (JSObject)_map.get( "prototype" );
            if ( proto != null )
                res = proto.get( s );
        };

        if ( res == null && _constructor != null )
            res = _constructor._prototype.get( s );
        
        if ( res == null && _objectLowFunctions != null 
             && ( _map == null || _map.get( "prototype" ) == null ) 
             && _constructor == null ){
            res = _objectLowFunctions.get( s );
        }

        if ( res == null && 
             ! ( "__notFoundHandler".equals( s ) 
                 || "__preGet".equals( s )
                 )
             ){

            Object blah = _simpleGet( "__notFoundHandler" );
            if ( blah instanceof JSFunction ){
                JSFunction f = (JSFunction)blah;
                Scope scope = f.getScope();
                if ( scope == null )
                    scope = Scope.getLastCreated();
                scope = scope.child();
                scope.setThis( this );
                if ( ! _inNotFoundHandler.get() ){
                    try {
                        _inNotFoundHandler.set( true );
                        return f.call( scope , s );
                    }
                    finally {
                        _inNotFoundHandler.set( false );
                    }
                }
            }
        }

        return res;
    }

    public Object removeField( Object n ){
        if ( n == null )
            return null;
        
        if ( n instanceof JSString )
            n = n.toString();
        
        Object val = null;

        if ( n instanceof String ){
            if ( _map != null )
                val = _map.remove( (String)n );
            if ( _keys != null )
                _keys.remove( n );
        }
        
        return val;
    }


    public Object setInt( int n , Object v ){
        _readOnlyCheck();
        prefunc();
        return set( String.valueOf( n ) , v );
    }

    public Object getInt( int n ){
        prefunc();
        return get( String.valueOf( n ) );
    }


    public boolean containsKey( String s ){
        if ( _keys != null && _keys.contains( s ) )
            return true;
        
        if ( _constructor != null && _constructor._prototype.containsKey( s ) )
            return true;

        return false;<commit_msg>prefunc needs to happen befor containsKey<commit_after>// JSObjectBase.java

package ed.js;

import java.io.*;
import java.util.*;

import ed.db.*;
import ed.js.func.*;
import ed.js.engine.*;

public class JSObjectBase implements JSObject {

    static {
        JS._debugSIStart( "JSObjectBase" );
    }

    static final String OBJECT_STRING = "Object";

    public JSObjectBase(){
    }

    public JSObjectBase( JSFunction constructor ){
        setConstructor( constructor );
    }

    public void prefunc(){}

    public Object set( Object n , Object v ){
        _readOnlyCheck();
        prefunc();
        if ( n == null )
            n = "null";
        
        if ( v != null && v instanceof String )
            v = new JSString( v.toString() );
        
        if ( n instanceof JSString )
            n = n.toString();
        
        if ( v != null &&  "_id".equals( n ) &&
	     ( ( v instanceof String ) || ( v instanceof JSString ) )
	     ){
            v = new ObjectId( v.toString() );
        }
            
        
        if ( n instanceof String ){
            String name = (String)n;
            
            if ( _map == null ){
                _map = new TreeMap<String,Object>();
                _keys = new ArrayList<String>();
            }
            
            
            if ( ! ( name.equals( "__proto__" ) || 
                     name.equals( "__constructor__" ) || 
                     name.equals( "constructor" ) || 
                     name.equals( "__parent__" ) ) )
                if ( ! _map.containsKey( n ) )
                    _keys.add( name );
            
            _map.put( name , v );
            return v;
        }
        
        if ( n instanceof Number ){
            setInt( ((Number)n).intValue() , v );
            return v;
        }
        
        throw new RuntimeException( "object key can't be a [" + n.getClass() + "]" );
    }

    public Object get( Object n ){

        prefunc();

        if ( n == null )
            n = "null";
        
        if ( n instanceof JSString )
            n = n.toString();
        
        if ( ! "__preGet".equals( n ) ){
            Object foo = _simpleGet( "__preGet" );
            if ( foo != null && foo instanceof JSFunction ){
                Scope s = Scope.getLastCreated();
                if ( s != null ){
                    try {
                        s.setThis( this );
                        ((JSFunction)foo).call( s , n );
                    }
                    finally {
                        s.clearThisNormal( null );
                    }
                }
            }
        }

        if ( n instanceof String )
            return _simpleGet( (String)n );
        
        if ( n instanceof Number )
            return getInt( ((Number)n).intValue() );
        
        throw new RuntimeException( "object key can't be a [" + n.getClass() + "]" );
    }

    public Object _simpleGet( String s ){
        Object res = null;
        
        if ( _map != null )
            res = _map.get( s );
        
        if ( res == null && _map != null ){
            JSObject proto = (JSObject)_map.get( "prototype" );
            if ( proto != null )
                res = proto.get( s );
        };

        if ( res == null && _constructor != null )
            res = _constructor._prototype.get( s );
        
        if ( res == null && _objectLowFunctions != null 
             && ( _map == null || _map.get( "prototype" ) == null ) 
             && _constructor == null ){
            res = _objectLowFunctions.get( s );
        }

        if ( res == null && 
             ! ( "__notFoundHandler".equals( s ) 
                 || "__preGet".equals( s )
                 )
             ){

            Object blah = _simpleGet( "__notFoundHandler" );
            if ( blah instanceof JSFunction ){
                JSFunction f = (JSFunction)blah;
                Scope scope = f.getScope();
                if ( scope == null )
                    scope = Scope.getLastCreated();
                scope = scope.child();
                scope.setThis( this );
                if ( ! _inNotFoundHandler.get() ){
                    try {
                        _inNotFoundHandler.set( true );
                        return f.call( scope , s );
                    }
                    finally {
                        _inNotFoundHandler.set( false );
                    }
                }
            }
        }

        return res;
    }

    public Object removeField( Object n ){
        if ( n == null )
            return null;
        
        if ( n instanceof JSString )
            n = n.toString();
        
        Object val = null;

        if ( n instanceof String ){
            if ( _map != null )
                val = _map.remove( (String)n );
            if ( _keys != null )
                _keys.remove( n );
        }
        
        return val;
    }


    public Object setInt( int n , Object v ){
        _readOnlyCheck();
        prefunc();
        return set( String.valueOf( n ) , v );
    }

    public Object getInt( int n ){
        prefunc();
        return get( String.valueOf( n ) );
    }


    public boolean containsKey( String s ){
        prefunc();
        if ( _keys != null && _keys.contains( s ) )
            return true;
        
        if ( _constructor != null && _constructor._prototype.containsKey( s ) )
            return true;

        return false;
{'fraction_non_alphanumeric': 0.11421483046953965, 'fraction_numerical': 0.0, 'mean_word_length': 1.1253661394258934, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4311181', 'n_tokens_mistral': 2906, 'n_tokens_neox': 2778, 'n_words': 767}