Example #1
0
 internal EvaluationInfo PromoteLifetime(ComputationContext ctx, Lifetime lifetime)
 {
     return(EvaluationInfo.Create(this.Components.Rebuild(ctx, lifetime, deep: false), this.Aggregate.Build(lifetime)));
 }
Example #2
0
        protected override void compute(ComputationContext ctx)
        {
            IEntityInstance eval = EntityInstanceIntersection.Create(Elements.Select(it => it.Evaluation.Components));



            // we need to get sum (all) of the members

            bool has_reference                = false;
            bool has_pointer                  = false;
            var  dereferenced_instances       = new List <EntityInstance>();
            List <FunctionDefinition> members = new List <FunctionDefinition>();

            foreach (EntityInstance ____instance in this.Elements.Select(it => it.Evaluation.Aggregate))
            {
                if (ctx.Env.DereferencedOnce(____instance, out IEntityInstance __instance, out bool via_pointer))
                {
                    if (via_pointer)
                    {
                        has_pointer = true;
                    }
                    else
                    {
                        has_reference = true;
                    }
                }

                EntityInstance instance = __instance.Cast <EntityInstance>();

                dereferenced_instances.Add(instance);

                foreach (FunctionDefinition func in instance.TargetType.NestedFunctions)
                {
                    bool found = false;
                    foreach (FunctionDefinition m in members)
                    {
                        // todo: maybe some day handle optionals
                        if (func.IsAnyConstructor() || func.Parameters.Any(it => it.IsOptional))
                        {
                            continue;
                        }

                        if (FunctionDefinitionExtension.IsSame(ctx, m, func, instance))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        members.Add(func);
                    }
                }
            }

            EntityInstance aggregate_instance = createAggregate(ctx, has_reference, has_pointer,
                                                                dereferenced_instances, members, partialVirtualTables: true);

            this.Evaluation = EvaluationInfo.Create(eval, aggregate_instance);
        }