public static Material GetInstancedMaterial(uint groupID, StaticProperties staticProps) { MaterialsGroup group = (MaterialsGroup)ms_MaterialsGroup[groupID]; if (group == null) { group = new MaterialsGroup(); ms_MaterialsGroup[groupID] = group; } int matID = staticProps.materialID; Debug.Assert(matID < kStaticPropertiesCount); var mat = group.materials[matID]; if (mat == null) { mat = NewMaterialTransient(gpuInstanced: true); if (mat) { group.materials[matID] = mat; staticProps.ApplyToMaterial(mat); } } return(mat); }
public ISymbolValue Visit(UnaryExpression_Type x) { var uat = x as UnaryExpression_Type; if (uat.Type == null) { return(null); } var types = TypeDeclarationResolver.Resolve(uat.Type, ctxt); ctxt.CheckForSingleResult(types, uat.Type); if (types != null && types.Length != 0) { // First off, try to resolve static properties var statProp = StaticProperties.TryEvalPropertyValue(ValueProvider, types[0], uat.AccessIdentifierHash); if (statProp != null) { return(statProp); } //TODO } return(null); }
/// <summary> /// Adds the control tower fuel info. /// </summary> /// <param name="items">The items.</param> private void AddControlTowerFuelInfo(ICollection <ListViewItem> items) { if (SelectControl.SelectedObjects.All(x => !x.ControlTowerFuel.Any())) { return; } EveProperty prop = StaticProperties.GetPropertyByName(DBConstants.ConsumptionRatePropertyName); IList <SerializableControlTowerFuel> fuelMaterials = SelectControl.SelectedObjects.Where( x => x.ControlTowerFuel.Any()).SelectMany(x => x.ControlTowerFuel).ToList(); foreach (string purpose in fuelMaterials.Select(x => x.Purpose).Distinct()) { string groupName = $"Fuel Requirements - {purpose}"; ListViewGroup group = new ListViewGroup(groupName); foreach (Item item in StaticItems.AllItems.OrderBy(x => x.ID)) { if (fuelMaterials.Where(x => x.Purpose == purpose).All(x => x.ID != item.ID)) { continue; } IEnumerable <Material> materials = GetMaterials(fuelMaterials, item); AddListViewItem(prop, items, group, item, materials); } PropertiesList.Groups.Add(group); } }
public MigrationContainer(IPropertyContainer container) : this() { m_Container = container; // Initialize the `PropertyBag` with passthrough properties to the backing container foreach (var property in m_Container.PropertyBag.Properties) { m_PropertyBag.AddProperty(StaticProperties.CreateProperty(property)); } }
void GenUfcsAndStaticProperties(AbstractType t) { if (isVariableInstance && CompletionOptions.Instance.ShowUFCSItems) { foreach (var ufcsItem in UFCSResolver.TryResolveUFCS(t, 0, ed.CaretLocation, ctxt)) { CompletionDataGenerator.Add((ufcsItem as DSymbol).Definition); } } StaticProperties.ListProperties(CompletionDataGenerator, MemberFilter, t, isVariableInstance); }
void GenUfcsAndStaticProperties(AbstractType t) { if (t.NonStaticAccess && CompletionOptions.Instance.ShowUFCSItems) { CodeCompletion.DoTimeoutableCompletionTask(null, ctxt, () => { foreach (var ufcsItem in UFCSResolver.TryResolveUFCS(t, 0, ed.CaretLocation, ctxt)) { CompletionDataGenerator.Add((ufcsItem as DSymbol).Definition); } }); } StaticProperties.ListProperties(CompletionDataGenerator, ctxt, MemberFilter, t, t.NonStaticAccess); }
public void VisitTemplateParameterSymbol(TemplateParameterSymbol tps) { if (tps.Base != null) { tps.Base.Accept(this); } else { var tpp = tps.Parameter is TemplateThisParameter ? (tps.Parameter as TemplateThisParameter).FollowParameter : tps.Parameter; if (tpp is TemplateTupleParameter) { StaticProperties.ListProperties(CompletionDataGenerator, MemberFilter, tps, true); } } }
void BuildCompletionData(MemberSymbol mrr, IBlockNode currentlyScopedBlock, bool isVariableInstance = false) { if (mrr.Base != null) { BuildCompletionData(mrr.Base, currentlyScopedBlock, isVariableInstance || (mrr.Definition is DVariable && !(mrr is AliasedType) || // True if we obviously have a variable handled here. Otherwise depends on the samely-named parameter.. mrr.Definition is DMethod), mrr); } else { StaticProperties.ListProperties(CompletionDataGenerator, MemberFilter, mrr, false); } }
void IJsonSerializable.Serialize(JsonWriter writer) { // Serialize static property values if (StaticProperties.Count > 0) { writer.Set("static", StaticProperties.ToDictionary( property => property.Name, property => JsonConverter.GetPropertyValue(property, property.DeclaringType))); } // Serialize instances foreach (var instance in Instances) { writer.Set(instance.Key, instance.Value); } }
/// <summary> /// Adds the reprocessing skill. /// </summary> /// <param name="group">The listGroup.</param> /// <param name="items">The list of items.</param> private void AddReprocessingSkill(ListViewGroup group, ICollection <ListViewItem> items) { // Create the list of labels List <string> labels = new List <string>(); foreach (Item obj in SelectControl.SelectedObjects) { // Add a placeholder if no materials if (obj.ReprocessingMaterials == null) { labels.Add("None"); continue; } string skillName = obj.ReprocessingSkill?.Name ?? EveMonConstants.UnknownText; labels.Add(skillName); } // Create the list view item EveProperty property = StaticProperties.GetPropertyByID(DBConstants.ReprocessingSkillPropertyID); ListViewItem item = new ListViewItem(group); if (property != null) { item.ToolTipText = property.Description; item.Text = property.Name; StaticSkill skill = SelectControl.SelectedObjects.Select(obj => obj.ReprocessingSkill).FirstOrDefault(); if (skill != null && SelectControl.SelectedObjects.All(obj => obj.ReprocessingSkill == skill)) { item.Tag = Character?.Skills[skill.ID] ?? SkillCollection.Skills.FirstOrDefault(x => x.ID == skill.ID); } else { item.Tag = property.ID; } } items.Add(item); // Add the value for every selected item AddValueForSelectedObjects(null, item, labels, new Double[] { }); }
/// <summary> /// Loads the static data. /// </summary> public static async Task LoadAsync() { // Quit if the client has been shut down if (EveMonClient.Closed) { return; } // This is the time optimal loading order // (min order to follow : // skills before anything else, // properties before items, // items before blueprints, reprocessing and certificates, // certs before masteries) EveMonClient.Trace("Datafiles.Load - begin", printMethod: false); // Must always run first // It will have finished loading until static skills finish Task properties = TaskHelper.RunIOBoundTaskAsync(() => StaticProperties.Load()); // Must always run before items Task skills = TaskHelper.RunIOBoundTaskAsync(() => StaticSkills.Load()); await Task.WhenAll(skills, properties); // Must always run synchronously as blueprints, reprocessing and certificates depend on it await TaskHelper.RunIOBoundTaskAsync(() => StaticItems.Load()); // Must always run synchronously as masteries depend on it await TaskHelper.RunIOBoundTaskAsync(() => StaticCertificates.Load()); // Must always run synchronously as ID to name depends on it await TaskHelper.RunIOBoundTaskAsync(() => StaticGeography.Load()); // Non critical loadings as all dependencies have been loaded Task blueprints = TaskHelper.RunIOBoundTaskAsync(() => StaticBlueprints.Load()); Task reprocessing = TaskHelper.RunIOBoundTaskAsync(() => StaticReprocessing.Load()); await TaskHelper.RunIOBoundTaskAsync(() => StaticMasteries.Load()); EveMonClient.Trace("Datafiles.Load - done", printMethod: false); }
ISemantic E(UnaryExpression_Type x) { var uat = x as UnaryExpression_Type; if (uat.Type == null) { return(null); } var types = TypeDeclarationResolver.Resolve(uat.Type, ctxt); ctxt.CheckForSingleResult(types, uat.Type); if (types != null && types.Length != 0) { // First off, try to resolve static properties if (eval) { var statProp = StaticProperties.TryEvalPropertyValue(ValueProvider, types[0], uat.AccessIdentifierHash); if (statProp != null) { return(statProp); } } // If it's not the case, try the conservative way var res = TypeDeclarationResolver.Resolve(new IdentifierDeclaration(uat.AccessIdentifierHash) { EndLocation = uat.EndLocation }, ctxt, types); ctxt.CheckForSingleResult(res, x); if (res != null && res.Length != 0) { return(res[0]); } } return(null); }
public IEnumerable <PropertyContents> AllPropertiesWithName(string name) { PropertyContents prop = null; if (Properties.TryGetValue(name, out prop)) { yield return(prop); } if (PrivateProperties.TryGetValue(name, out prop)) { yield return(prop); } if (StaticProperties.TryGetValue(name, out prop)) { yield return(prop); } if (StaticPrivateProperties.TryGetValue(name, out prop)) { yield return(prop); } }
private void Other(TypeInfo ty, string var, VAL val) { string constKey = ToConstKey(var); string defaultKey = ToDefaultKey(var); Comment comment = new Comment(var) { Alignment = Alignment.Top }; //const key field Field field = new Field(new TypeInfo(typeof(string)), constKey, new Value(var)) { Modifier = Modifier.Public | Modifier.Const, }; ConstKeyFields.Add(field); //default value field Modifier modifier = Modifier.Public | Modifier.Const; string value = val.ToString(); if (val.IsList) { modifier = Modifier.Public | Modifier.Readonly | Modifier.Static; value = $"new {ty} " + value; } field = new Field(ty, defaultKey) { Modifier = modifier, UserValue = value, Comment = comment }; DefaultValueFields.Add(field); StaticFields.Add(createField(TOKEY(var), ty, var)); StaticProperties.Add(createProperty(toPascal(var), ty, var)); StaticMethods.Add(createMethod(toPascal(var), ty, var)); }
public void Write(Stream output) { BinaryWriter writer = new BinaryWriter(output, Encoding.Default, true); long headerPosition = output.Position; output.Position += HeaderSize; foreach (var staticProperty in StaticProperties) { staticProperty.Write(output); } uint staticDataSize = (uint)(output.Position - headerPosition); foreach (var dynamicProperty in DynamicProperties) { dynamicProperty.Write(output); } long endPosition = output.Position; uint dataSize = (uint)(endPosition - headerPosition); output.Position = headerPosition; writer.Write(HeaderSize); writer.Write(Unknown1); writer.WriteZeros(2); // padding1 writer.Write(MagicNumber); writer.Write(Address); writer.WriteZeros(4); // padding2 writer.Write(Unknown2); writer.WriteZeros(4); writer.Write(Version); writer.Write(ClassNameHash); writer.Write(Convert.ToUInt16(StaticProperties.Count())); writer.Write(Convert.ToUInt16(DynamicProperties.Count())); writer.Write((int)HeaderSize); writer.Write(staticDataSize); writer.Write(dataSize); output.AlignWrite(16, 0x00); //writer.WriteZeros(12); output.Position = endPosition; }
/// <summary> /// Initializes paths, static objects, check and load datafiles, etc. /// </summary> /// <remarks>May be called more than once without causing redundant operations to occur.</remarks> public static void Initialize() { lock (s_initializationLock) { if (s_initialized) { return; } s_initialized = true; Trace("EveClient.Initialize() - begin"); // Members instantiations HttpWebService = new HttpWebService(); APIProviders = new GlobalAPIProviderCollection(); MonitoredCharacters = new GlobalMonitoredCharacterCollection(); CharacterIdentities = new GlobalCharacterIdentityCollection(); Notifications = new GlobalNotificationCollection(); Characters = new GlobalCharacterCollection(); Datafiles = new GlobalDatafileCollection(); Accounts = new GlobalAccountCollection(); EVEServer = new EveServer(); // Load static datas (min order to follow : skills before anything else, items before certs) Trace("Load Datafiles - begin"); StaticProperties.Load(); StaticSkills.Load(); StaticItems.Load(); StaticCertificates.Load(); StaticBlueprints.Load(); Trace("Load Datafiles - done"); // Network monitoring (connection availability changes) NetworkMonitor.Initialize(); Trace("EveClient.Initialize() - done"); } }
public ISymbolValue Visit(UnaryExpression_Type x) { var uat = x as UnaryExpression_Type; if (uat.Type == null) { return(null); } var types = TypeDeclarationResolver.ResolveSingle(uat.Type, ctxt); // First off, try to resolve static properties var statProp = StaticProperties.TryEvalPropertyValue(ValueProvider, types, uat.AccessIdentifierHash); if (statProp != null) { return(statProp); } //TODO return(null); }
/// <summary> /// Adds the reaction info. /// </summary> /// <param name="items">The items.</param> private void AddReactionInfo(ICollection <ListViewItem> items) { if (SelectControl.SelectedObjects.All(x => !x.ReactionMaterial.Any())) { return; } EveProperty prop = StaticProperties.GetPropertyByID(DBConstants.ConsumptionQuantityPropertyID); IList <SerializableReactionInfo> reactionMaterials = SelectControl.SelectedObjects.Where( x => x.ReactionMaterial.Any()).SelectMany(x => x.ReactionMaterial).ToList(); // Add resources info ListViewGroup resourcesGroup = new ListViewGroup("Resources"); IList <SerializableReactionInfo> resources = reactionMaterials.Where(x => x.IsInput).ToList(); AddItemsAndSubItems(prop, items, resourcesGroup, resources); // Add products info ListViewGroup productsGroup = new ListViewGroup("Products"); IList <SerializableReactionInfo> products = reactionMaterials.Where(x => !x.IsInput).ToList(); AddItemsAndSubItems(prop, items, productsGroup, products); }
void BuildCompletionData(UserDefinedType tr, bool showInstanceItems) { MemberCompletionEnumeration.EnumChildren(CompletionDataGenerator, ctxt, tr, showInstanceItems, MemberFilter); StaticProperties.ListProperties(CompletionDataGenerator, MemberFilter, tr, showInstanceItems); }
bool HandleAliasThisDeclarations(TemplateIntermediateType tit, MemberFilter vis) { bool pop; var ch = tit.Definition [DVariable.AliasThisIdentifierHash]; if (ch != null) { foreach (DVariable aliasDef in ch) { if (MatchesCompilationConditions(aliasDef) || aliasDef.Type == null) { continue; } pop = ctxt.ScopedBlock != tit.Definition; if (pop) { ctxt.PushNewScope(tit.Definition); } // Resolve the aliased symbol and expect it to be a member symbol(?). //TODO: Check if other cases are allowed as well! var aliasedSymbol = DResolver.StripAliasSymbol(TypeDeclarationResolver.ResolveSingle(aliasDef.Type, ctxt)); var aliasedMember = aliasedSymbol as MemberSymbol; if (pop) { ctxt.Pop(); } if (aliasedMember == null) { if (aliasedSymbol != null) { ctxt.LogError(aliasDef, "Aliased type from 'alias this' definition is expected to be a type instance, not " + aliasedSymbol.ToString() + "!"); } continue; } /* * The aliased member's type can be everything! */ aliasedSymbol = aliasedMember.Base; foreach (var statProp in StaticProperties.ListProperties(aliasedSymbol)) { if (HandleItem(statProp)) { return(true); } } /** TODO: Visit ufcs recommendations and other things that * become added in e.g. MemberCompletionProvider */ var tit_ = aliasedSymbol as TemplateIntermediateType; if (tit_ != null) { pop = !ctxt.ScopedBlockIsInNodeHierarchy(tit_.Definition); if (pop) { ctxt.PushNewScope(tit_.Definition); } ctxt.CurrentContext.IntroduceTemplateParameterTypes(tit_); var r = DeepScanClass(tit_, vis, true); if (pop) { ctxt.Pop(); } else { ctxt.CurrentContext.RemoveParamTypesFromPreferredLocals(tit_); } if (r) { return(true); } } } } return(false); }
public override void Read(AssetReader reader) { if (IsSerialized(reader.Version)) { ReadNamedObject(reader); ParsedForm.Read(reader); Platforms = reader.ReadArray((t) => (GPUPlatform)t); if (IsDoubleArray(reader.Version)) { uint[][] offsets = reader.ReadUInt32ArrayArray(); uint[][] compressedLengths = reader.ReadUInt32ArrayArray(); uint[][] decompressedLengths = reader.ReadUInt32ArrayArray(); byte[] compressedBlob = reader.ReadByteArray(); reader.AlignStream(); UnpackSubProgramBlobs(reader.Layout, offsets, compressedLengths, decompressedLengths, compressedBlob); } else { uint[] offsets = reader.ReadUInt32Array(); uint[] compressedLengths = reader.ReadUInt32Array(); uint[] decompressedLengths = reader.ReadUInt32Array(); byte[] compressedBlob = reader.ReadByteArray(); reader.AlignStream(); UnpackSubProgramBlobs(reader.Layout, offsets, compressedLengths, decompressedLengths, compressedBlob); } } else { base.Read(reader); if (HasBlob(reader.Version)) { uint decompressedSize = reader.ReadUInt32(); byte[] compressedBlob = reader.ReadByteArray(); reader.AlignStream(); UnpackSubProgramBlobs(reader.Layout, 0, (uint)compressedBlob.Length, decompressedSize, compressedBlob); } if (HasFallback(reader.Version)) { Fallback.Read(reader); } if (HasDefaultProperties(reader.Version)) { DefaultProperties.Read(reader); } if (HasStaticProperties(reader.Version)) { StaticProperties.Read(reader); } } if (HasDependencies(reader.Version)) { Dependencies = reader.ReadAssetArray <PPtr <Shader> >(); } if (HasNonModifiableTextures(reader.Version)) { NonModifiableTextures = new Dictionary <string, PPtr <Texture> >(); NonModifiableTextures.Read(reader); } if (HasShaderIsBaked(reader.Version)) { ShaderIsBaked = reader.ReadBoolean(); reader.AlignStream(); } #if UNIVERSAL if (HasErrors(reader.Version, reader.Flags)) { Errors = reader.ReadAssetArray <ShaderError>(); } if (HasDefaultTextures(reader.Version, reader.Flags)) { DefaultTextures = new Dictionary <string, PPtr <Texture> >(); DefaultTextures.Read(reader); } if (HasCompileInfo(reader.Version, reader.Flags)) { CompileInfo.Read(reader); } #endif }
/// <summary> /// Returns either all unfiltered and undeduced overloads of a member of a base type/value (like b from type a if the expression is a.b). /// if <param name="EvalAndFilterOverloads"></param> is false. /// If true, all overloads will be deduced, filtered and evaluated, so that (in most cases,) a one-item large array gets returned /// which stores the return value of the property function b that is executed without arguments. /// Also handles UFCS - so if filtering is wanted, the function becom /// </summary> ISemantic[] E(PostfixExpression_Access acc, ISemantic resultBase = null, bool EvalAndFilterOverloads = true, bool ResolveImmediateBaseType = true) { if (acc == null) { return(null); } var baseExpression = resultBase ?? E(acc.PostfixForeExpression); if (acc.AccessExpression is NewExpression) { /* * This can be both a normal new-Expression as well as an anonymous class declaration! */ //TODO! return(null); } AbstractType[] overloads; var optBackup = ctxt.CurrentContext.ContextDependentOptions; if (acc.AccessExpression is TemplateInstanceExpression) { if (!ResolveImmediateBaseType) { ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.DontResolveBaseTypes; } var tix = (TemplateInstanceExpression)acc.AccessExpression; // Do not deduce and filter if superior expression is a method call since call arguments' types also count as template arguments! overloads = GetOverloads(tix, new[] { AbstractType.Get(baseExpression) }, EvalAndFilterOverloads); if (!ResolveImmediateBaseType) { ctxt.CurrentContext.ContextDependentOptions = optBackup; } } else if (acc.AccessExpression is IdentifierExpression) { var id = acc.AccessExpression as IdentifierExpression; if (eval && EvalAndFilterOverloads && resultBase != null) { var staticPropResult = StaticProperties.TryEvalPropertyValue(ValueProvider, resultBase, id.ValueStringHash); if (staticPropResult != null) { return new[] { staticPropResult } } ; } if (!ResolveImmediateBaseType) { ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.DontResolveBaseTypes; } overloads = TypeDeclarationResolver.ResolveFurtherTypeIdentifier(id.ValueStringHash, new[] { AbstractType.Get(baseExpression) }, ctxt, acc.AccessExpression); if (!ResolveImmediateBaseType) { ctxt.CurrentContext.ContextDependentOptions = optBackup; } } else { if (eval) { EvalError(acc, "Invalid access expression"); return(null); } ctxt.LogError(acc, "Invalid post-dot expression"); return(null); } /* * Try to get ufcs functions at first! * * void foo(int i) {} * * class A * { * void foo(int i, int a) {} * * void bar(){ * 123.foo(23); // Not allowed! * // Anyway, if we tried to search ufcs functions AFTER searching from child to parent scope levels, * // it would return the local foo() only, not the global one..which would be an error then! * } * * Probably also worth to notice is the property syntax..are property functions rather preferred than ufcs ones? * } */ if (overloads == null || EvalAndFilterOverloads) { var oo = UFCSResolver.TryResolveUFCS(baseExpression, acc, ctxt) as AbstractType[]; if (oo != null) { int overloadsLength = overloads == null ? 0 : overloads.Length; var newArr = new AbstractType[overloadsLength + oo.Length]; if (overloadsLength != 0) { overloads.CopyTo(newArr, 0); } oo.CopyTo(newArr, overloadsLength); overloads = newArr; } } // If evaluation active and the access expression is stand-alone, return a single item only. if (EvalAndFilterOverloads && eval) { return new[] { TryDoCTFEOrGetValueRefs(overloads, acc.AccessExpression) } } ; return(overloads); } ISemantic E(PostfixExpression_Index x, ISemantic foreExpression) { if (eval) { //TODO: Access pointer arrays(?) if (foreExpression is ArrayValue) // ArrayValue must be checked first due to inheritance! { var av = foreExpression as ArrayValue; // Make $ operand available var arrLen_Backup = ValueProvider.CurrentArrayLength; ValueProvider.CurrentArrayLength = av.Elements.Length; var n = E(x.Arguments[0]) as PrimitiveValue; ValueProvider.CurrentArrayLength = arrLen_Backup; if (n == null) { EvalError(x.Arguments[0], "Returned no value"); return(null); } int i = 0; try{ i = Convert.ToInt32(n.Value); } catch { EvalError(x.Arguments[0], "Index expression must be of type int"); return(null); } if (i < 0 || i > av.Elements.Length) { EvalError(x.Arguments[0], "Index out of range - it must be between 0 and " + av.Elements.Length); return(null); } return(av.Elements[i]); } else if (foreExpression is AssociativeArrayValue) { var aa = (AssociativeArrayValue)foreExpression; var key = E(x.Arguments[0]); if (key == null) { EvalError(x.Arguments[0], "Returned no value"); return(null); } ISymbolValue val = null; foreach (var kv in aa.Elements) { if (kv.Key.Equals(key)) { return(kv.Value); } } EvalError(x, "Could not find key '" + val + "'"); return(null); } EvalError(x.PostfixForeExpression, "Invalid index expression base value type", foreExpression); return(null); } else { foreExpression = DResolver.StripMemberSymbols(AbstractType.Get(foreExpression)); if (foreExpression is AssocArrayType) { var ar = foreExpression as AssocArrayType; /* * myType_Array[0] -- returns TypeResult myType * return the value type of a given array result */ //TODO: Handle opIndex overloads return(new ArrayAccessSymbol(x, ar.ValueType)); } /* * int* a = new int[10]; * * a[0] = 12; */ else if (foreExpression is PointerType) { return((foreExpression as PointerType).Base); } //return new ArrayAccessSymbol(x,((PointerType)foreExpression).Base); else if (foreExpression is DTuple) { var tt = foreExpression as DTuple; if (x.Arguments != null && x.Arguments.Length != 0) { var idx = EvaluateValue(x.Arguments[0], ctxt) as PrimitiveValue; if (idx == null || !DTokens.BasicTypes_Integral[idx.BaseTypeToken]) { ctxt.LogError(x.Arguments[0], "Index expression must evaluate to integer value"); } else if (idx.Value > (decimal)Int32.MaxValue || (int)idx.Value >= tt.Items.Length || (int)idx.Value < 0) { ctxt.LogError(x.Arguments[0], "Index number must be a value between 0 and " + tt.Items.Length); } else { return(tt.Items[(int)idx.Value]); } } } ctxt.LogError(new ResolutionError(x, "Invalid base type for index expression")); } return(null); } ISemantic E(PostfixExpression_Slice x, ISemantic foreExpression) { if (!eval) { return(foreExpression); // Still of the array's type. } if (!(foreExpression is ArrayValue)) { EvalError(x.PostfixForeExpression, "Must be an array"); return(null); } var ar = (ArrayValue)foreExpression; var sl = (PostfixExpression_Slice)x; // If the [ ] form is used, the slice is of the entire array. if (sl.FromExpression == null && sl.ToExpression == null) { return(foreExpression); } // Make $ operand available var arrLen_Backup = ValueProvider.CurrentArrayLength; ValueProvider.CurrentArrayLength = ar.Elements.Length; var bound_lower = E(sl.FromExpression) as PrimitiveValue; var bound_upper = E(sl.ToExpression) as PrimitiveValue; ValueProvider.CurrentArrayLength = arrLen_Backup; if (bound_lower == null || bound_upper == null) { EvalError(bound_lower == null ? sl.FromExpression : sl.ToExpression, "Must be of an integral type"); return(null); } int lower = -1, upper = -1; try { lower = Convert.ToInt32(bound_lower.Value); upper = Convert.ToInt32(bound_upper.Value); } catch { EvalError(lower != -1 ? sl.FromExpression : sl.ToExpression, "Boundary expression must base an integral type"); return(null); } if (lower < 0) { EvalError(sl.FromExpression, "Lower boundary must be greater than 0"); return(null); } if (lower >= ar.Elements.Length) { EvalError(sl.FromExpression, "Lower boundary must be smaller than " + ar.Elements.Length); return(null); } if (upper < lower) { EvalError(sl.ToExpression, "Upper boundary must be greater than " + lower); return(null); } if (upper >= ar.Elements.Length) { EvalError(sl.ToExpression, "Upper boundary must be smaller than " + ar.Elements.Length); return(null); } var rawArraySlice = new ISymbolValue[upper - lower]; int j = 0; for (int i = lower; i < upper; i++) { rawArraySlice[j++] = ar.Elements[i]; } return(new ArrayValue(ar.RepresentedType as ArrayType, rawArraySlice)); } ISemantic E(PostfixExpression_Increment x, ISemantic foreExpression) { // myInt++ is still of type 'int' if (!eval) { return(foreExpression); } if (resolveConstOnly) { EvalError(new NoConstException(x)); } // Must be implemented anyway regarding ctfe return(null); } ISemantic E(PostfixExpression_Decrement x, ISemantic foreExpression) { if (!eval) { return(foreExpression); } if (resolveConstOnly) { EvalError(new NoConstException(x)); } // Must be implemented anyway regarding ctfe return(null); } } }
/// <summary> /// Used for searching further identifier list parts. /// /// a.b -- nextIdentifier would be 'b' whereas <param name="resultBases">resultBases</param> contained the resolution result for 'a' /// </summary> public static AbstractType[] ResolveFurtherTypeIdentifier(int nextIdentifierHash, IEnumerable <AbstractType> resultBases, ResolutionContext ctxt, ISyntaxRegion typeIdObject = null) { MemberSymbol statProp; if ((resultBases = DResolver.StripMemberSymbols(resultBases)) == null) { return(null); } var r = new List <AbstractType>(); foreach (var b in resultBases) { if (b is UserDefinedType) { var udt = b as UserDefinedType; var bn = udt.Definition as IBlockNode; bool pop = b is MixinTemplateType; if (pop) { ctxt.PushNewScope(bn); } ctxt.CurrentContext.IntroduceTemplateParameterTypes(udt); r.AddRange(SingleNodeNameScan.SearchChildrenAndResolve(ctxt, udt, nextIdentifierHash, typeIdObject)); List <TemplateParameterSymbol> dedTypes = null; foreach (var t in r) { var ds = t as DSymbol; if (ds != null && ds.DeducedTypes == null) { if (dedTypes == null) { dedTypes = ctxt.DeducedTypesInHierarchy; } ds.DeducedTypes = new System.Collections.ObjectModel.ReadOnlyCollection <TemplateParameterSymbol>(dedTypes); } } statProp = StaticProperties.TryEvalPropertyType(ctxt, b, nextIdentifierHash); if (statProp != null) { r.Add(statProp); } // go the opDispatch way if possible - http://dlang.org/operatoroverloading.html#Dispatch if (r.Count == 0 && nextIdentifierHash != OpDispatchResolution.opDispatchId) { r.AddRange(OpDispatchResolution.TryResolveFurtherIdViaOpDispatch(ctxt, nextIdentifierHash, udt)); } if (r.Count == 0) { r.AddRange(UFCSResolver.TryResolveUFCS(b, nextIdentifierHash, !pop && typeIdObject != null ? typeIdObject.Location : ctxt.ScopedBlock.BlockStartLocation, ctxt, typeIdObject)); } if (pop) { ctxt.Pop(); } else { ctxt.CurrentContext.RemoveParamTypesFromPreferredLocals(udt); } } else if (b is PackageSymbol) { var pack = (b as PackageSymbol).Package; var accessedModule = pack.GetModule(nextIdentifierHash); if (accessedModule != null) { r.Add(new ModuleSymbol(accessedModule as DModule, typeIdObject as ISyntaxRegion, b as PackageSymbol)); } else if ((pack = pack.GetPackage(nextIdentifierHash)) != null) { r.Add(new PackageSymbol(pack, typeIdObject as ISyntaxRegion)); } } else if (b is ModuleSymbol) { r.AddRange(SingleNodeNameScan.SearchChildrenAndResolve(ctxt, b as ModuleSymbol, nextIdentifierHash, typeIdObject)); } else { statProp = StaticProperties.TryEvalPropertyType(ctxt, b, nextIdentifierHash); if (statProp != null) { r.Add(statProp); } if (r.Count == 0) // Only if there hasn't been a result yet? { r.AddRange(UFCSResolver.TryResolveUFCS(b, nextIdentifierHash, typeIdObject != null ? typeIdObject.Location : ctxt.ScopedBlock.BlockStartLocation, ctxt, typeIdObject)); } } } return(r.Count == 0 ? null : r.ToArray()); }
public void Add(TLDefinition tld, Stream srcStm) { TLFunction tlf = tld as TLFunction; if (tlf != null) { if (IsConstructor(tlf.Signature, tlf.Class)) { Constructors.Add(tlf, srcStm); } else if (tlf.Signature is SwiftClassConstructorType) { if (ClassConstructor.Values.Count() == 0) { ClassConstructor.Add(tlf, srcStm); } else { throw ErrorHelper.CreateError(ReflectorError.kInventoryBase + 12, $"multiple type metadata accessors for {tlf.Class.ClassName.ToFullyQualifiedName ()}"); } } else if (IsDestructor(tlf.Signature, tlf.Class)) { Destructors.Add(tlf, srcStm); } else if (IsProperty(tlf.Signature, tlf.Class)) { if (IsSubscript(tlf.Signature, tlf.Class)) { if (IsPrivateProperty(tlf.Signature, tlf.Class)) { PrivateSubscripts.Add(tlf); } else { Subscripts.Add(tlf); } } else { if (IsStaticProperty(tlf.Signature, tlf.Class)) { if (IsPrivateProperty(tlf.Signature, tlf.Class)) { StaticPrivateProperties.Add(tlf, srcStm); } else { StaticProperties.Add(tlf, srcStm); } } else { if (IsPrivateProperty(tlf.Signature, tlf.Class)) { PrivateProperties.Add(tlf, srcStm); } else { Properties.Add(tlf, srcStm); } } } } else if (IsMethodOnClass(tlf.Signature, tlf.Class)) { if (tlf is TLMethodDescriptor) { MethodDescriptors.Add(tlf, srcStm); } else { Methods.Add(tlf, srcStm); } } else if (IsStaticMethod(tlf.Signature, tlf.Class)) { StaticFunctions.Add(tlf, srcStm); } else if (IsWitnessTable(tlf.Signature, tlf.Class)) { WitnessTable.Add(tlf, srcStm); } else if (IsInitializer(tlf.Signature, tlf.Class)) { Initializers.Add(tlf, srcStm); } else { FunctionsOfUnknownDestination.Add(tlf); } return; } var meta = tld as TLDirectMetadata; if (meta != null) { if (DirectMetadata != null) { throw ErrorHelper.CreateError(ReflectorError.kInventoryBase + 13, $"duplicate direct metadata in class {DirectMetadata.Class.ClassName.ToFullyQualifiedName ()}"); } DirectMetadata = meta; return; } var lazy = tld as TLLazyCacheVariable; if (lazy != null) { if (LazyCacheVariable != null) { throw ErrorHelper.CreateError(ReflectorError.kInventoryBase + 14, $"duplicate lazy cache variable in class {LazyCacheVariable.Class.ClassName.ToFullyQualifiedName ()}"); } LazyCacheVariable = lazy; return; } var mc = tld as TLMetaclass; if (mc != null) { if (Metaclass != null) { throw ErrorHelper.CreateError(ReflectorError.kInventoryBase + 15, $"duplicate type meta data descriptor in class {Metaclass.Class.ClassName.ToFullyQualifiedName ()}"); } Metaclass = mc; return; } var nom = tld as TLNominalTypeDescriptor; if (nom != null) { if (TypeDescriptor != null) { throw ErrorHelper.CreateError(ReflectorError.kInventoryBase + 16, $"duplicate nominal type descriptor in class {TypeDescriptor.Class.ClassName.ToFullyQualifiedName ()}"); } TypeDescriptor = nom; return; } var tlvar = tld as TLVariable; if (tlvar != null) { if (tlvar is TLPropertyDescriptor tlpropDesc) { PropertyDescriptors.Add(tlpropDesc); } else { Variables.Add(tlvar, srcStm); } return; } var tlprot = tld as TLProtocolConformanceDescriptor; if (tlprot != null) { ProtocolConformanceDescriptors.Add(tlprot); return; } DefinitionsOfUnknownDestination.Add(tld); }
private static void ExecuteOpenPropertiesCommand(object parameter) { ResourceDescription rd = cnClient.GetStaticDataForElement((long)parameter); PropertiesControl propertiesControl = new PropertiesControl(); List <DigitalMeasurement> digitalMeasurements = new List <DigitalMeasurement>(); List <AnalogMeasurement> analogMeasurements = new List <AnalogMeasurement>(); PropertiesModelView propertiesModelView = new PropertiesModelView(); if (rd != null) { StaticProperties staticProperties = new StaticProperties(); staticProperties.ReadFromResourceDescription(rd); GeneralStaticPropertiesControl generalStaticPropertiesControl = new GeneralStaticPropertiesControl() { DataContext = staticProperties }; propertiesControl.StaticProperties.Content = generalStaticPropertiesControl; if (rd.ContainsProperty(ModelCode.PSR_MEASUREMENTS)) { List <long> measurementGids = rd.GetProperty(ModelCode.PSR_MEASUREMENTS).AsLongs(); foreach (long meas in measurementGids) { rd = cnClient.GetStaticDataForElement(meas); short type = ModelCodeHelper.ExtractTypeFromGlobalId(meas); PropertiesModelView.Measurements.Clear(); if (type == (short)DMSType.DISCRETE) { DigitalMeasurement digitalMeasurement = new DigitalMeasurement(); digitalMeasurement.ReadFromResourceDescription(rd); csClient.GetDiscreteMeasurement(rd.GetProperty(ModelCode.IDOBJ_MRID).AsString(), out OMSSCADACommon.States state); digitalMeasurement.State = state; digitalMeasurements.Add(digitalMeasurement); PropertiesModelView.Measurements.Add(digitalMeasurement.MRID, digitalMeasurement); } else if (type == (short)DMSType.ANALOG) { AnalogMeasurement analogMeasurement = new AnalogMeasurement(); analogMeasurement.ReadFromResourceDescription(rd); csClient.GetAnalogMeasurement(rd.GetProperty(ModelCode.IDOBJ_MRID).AsString(), out float value); analogMeasurement.Value = value; analogMeasurements.Add(analogMeasurement); PropertiesModelView.Measurements.Add(analogMeasurement.MRID, analogMeasurement); } } } } if (digitalMeasurements.Count == 0 && analogMeasurements.Count == 0) { propertiesModelView.MeasurementVisibility = Visibility.Collapsed; } else { propertiesModelView.MeasurementVisibility = Visibility.Visible; propertiesControl.Measurements.Content = new MeasurementsControl() { DataContext = propertiesModelView }; if (digitalMeasurements.Count > 0) { foreach (DigitalMeasurement measurement in digitalMeasurements) { DiscreteMeasurementControl discreteMeasurementControl = new DiscreteMeasurementControl() { DataContext = measurement }; propertiesModelView.DigitalControls.Add(discreteMeasurementControl); } propertiesModelView.DigitalMeasurementVisibility = Visibility.Visible; } else { propertiesModelView.DigitalMeasurementVisibility = Visibility.Collapsed; } if (analogMeasurements.Count > 0) { foreach (AnalogMeasurement measurement in analogMeasurements) { AnalogMeasurementControl analogMeasurementControl = new AnalogMeasurementControl() { DataContext = measurement }; propertiesModelView.AnalogControls.Add(analogMeasurementControl); } propertiesModelView.AnalogMeasurementVisibility = Visibility.Visible; } else { propertiesModelView.AnalogMeasurementVisibility = Visibility.Collapsed; } } ShellFillerShell sfs = new ShellFillerShell() /*DataContext = this*/ }
public override void Read(AssetReader reader) { if (IsSerialized(reader.Version)) { ReadNamedObject(reader); ParsedForm.Read(reader); Platforms = reader.ReadArray((t) => (GPUPlatform)t); uint[] offsets = reader.ReadUInt32Array(); uint[] compressedLengths = reader.ReadUInt32Array(); uint[] decompressedLengths = reader.ReadUInt32Array(); byte[] compressedBlob = reader.ReadByteArray(); reader.AlignStream(); SubProgramBlobs = new ShaderSubProgramBlob[Platforms.Length]; using (MemoryStream memStream = new MemoryStream(compressedBlob)) { for (int i = 0; i < Platforms.Length; i++) { uint offset = offsets[i]; uint compressedLength = compressedLengths[i]; uint decompressedLength = decompressedLengths[i]; memStream.Position = offset; byte[] decompressedBuffer = new byte[decompressedLength]; using (Lz4DecodeStream lz4Stream = new Lz4DecodeStream(memStream, (int)compressedLength)) { lz4Stream.ReadBuffer(decompressedBuffer, 0, decompressedBuffer.Length); } using (MemoryStream blobMem = new MemoryStream(decompressedBuffer)) { using (AssetReader blobReader = new AssetReader(blobMem, EndianType.LittleEndian, reader.Version, reader.Platform, reader.Flags)) { ShaderSubProgramBlob blob = new ShaderSubProgramBlob(); blob.Read(blobReader); SubProgramBlobs[i] = blob; } } } } } else { base.Read(reader); if (IsEncoded(reader.Version)) { uint decompressedSize = reader.ReadUInt32(); int comressedSize = reader.ReadInt32(); if (comressedSize > 0 && decompressedSize > 0) { byte[] subProgramBlob = new byte[comressedSize]; reader.ReadBuffer(subProgramBlob, 0, comressedSize); byte[] decompressedBuffer = new byte[decompressedSize]; using (MemoryStream memStream = new MemoryStream(subProgramBlob)) { using (Lz4DecodeStream lz4Stream = new Lz4DecodeStream(memStream)) { lz4Stream.ReadBuffer(decompressedBuffer, 0, decompressedBuffer.Length); } } using (MemoryStream memStream = new MemoryStream(decompressedBuffer)) { using (AssetReader blobReader = new AssetReader(memStream, EndianType.LittleEndian, reader.Version, reader.Platform, reader.Flags)) { SubProgramBlob.Read(blobReader); } } } reader.AlignStream(); } if (HasFallback(reader.Version)) { Fallback.Read(reader); } if (HasDefaultProperties(reader.Version)) { DefaultProperties.Read(reader); } if (HasStaticProperties(reader.Version)) { StaticProperties.Read(reader); } } if (HasDependencies(reader.Version)) { Dependencies = reader.ReadAssetArray <PPtr <Shader> >(); } if (HasNonModifiableTextures(reader.Version)) { NonModifiableTextures = new Dictionary <string, PPtr <Texture> >(); NonModifiableTextures.Read(reader); } if (HasShaderIsBaked(reader.Version)) { ShaderIsBaked = reader.ReadBoolean(); reader.AlignStream(); } #if UNIVERSAL if (HasErrors(reader.Version, reader.Flags)) { Errors = reader.ReadAssetArray <ShaderError>(); } if (HasDefaultTextures(reader.Version, reader.Flags)) { DefaultTextures = new Dictionary <string, PPtr <Texture> >(); DefaultTextures.Read(reader); } if (HasCompileInfo(reader.Version, reader.Flags)) { CompileInfo.Read(reader); } #endif }
/// <summary> /// Returns either all unfiltered and undeduced overloads of a member of a base type/value (like b from type a if the expression is a.b). /// if <param name="EvalAndFilterOverloads"></param> is false. /// If true, all overloads will be deduced, filtered and evaluated, so that (in most cases,) a one-item large array gets returned /// which stores the return value of the property function b that is executed without arguments. /// Also handles UFCS - so if filtering is wanted, the function becom /// </summary> public static R[] EvalPostfixAccessExpression <R>(ExpressionVisitor <R> vis, ResolutionContext ctxt, PostfixExpression_Access acc, ISemantic resultBase = null, bool EvalAndFilterOverloads = true, bool ResolveImmediateBaseType = true, AbstractSymbolValueProvider ValueProvider = null) where R : class, ISemantic { if (acc == null) { return(null); } var baseExpression = resultBase ?? (acc.PostfixForeExpression != null ? acc.PostfixForeExpression.Accept(vis) as ISemantic : null); if (acc.AccessExpression is NewExpression) { /* * This can be both a normal new-Expression as well as an anonymous class declaration! */ //TODO! return(null); } AbstractType[] overloads; var optBackup = ctxt.CurrentContext.ContextDependentOptions; if (acc.AccessExpression is TemplateInstanceExpression) { if (!ResolveImmediateBaseType) { ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.DontResolveBaseTypes; } var tix = (TemplateInstanceExpression)acc.AccessExpression; // Do not deduce and filter if superior expression is a method call since call arguments' types also count as template arguments! overloads = ExpressionTypeEvaluation.GetOverloads(tix, ctxt, new[] { AbstractType.Get(baseExpression) }, EvalAndFilterOverloads); if (!ResolveImmediateBaseType) { ctxt.CurrentContext.ContextDependentOptions = optBackup; } } else if (acc.AccessExpression is IdentifierExpression) { var id = acc.AccessExpression as IdentifierExpression; if (ValueProvider != null && EvalAndFilterOverloads && baseExpression != null) { var staticPropResult = StaticProperties.TryEvalPropertyValue(ValueProvider, baseExpression, id.ValueStringHash); if (staticPropResult != null) { return new[] { (R)staticPropResult } } ; } if (!ResolveImmediateBaseType) { ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.DontResolveBaseTypes; } overloads = ExpressionTypeEvaluation.GetOverloads(id, ctxt, AmbiguousType.TryDissolve(AbstractType.Get(baseExpression)), EvalAndFilterOverloads); if (!ResolveImmediateBaseType) { ctxt.CurrentContext.ContextDependentOptions = optBackup; } } else { /* * if (eval){ * EvalError(acc, "Invalid access expression"); * return null; * }*/ ctxt.LogError(acc, "Invalid post-dot expression"); return(null); } // If evaluation active and the access expression is stand-alone, return a single item only. if (EvalAndFilterOverloads && ValueProvider != null) { return new[] { (R) new Evaluation(ValueProvider).TryDoCTFEOrGetValueRefs(AmbiguousType.Get(overloads, acc.AccessExpression), acc.AccessExpression) } } ; return(overloads as R[]); } ISymbolValue EvalForeExpression(PostfixExpression ex) { return(ex.PostfixForeExpression != null?ex.PostfixForeExpression.Accept(this) : null); }
/// <summary> /// Used for searching further identifier list parts. /// /// a.b -- nextIdentifier would be 'b' whereas <param name="resultBases">resultBases</param> contained the resolution result for 'a' /// </summary> public static AbstractType[] ResolveFurtherTypeIdentifier(int nextIdentifierHash, IEnumerable <AbstractType> resultBases, ResolutionContext ctxt, object typeIdObject = null) { MemberSymbol statProp; if ((resultBases = DResolver.StripMemberSymbols(resultBases)) == null) { return(null); } var r = new List <AbstractType>(); foreach (var b in resultBases) { if (b is UserDefinedType) { var udt = b as UserDefinedType; var bn = udt.Definition as IBlockNode; bool pop = !(b is MixinTemplateType); if (!pop) { ctxt.PushNewScope(bn); } ctxt.CurrentContext.IntroduceTemplateParameterTypes(udt); r.AddRange(SingleNodeNameScan.SearchChildrenAndResolve(ctxt, bn, nextIdentifierHash, typeIdObject)); List <TemplateParameterSymbol> dedTypes = null; foreach (var t in r) { var ds = t as DSymbol; if (ds != null && ds.DeducedTypes == null) { if (dedTypes == null) { dedTypes = ctxt.DeducedTypesInHierarchy; } ds.DeducedTypes = new System.Collections.ObjectModel.ReadOnlyCollection <TemplateParameterSymbol>(dedTypes); } } statProp = StaticProperties.TryEvalPropertyType(ctxt, b, nextIdentifierHash); if (statProp != null) { r.Add(statProp); } ctxt.CurrentContext.RemoveParamTypesFromPreferredLocals(udt); if (!pop) { ctxt.Pop(); } } else if (b is PackageSymbol) { var pack = (b as PackageSymbol).Package; var accessedModule = pack.GetModule(nextIdentifierHash); if (accessedModule != null) { r.Add(new ModuleSymbol(accessedModule as DModule, typeIdObject as ISyntaxRegion, b as PackageSymbol)); } else if ((pack = pack.GetPackage(nextIdentifierHash)) != null) { r.Add(new PackageSymbol(pack, typeIdObject as ISyntaxRegion)); } } else if (b is ModuleSymbol) { r.AddRange(SingleNodeNameScan.SearchChildrenAndResolve(ctxt, (b as ModuleSymbol).Definition, nextIdentifierHash, typeIdObject)); } else { statProp = StaticProperties.TryEvalPropertyType(ctxt, b, nextIdentifierHash); if (statProp != null) { r.Add(statProp); } } // TODO: Search for UFCS symbols } return(r.Count == 0 ? null : r.ToArray()); }
public override void Read(AssetReader reader) { if (IsSerialized(reader.Version)) { ReadBase(reader); ParsedForm.Read(reader); m_platforms = reader.ReadEnum32Array((t) => (GPUPlatform)t); uint[] offsets = reader.ReadUInt32Array(); uint[] compressedLengths = reader.ReadUInt32Array(); uint[] decompressedLengths = reader.ReadUInt32Array(); byte[] compressedBlob = reader.ReadByteArray(); reader.AlignStream(AlignType.Align4); m_subProgramBlobs = new ShaderSubProgramBlob[m_platforms.Length]; using (MemoryStream memStream = new MemoryStream(compressedBlob)) { for (int i = 0; i < m_platforms.Length; i++) { uint offset = offsets[i]; uint compressedLength = compressedLengths[i]; uint decompressedLength = decompressedLengths[i]; memStream.Position = offset; byte[] decompressedBuffer = new byte[decompressedLength]; using (Lz4DecodeStream lz4Stream = new Lz4DecodeStream(memStream, (int)compressedLength)) { int read = lz4Stream.Read(decompressedBuffer, 0, decompressedBuffer.Length); if (read != decompressedLength) { throw new Exception($"Can't properly decode shader blob. Read {read} but expected {decompressedLength}"); } } using (MemoryStream blobMem = new MemoryStream(decompressedBuffer)) { using (AssetReader blobReader = new AssetReader(blobMem, reader.Version, reader.Platform, reader.Flags)) { ShaderSubProgramBlob blob = new ShaderSubProgramBlob(); blob.Read(blobReader); m_subProgramBlobs[i] = blob; } } } } } else { base.Read(reader); if (IsEncoded(reader.Version)) { uint decompressedSize = reader.ReadUInt32(); int comressedSize = reader.ReadInt32(); byte[] subProgramBlob = new byte[comressedSize]; reader.Read(subProgramBlob, 0, comressedSize); reader.AlignStream(AlignType.Align4); if (comressedSize > 0 && decompressedSize > 0) { byte[] decompressedBuffer = new byte[decompressedSize]; using (MemoryStream memStream = new MemoryStream(subProgramBlob)) { using (Lz4DecodeStream lz4Stream = new Lz4DecodeStream(memStream)) { int read = lz4Stream.Read(decompressedBuffer, 0, decompressedBuffer.Length); if (read != decompressedSize) { throw new Exception($"Can't properly decode sub porgram blob. Read {read} but expected {decompressedSize}"); } } } using (MemoryStream memStream = new MemoryStream(decompressedBuffer)) { using (AssetReader blobReader = new AssetReader(memStream, reader.Version, reader.Platform, reader.Flags)) { SubProgramBlob.Read(blobReader); } } } } if (IsReadFallback(reader.Version)) { Fallback.Read(reader); } if (IsReadDefaultProperties(reader.Version)) { DefaultProperties.Read(reader); } if (IsReadStaticProperties(reader.Version)) { StaticProperties.Read(reader); } } if (IsReadDependencies(reader.Version)) { m_dependencies = reader.ReadAssetArray <PPtr <Shader> >(); } if (IsReadNonModifiableTextures(reader.Version)) { m_nonModifiableTextures = reader.ReadAssetArray <PPtr <Texture> >(); } if (IsReadShaderIsBaked(reader.Version)) { ShaderIsBaked = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); } }
void BuildCompletionData( AbstractType rr, IBlockNode currentlyScopedBlock, bool isVariableInstance = false, AbstractType resultParent = null) { if (rr == null) { return; } if (rr.DeclarationOrExpressionBase is ITypeDeclaration) { isVariableInstance |= (rr.DeclarationOrExpressionBase as ITypeDeclaration).ExpressesVariableAccess; } if (rr is ArrayAccessSymbol) { isVariableInstance = true; rr = (rr as ArrayAccessSymbol).Base; } if (rr is MemberSymbol) { BuildCompletionData((MemberSymbol)rr, currentlyScopedBlock, isVariableInstance); } // A module path has been typed else if (!isVariableInstance && rr is ModuleSymbol) { BuildCompletionData((ModuleSymbol)rr); } else if (rr is PackageSymbol) { BuildCompletionData((PackageSymbol)rr); } #region A type was referenced directly else if (rr is EnumType) { var en = (EnumType)rr; foreach (var e in en.Definition) { CompletionDataGenerator.Add(e); } } else if (rr is TemplateIntermediateType) { var tr = (TemplateIntermediateType)rr; if (tr.DeclarationOrExpressionBase is TokenExpression) { int token = ((TokenExpression)tr.DeclarationOrExpressionBase).Token; isVariableInstance = token == DTokens.This || token == DTokens.Super; } // Cases: // myVar. (located in basetype definition) <-- Show everything // this. <-- Show everything // myVar. (not located in basetype definition) <-- Show public and public static members // super. <-- Show all base type members // myClass. (not located in myClass) <-- Show all static members // myClass. (located in myClass) <-- Show all static members BuildCompletionData(tr, isVariableInstance); } #endregion else if (rr is PointerType) { var pt = (PointerType)rr; if (!(pt.Base is PrimitiveType && pt.Base.DeclarationOrExpressionBase is PointerDecl)) { BuildCompletionData(pt.Base, currentlyScopedBlock, true, pt); } } else { StaticProperties.ListProperties(CompletionDataGenerator, MemberFilter, rr, isVariableInstance); } }