public void IntroduceTemplateParameterTypes(DSymbol tir) { if(tir!=null && tir.DeducedTypes != null) foreach (var dt in tir.DeducedTypes) if(dt != null) DeducedTemplateParameters[dt.Parameter] = dt; }
public void RemoveParamTypesFromPreferredLocals(DSymbol tir) { if (tir != null && tir.DeducedTypes != null) { foreach (var dt in tir.DeducedTypes) { DeducedTemplateParameters.Remove(dt.Parameter); } } }
public void IntroduceTemplateParameterTypes(DSymbol tir) { if (tir != null && tir.DeducedTypes != null) { foreach (var dt in tir.DeducedTypes) { DeducedTemplateParameters[dt.Parameter] = dt; } } }
public IDisposable Push(DSymbol ds, CodeLocation caret) { if (ds == null) { return(null); } var pop = Push_(ds.Definition, caret); CurrentContext.IntroduceTemplateParameterTypes(ds); return(new PopDisposable(this, pop ? null : ds)); }
ITypeDeclaration VisitDSymbol(DSymbol t) { var def = t.Definition; ITypeDeclaration td = new IdentifierDeclaration(def != null ? def.NameHash : 0); if (def != null && t.DeducedTypes != null && def.TemplateParameters != null) { var args = new List <IExpression>(); foreach (var tp in def.TemplateParameters) { IExpression argEx = null; foreach (var tps in t.DeducedTypes) { if (tps != null && tps.Parameter == tp) { if (tps.ParameterValue != null) { //TODO: Convert ISymbolValues back to IExpression } else { argEx = new TypeDeclarationExpression(AcceptType(tps)); } break; } } args.Add(argEx ?? new IdentifierExpression(tp.NameHash)); } td = new TemplateInstanceExpression(td) { Arguments = args.ToArray() }; } var ret = td; while (def != null && def != (def = def.Parent as DNode) && def != null && !(def is DModule)) { td = td.InnerDeclaration = new IdentifierDeclaration(def.NameHash); } return(ret); }
public void RemoveParamTypesFromPreferredLocals(DSymbol tir) { if (tir != null && tir.DeducedTypes != null) foreach (var dt in tir.DeducedTypes) DeducedTemplateParameters.Remove(dt.Parameter); }
void VisitDSymbol(DSymbol t) { var def = t.Definition; sb.Append(def != null ? def.ToString(false, true) : "<Node object no longer exists>"); }
public static ObjectValueFlags BuildObjectValueFlags (DSymbol ds) { var baseType = ds is MemberSymbol ? ds.Base : ds; ObjectValueFlags f = ObjectValueFlags.None; if (baseType is ClassType || baseType is InterfaceType) f |= ObjectValueFlags.Object; else if (baseType is PrimitiveType) f |= ObjectValueFlags.Primitive; else if (baseType is ArrayType) f |= ObjectValueFlags.Array; if(ds is MemberSymbol) { var defParent = ds.Definition.Parent; if (defParent is DModule) f |= ObjectValueFlags.Global; else if (defParent is DMethod) { if ((defParent as DMethod).Parameters.Contains (ds.Definition)) f |= ObjectValueFlags.Parameter; else f |= ObjectValueFlags.Variable; } } return f; }
protected void Handle(ISyntaxRegion o, DSymbol resolvedSymbol) { if (o is IdentifierDeclaration) { var id = (IdentifierDeclaration)o; if (id.Id != searchId) return; if (resolvedSymbol == null) resolvedSymbol = TypeDeclarationResolver.ResolveSingle(id, ctxt) as DSymbol; } else if (o is TemplateInstanceExpression) { var tix = (TemplateInstanceExpression)o; if (tix.TemplateIdentifier.Id != searchId) return; if (resolvedSymbol == null) resolvedSymbol = Evaluation.EvaluateType(tix, ctxt) as DSymbol; } else if (o is IdentifierExpression) { var id = (IdentifierExpression)o; if ((string)id.Value != searchId) return; if (resolvedSymbol == null) resolvedSymbol = Evaluation.EvaluateType(id, ctxt) as DSymbol; } else if (o is PostfixExpression_Access) { var acc = (PostfixExpression_Access)o; if ((acc.AccessExpression is IdentifierExpression && (string)((IdentifierExpression)acc.AccessExpression).Value != searchId) || (acc.AccessExpression is TemplateInstanceExpression && (string)((TemplateInstanceExpression)acc.AccessExpression).TemplateIdentifier.Id != searchId)) { Handle(acc.PostfixForeExpression, null); return; } else if (acc.AccessExpression is NewExpression) { var nex = (NewExpression)acc.AccessExpression; if ((nex.Type is IdentifierDeclaration && ((IdentifierDeclaration)nex.Type).Id != searchId) || (nex.Type is TemplateInstanceExpression && (string)((TemplateInstanceExpression)acc.AccessExpression).TemplateIdentifier.Id != searchId)) { Handle(acc.PostfixForeExpression, null); return; } // Are there other types to test for? } var s = resolvedSymbol ?? Evaluation.EvaluateType(acc, ctxt) as DerivedDataType; if (s is DSymbol) { if (((DSymbol)s).Definition == symbol) l.Add(acc.AccessExpression); } else if (s == null || !(s.Base is DSymbol)) return; // Scan down for other possible symbols Handle(acc.PostfixForeExpression, s.Base as DSymbol); return; } // The resolved node must be equal to the symbol definition that is looked for. if (resolvedSymbol == null || resolvedSymbol.Definition != symbol) return; l.Add(o); }
public IDisposable Push(DSymbol ds) { return(ds != null?Push(ds, ds.Definition.Location) : null); }
public PopDisposable(ResolutionContext ctxt, DSymbol ds = null) { this.ctxt = ctxt; this.ds = ds; }
public void RemoveParamTypesFromPreferredLocals(DSymbol tir) { if (tir != null) DeducedTemplateParameters.Remove (tir.DeducedTypes); }
public void IntroduceTemplateParameterTypes(DSymbol tir) { if (tir != null) DeducedTemplateParameters.Add (tir.DeducedTypes); }
public static TooltipInformation Generate(DSymbol tit, int currentParam = -1) { var sb = new StringBuilder("("); if (tit is ClassType) sb.Append("Class"); else if (tit is InterfaceType) sb.Append("Interface"); else if (tit is TemplateType || tit is EponymousTemplateType) sb.Append("Template"); else if (tit is StructType) sb.Append("Struct"); else if (tit is UnionType) sb.Append("Union"); sb.Append(") ").Append(tit.Name); var dc =tit.Definition; if (dc.TemplateParameters != null && dc.TemplateParameters.Length != 0) { sb.Append('('); for (int i = 0; i < dc.TemplateParameters.Length; i++) { if (i == currentParam) sb.Append("<i>"); sb.Append(dc.TemplateParameters[i].ToString()); if (i == currentParam) sb.Append("</i>"); sb.Append(','); } sb.Remove(sb.Length -1, 1).Append(')'); } var tti = new TooltipInformation { SignatureMarkup = sb.ToString(), SummaryMarkup = dc.Description, FooterMarkup = dc.ToString(false) }; return tti; }