public void DefineDeclaration(IIntermediateFieldMember declaration) { }
public string Visit <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent>(IIntermediateFieldMember <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> field, IntermediateNameRequestDetails context) where TField : Abstract.Members.IFieldMember <TField, TFieldParent> where TIntermediateField : TField, IIntermediateFieldMember <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> where TFieldParent : Abstract.IFieldParent <TField, TFieldParent> where TIntermediateFieldParent : TFieldParent, IIntermediateFieldParent <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> { string name = null; switch (context) { case IntermediateNameRequestDetails.TargetFileName: if (!(field.Parent is IIntermediateType)) { return(null); } this.fileNameLookup.TryGetValue(((IIntermediateType)field.Parent).Assembly, out name); if (this.HtmlContext) { name = string.Format("{0}#fld{1:X8}", name, field.GetHashCode()); } break; case IntermediateNameRequestDetails.SourceFileName: if (!(field.Parent is IIntermediateType)) { return(null); } name = ((IIntermediateType)field.Parent).Assembly.FileName; break; case IntermediateNameRequestDetails.DisplayName: name = field.Name; break; case IntermediateNameRequestDetails.ReferenceName: if (this.HtmlContext) { name = string.Format("fld{0:X8}", field.GetHashCode()); } break; } return(name); }
public void ReferenceDeclaration(IIntermediateFieldMember declaration) { }
/// <summary> /// <para>Creates a C♯ compiler warning, relative /// to the abstract model, (level 3) #414:</para> /// <para>The private field <paramref name="offendingField"/> is assigned but its value /// is never used.</para> /// </summary> /// <param name="offendingField">The <see cref="IIntermediateFieldMember"/> which is assigned its value /// but never used.</param> public static ICompilerModelWarning <IIntermediateFieldMember> WarningCS0414(IIntermediateFieldMember offendingField) { //ToDo: Add location information to fields. return(new CompilerModelWarning <IIntermediateFieldMember>(CS0414, offendingField, offendingField.UniqueIdentifier.ToString())); }
void IIntermediateMemberVisitor.Visit <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent>(IIntermediateFieldMember <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> intermediateMember) { this.Translate(intermediateMember); }
public void DefineDeclaration(IIntermediateFieldMember declaration) { this.DefineDeclaration((IIntermediateMember)declaration); }
public TestLinkerResult Visit <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent>(IIntermediateFieldMember <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> field, ICompilationContext context) where TField : IFieldMember <TField, TFieldParent> where TIntermediateField : TField, IIntermediateFieldMember <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> where TFieldParent : IFieldParent <TField, TFieldParent> where TIntermediateFieldParent : TFieldParent, IIntermediateFieldParent <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> { throw new NotImplementedException(); }
public IGeneralMemberUniqueIdentifier GetIdentifier(IIntermediateFieldMember member) { return(TypeSystemIdentifiers.GetMemberIdentifier(member.Name, member.UserSpecificQualifier)); }
private static void BuildStructureConstructors(IProductionRuleCaptureStructure targetStructure, OilexerGrammarProductionRuleEntry structureRoot, ITypeIdentityManager identityManager) { int stateIndex = 0; foreach (var element in targetStructure.Values) { element.StateIndex = stateIndex++; } IEnumerable <IEnumerable <Tuple <IProductionRuleCaptureStructuralItem, bool> > > validVariations = new IEnumerable <Tuple <IProductionRuleCaptureStructuralItem, bool> > [0]; var firstOrDefSeries = (IProductionRuleSeries)targetStructure.Sources.FirstOrDefault(k => k is IProductionRuleSeries); var firstOrDefProductionRule = (IOilexerGrammarProductionRuleEntry)targetStructure.Sources.FirstOrDefault(k => k is IOilexerGrammarProductionRuleEntry); var optg = PickOptionalGroups(firstOrDefProductionRule == null ? firstOrDefSeries : firstOrDefProductionRule, targetStructure); foreach (var parameterSet in targetStructure.Structures) { var limitedSet = (from param in parameterSet join item in targetStructure.Keys on param equals item select new { Name = item, Item = targetStructure[item] }).ToArray(); var optionalSet = (from l in limitedSet where l.Item.Optional select l).ToArray(); if (limitedSet.Length > 0) { var parameterPermutations = VariateSeries(new LockedLinkedList <IProductionRuleCaptureStructuralItem>(from l in limitedSet select l.Item).First, optg).Distinct(); validVariations = validVariations.Concat(parameterPermutations); foreach (var variation in parameterPermutations) { bool[] parameterStateFlags = (from k in variation.ToArray() select k.Item2).ToArray(); List <string> parameterResult = new List <string>(); for (int parameterIndex = 0; parameterIndex < parameterStateFlags.Length; parameterIndex++) { if (parameterStateFlags[parameterIndex]) { var limitedEntry = limitedSet[parameterIndex]; parameterResult.Add(limitedEntry.Name); } } //if (!resultantParameterSets.Any(k => k.SequenceEqual(parameterResult))) // resultantParameterSets.Add(parameterResult); } } } List <IEnumerable <Tuple <IProductionRuleCaptureStructuralItem, bool> > > toRemove = new List <IEnumerable <Tuple <IProductionRuleCaptureStructuralItem, bool> > >(); var exclusiveDistinctions = (from set in validVariations.Distinct().ToArray() let parameters = from parameter in set where parameter.Item2 select parameter.Item1 orderby string.Join(string.Empty, from k in parameters select k.BucketName) select new HashList <IProductionRuleCaptureStructuralItem>(parameters)).Distinct(); var stateField = targetStructure.ResultClass.Fields.Add(new TypedName("state", identityManager.ObtainTypeReference(RuntimeCoreType.Int32))); var toStringMethod = targetStructure.ResultClass.Methods.Add(new TypedName("ToString", identityManager.ObtainTypeReference(RuntimeCoreType.String))); toStringMethod.AccessLevel = AccessLevelModifiers.Public; toStringMethod.IsOverride = true; var toStringStateSwitch = toStringMethod.Switch(stateField.GetReference()); toStringMethod.Return(identityManager.ObtainTypeReference(RuntimeCoreType.String).GetTypeExpression().GetField("Empty")); var formatMethod = identityManager.ObtainTypeReference(RuntimeCoreType.String).GetTypeExpression().GetMethod("Format"); foreach (var parameterSetVariation in exclusiveDistinctions) { TypedNameSeries currentCtorTNS = new TypedNameSeries(); int currentStateValue = 0; foreach (var parameterEntry in parameterSetVariation) { var parameterName = parameterEntry.BucketName; var currentElement = targetStructure[parameterName]; IType parameterType = null; switch (currentElement.ResultType) { case ResultedDataType.EnumerationItem: case ResultedDataType.Flag: parameterType = identityManager.ObtainTypeReference(RuntimeCoreType.Boolean); break; case ResultedDataType.Enumeration: IProductionRuleCaptureStructure enumStructure = (IProductionRuleCaptureStructure)currentElement; parameterType = enumStructure.AggregateSetEnum ?? enumStructure.ResultEnumSet[0]; break; case ResultedDataType.ComplexType: IProductionRuleCaptureStructure dualStructure = (IProductionRuleCaptureStructure)currentElement; parameterType = dualStructure.ResultInterface; break; case ResultedDataType.Counter: parameterType = identityManager.ObtainTypeReference(RuntimeCoreType.Int32); break; case ResultedDataType.Character: parameterType = identityManager.ObtainTypeReference(RuntimeCoreType.Char); break; case ResultedDataType.String: parameterType = identityManager.ObtainTypeReference(RuntimeCoreType.String); break; default: throw new InvalidOperationException("Unknown parameter type."); } currentStateValue |= (int)Math.Pow(2, parameterEntry.StateIndex); currentCtorTNS.Add(LowerFirstCharacter(parameterName), parameterType); } var currentCtor = targetStructure.ResultClass.Constructors.Add(currentCtorTNS); currentCtor.AccessLevel = AccessLevelModifiers.Public; currentCtor.Assign(stateField.GetReference(), currentStateValue.ToPrimitive()); var currentStateCase = toStringStateSwitch.Case(currentStateValue.ToPrimitive()); var currentInvocation = formatMethod.Invoke(); currentStateCase.Return(currentInvocation); var currentFormat = string.Empty.ToPrimitive(); currentInvocation.Arguments.Add(currentFormat); StringBuilder formatBuilder = new StringBuilder(); bool first = true; int currentParamIndex = 0; foreach (var parameterEntry in parameterSetVariation) { if (first) { first = false; } else { formatBuilder.Append(", "); } formatBuilder.AppendFormat("{{{0}}}", currentParamIndex++); var parameterName = parameterEntry.BucketName; var currentElement = targetStructure[parameterName]; IIntermediateFieldMember currentField = currentElement.AssociatedField; currentInvocation.Arguments.Add(currentField.GetReference()); currentCtor.Assign(currentField.GetReference(), currentCtor.Parameters[LowerFirstCharacter(parameterName)].GetReference()); } currentFormat.Value = formatBuilder.ToString(); } }
public abstract void Translate <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent>(IIntermediateFieldMember <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> intermediateMember) where TField : IFieldMember <TField, TFieldParent> where TIntermediateField : TField, IIntermediateFieldMember <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> where TFieldParent : IFieldParent <TField, TFieldParent> where TIntermediateFieldParent : TFieldParent, IIntermediateFieldParent <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent>;
public void ReferenceDeclaration(IIntermediateFieldMember declaration) { this.Formatter.ReferenceDeclaration(declaration); }
public void DefineDeclaration(IIntermediateFieldMember declaration) { this.Formatter.DefineDeclaration(declaration); }
public IGeneralMemberUniqueIdentifier GetIdentifier(IIntermediateFieldMember member) { return(IntermediateGateway.DefaultUniqueIdentifierService.GetIdentifier(member)); }
public TransformationKind Visit <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent>(IIntermediateFieldMember <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> field, ITransformationContext context) where TField : IFieldMember <TField, TFieldParent> where TIntermediateField : TField, IIntermediateFieldMember <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> where TFieldParent : IFieldParent <TField, TFieldParent> where TIntermediateFieldParent : TFieldParent, IIntermediateFieldParent <TField, TIntermediateField, TFieldParent, TIntermediateFieldParent> { throw new NotImplementedException(); }