<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using hw.Debug;
using hw.Helper;
using Reni.Basics;
using Reni.Feature;
using Reni.ReniSyntax;
using Reni.TokenClasses;
using Reni.Type;

namespace Reni.Struct
{
    sealed class AccessFeature
        : DumpableObject
            , IFeatureImplementation
            , ISimpleFeature
    {
        static int _nextObjectId;

        internal AccessFeature(CompoundView compoundView, int position)
            : base(_nextObjectId++)
        {
            View = compoundView;
            Position = position;
            FunctionFeature = new ValueCache<IFunctionFeature>(ObtainFunctionFeature);
        }

        [EnableDump]
        public CompoundView View { get; }
        [EnableDump]
        public int Position { get; }

        ValueCache<IFunctionFeature> FunctionFeature { get; }

        IContextMetaFunctionFeature IFeatureImplementation.ContextMeta
            => (Statement as FunctionSyntax)?.ContextMetaFunctionFeature(View);

        IMetaFunctionFeature IFeatureImplementation.Meta => (Statement as FunctionSyntax)?.MetaFunctionFeature(View);

        IFunctionFeature IFeatureImplementation.Function => FunctionFeature.Value;

        ISimpleFeature IFeatureImplementation.Simple
        {
            get
            {
                var function = FunctionFeature.Value;
                if(function != null && function.IsImplicit)
                    return null;
                return this;
            }
        }

        Result ISimpleFeature.Result(Category category) => View
            .AccessViaContext(category, Position);

        TypeBase ISimpleFeature.TargetType => View.Type;

        CompileSyntax Statement => View
            .Compound
            .Syntax
            .Statements[Position];

        IFunctionFeature ObtainFunctionFeature()
        {
            var functionSyntax = Statement as FunctionSyntax;
            if(functionSyntax != null)
                return functionSyntax.FunctionFeature(View);

            return View.ValueType(Position).CheckedFeature?.Function;
        }
    }
}<commit_msg>Bug: use object pointer instead of context reference<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using hw.Debug;
using hw.Helper;
using Reni.Basics;
using Reni.Feature;
using Reni.ReniSyntax;
using Reni.TokenClasses;
using Reni.Type;

namespace Reni.Struct
{
    sealed class AccessFeature
        : DumpableObject
            , IFeatureImplementation
            , ISimpleFeature
    {
        static int _nextObjectId;

        internal AccessFeature(CompoundView compoundView, int position)
            : base(_nextObjectId++)
        {
            View = compoundView;
            Position = position;
            FunctionFeature = new ValueCache<IFunctionFeature>(ObtainFunctionFeature);
        }

        [EnableDump]
        public CompoundView View { get; }
        [EnableDump]
        public int Position { get; }

        ValueCache<IFunctionFeature> FunctionFeature { get; }

        IContextMetaFunctionFeature IFeatureImplementation.ContextMeta
            => (Statement as FunctionSyntax)?.ContextMetaFunctionFeature(View);

        IMetaFunctionFeature IFeatureImplementation.Meta => (Statement as FunctionSyntax)?.MetaFunctionFeature(View);

        IFunctionFeature IFeatureImplementation.Function => FunctionFeature.Value;

        ISimpleFeature IFeatureImplementation.Simple
        {
            get
            {
                var function = FunctionFeature.Value;
                if(function != null && function.IsImplicit)
                    return null;
                return this;
            }
        }

        Result ISimpleFeature.Result(Category category) => View
            .AccessViaObjectPointer(category, Position);

        TypeBase ISimpleFeature.TargetType => View.Type;

        CompileSyntax Statement => View
            .Compound
            .Syntax
            .Statements[Position];

        IFunctionFeature ObtainFunctionFeature()
        {
            var functionSyntax = Statement as FunctionSyntax;
            if(functionSyntax != null)
                return functionSyntax.FunctionFeature(View);

            return View.ValueType(Position).CheckedFeature?.Function;
        }
    }
}
{'fraction_non_alphanumeric': 0.07111419967570072, 'fraction_numerical': 0.0, 'mean_word_length': 2.2223880597014927, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '649279', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1012, 'n_words': 229}