public override IFacet GetFacet(Type facetType) { var facet = base.GetFacet(facetType); if (FacetUtils.IsNotANoopFacet(facet)) { return(facet); } var noopFacet = facet; if (Superclass != null) { var superClassFacet = Superclass.GetFacet(facetType); if (FacetUtils.IsNotANoopFacet(superClassFacet)) { return(superClassFacet); } noopFacet ??= superClassFacet; } foreach (var interfaceSpec in Interfaces) { var interfaceFacet = interfaceSpec.GetFacet(facetType); if (FacetUtils.IsNotANoopFacet(interfaceFacet)) { return(interfaceFacet); } noopFacet ??= interfaceFacet; } return(noopFacet); }
public bool IsOfType(IObjectSpecImmutable specification) { if (specification == this) { return(true); } if (Interfaces.Any(interfaceSpec => interfaceSpec.IsOfType(specification))) { return(true); } // match covariant generic types if (Type.IsGenericType && IsCollection) { Type otherType = specification.Type; if (otherType.IsGenericType && Type.GetGenericArguments().Count() == 1 && otherType.GetGenericArguments().Count() == 1) { if (Type.GetGenericTypeDefinition() == (typeof(IQueryable <>)) && Type.GetGenericTypeDefinition() == otherType.GetGenericTypeDefinition()) { Type genericArgument = Type.GetGenericArguments().Single(); Type otherGenericArgument = otherType.GetGenericArguments().Single(); Type otherGenericParameter = otherType.GetGenericTypeDefinition().GetGenericArguments().Single(); if ((otherGenericParameter.GenericParameterAttributes & GenericParameterAttributes.Covariant) != 0) { if (otherGenericArgument.IsAssignableFrom(genericArgument)) { return(true); } } } } } return(Superclass != null && Superclass.IsOfType(specification)); }
private JsonTokenClass(string name, Superclass superclass) { Debug.Assert(name != null); Debug.Assert(name.Length > 0); _name = name; _superclass = superclass; }
JsonTokenClass(string name, Superclass superclass = Superclass.Unspecified) { Debug.Assert(name != null); Debug.Assert(name.Length > 0); Name = name; _superclass = superclass; }
public override string GetTuplizerImplClassName(EntityMode mode) { string impl = base.GetTuplizerImplClassName(mode); if (impl == null) { impl = Superclass.GetTuplizerImplClassName(mode); } return(impl); }
public IEnumerable <NavigationProperty> AllNavigationProperties(params Association[] ignore) { List <NavigationProperty> result = LocalNavigationProperties(ignore).ToList(); if (Superclass != null) { result.AddRange(Superclass.AllNavigationProperties(ignore)); } return(result); }
public LoxFunction FindMethod(string name) { if (_methods.ContainsKey(name)) { return(_methods[name]); } if (Superclass != null) { return(Superclass.FindMethod(name)); } return(null); }
public LoxFunction FindMethod(string name) { var hasMethod = Methods.TryGetValue(name, out var method); if (hasMethod) { return(method); } else if (Superclass is not null) { return(Superclass.FindMethod(name)); } return(null); }
public override IFacet GetFacet(Type facetType) { IFacet facet = base.GetFacet(facetType); if (FacetUtils.IsNotANoopFacet(facet)) { return(facet); } IFacet noopFacet = facet; if (Superclass != null) { IFacet superClassFacet = Superclass.GetFacet(facetType); if (FacetUtils.IsNotANoopFacet(superClassFacet)) { return(superClassFacet); } if (noopFacet == null) { noopFacet = superClassFacet; } } foreach (var interfaceSpec in Interfaces) { IFacet interfaceFacet = interfaceSpec.GetFacet(facetType); if (FacetUtils.IsNotANoopFacet(interfaceFacet)) { return(interfaceFacet); } if (noopFacet == null) { noopFacet = interfaceFacet; } } return(noopFacet); }
public override bool IsClassOrSuperclassTable(Table closureTable) { return(base.IsClassOrSuperclassTable(closureTable) || Superclass.IsClassOrSuperclassTable(closureTable)); }
public override bool IsClassOrSuperclassJoin(Join join) { return(base.IsClassOrSuperclassJoin(join) || Superclass.IsClassOrSuperclassJoin(join)); }
/// <summary> /// Adds a <see cref="Table"/> that a subclass is stored in. /// </summary> /// <param name="table">The <see cref="Table"/> the subclass is stored in.</param> /// <remarks> /// This also adds the <see cref="Table"/> to the Superclass' collection /// of SubclassType Tables. /// </remarks> public override void AddSubclassTable(Table table) { base.AddSubclassTable(table); Superclass.AddSubclassTable(table); }
public override void AddSubclassJoin(Join join) { base.AddSubclassJoin(join); Superclass.AddSubclassJoin(join); }
/// <summary> /// Adds a <see cref="Property"/> that is implemented by a subclass. /// </summary> /// <param name="p">The <see cref="Property"/> implemented by a subclass.</param> /// <remarks> /// This also adds the <see cref="Property"/> to the Superclass' collection /// of SubclassType Properties. /// </remarks> public override void AddSubclassProperty(Property p) { base.AddSubclassProperty(p); Superclass.AddSubclassProperty(p); }
internal override int NextSubclassId() { return(Superclass.NextSubclassId()); }
public LoxFunction FindMethod(string name) { return(Methods.ContainsKey(name) ? Methods[name] : Superclass?.FindMethod(name)); }
public static void Test() { const int invocationTestCount = 256; const int iterations = 10000; var switches = new Switch[invocationTestCount]; var virtuals = new Superclass[invocationTestCount]; Random random = new Random(5); for (int i = 0; i < invocationTestCount; ++i) { var executionType = (ExecutionType)random.Next(12); switches[i].Type = executionType; switch (executionType) { case ExecutionType.Increment: virtuals[i] = new Increment(); break; case ExecutionType.Decrement: virtuals[i] = new Decrement(); break; case ExecutionType.LShift: virtuals[i] = new LShift(); break; case ExecutionType.RShift: virtuals[i] = new RShift(); break; case ExecutionType.Scramble1: virtuals[i] = new Scramble1(); break; case ExecutionType.Scramble2: virtuals[i] = new Scramble2(); break; case ExecutionType.Increment2: virtuals[i] = new Increment2(); break; case ExecutionType.Decrement2: virtuals[i] = new Decrement2(); break; case ExecutionType.LShift2: virtuals[i] = new LShift2(); break; case ExecutionType.RShift2: virtuals[i] = new RShift2(); break; case ExecutionType.Scramble12: virtuals[i] = new Scramble12(); break; case ExecutionType.Scramble22: virtuals[i] = new Scramble22(); break; } } int switchValue = 0; int virtualValue = 0; //Warmup. for (int i = 0; i < invocationTestCount; ++i) { switches[i].Do(ref switchValue); virtuals[i].Do(ref virtualValue); } var switchStart = Stopwatch.GetTimestamp(); for (int i = 0; i < iterations; ++i) { for (int j = 0; j < invocationTestCount; ++j) { switches[j].Do(ref switchValue); switches[j].Do(ref switchValue); switches[j].Do(ref switchValue); switches[j].Do(ref switchValue); switches[j].Do(ref switchValue); switches[j].Do(ref switchValue); switches[j].Do(ref switchValue); switches[j].Do(ref switchValue); switches[j].Do(ref switchValue); switches[j].Do(ref switchValue); } } var virtualStart = Stopwatch.GetTimestamp(); for (int i = 0; i < iterations; ++i) { for (int j = 0; j < invocationTestCount; ++j) { virtuals[j].Do(ref virtualValue); virtuals[j].Do(ref virtualValue); virtuals[j].Do(ref virtualValue); virtuals[j].Do(ref virtualValue); virtuals[j].Do(ref virtualValue); virtuals[j].Do(ref virtualValue); virtuals[j].Do(ref virtualValue); virtuals[j].Do(ref virtualValue); virtuals[j].Do(ref virtualValue); virtuals[j].Do(ref virtualValue); } } var virtualEnd = Stopwatch.GetTimestamp(); Console.WriteLine($"Switch time (ns): {1e9 * (virtualStart - switchStart) / (Stopwatch.Frequency * invocationTestCount * iterations * 10)}"); Console.WriteLine($"Virtual time (ns): {1e9 * (virtualEnd - virtualStart) / (Stopwatch.Frequency * invocationTestCount * iterations * 10)}"); Console.WriteLine($"Switch accumulator: {switchValue}, virtual accumulator: {virtualValue}"); }
private JsonTokenClass(string name, Superclass superclass) { this._name = name; this._superclass = superclass; }
private string GetTypeName(TypeName container, Superclass super) => this.GetTypeName(container, super.id);