public MethodClassRelations(ToWorkshop toWorkshop, DefinedMethodInstance method)
        {
            Method = method;

            if (method.DefinedInType is ClassType classType)
            {
                // Get the class relation.
                ClassRelation = toWorkshop.ClassInitializer.RelationFromClassType(classType);

                // Extract the virtual functions.
                Overriders = ClassRelation.ExtractOverridenElements <DefinedMethodInstance>(extender => DoesOverride(method, extender))
                             .ToArray();
            }
            else
            {
                Overriders = new DefinedMethodInstance[0];
            }
        }
示例#2
0
        public UserFunctionController(ToWorkshop toWorkshop, DefinedMethodInstance function, InstanceAnonymousTypeLinker typeArgs)
        {
            _toWorkshop    = toWorkshop;
            _function      = function;
            _typeArgLinker = typeArgs;
            _allVirtualOptions.Add(function);

            Attributes.IsRecursive = function.Attributes.Recursive;

            // If the function is defined in a type.
            if (function.DefinedInType != null)
            {
                Attributes.IsInstance = true;

                var relations = new MethodClassRelations(toWorkshop, function);

                // Get the class relation.
                _classRelation = relations.ClassRelation;

                // Extract the virtual functions.
                _allVirtualOptions.AddRange(relations.Overriders);
            }
        }