/// <summary> /// Resolves an identifier and returns the definition + its base type. /// Does not deduce any template parameters or nor filters out unfitting template specifications! /// </summary> public static AbstractType[] ResolveIdentifier(int idHash, ResolutionContext ctxt, object idObject, bool ModuleScope = false) { var loc = idObject is ISyntaxRegion ? ((ISyntaxRegion)idObject).Location : CodeLocation.Empty; if (ModuleScope) { ctxt.PushNewScope(ctxt.ScopedBlock.NodeRoot as DModule); } // If there are symbols that must be preferred, take them instead of scanning the ast else { TemplateParameterSymbol dedTemplateParam; if (ctxt.GetTemplateParam(idHash, out dedTemplateParam)) { return new[] { dedTemplateParam } } ; } var res = NameScan.SearchAndResolve(ctxt, loc, idHash, idObject); if (ModuleScope) { ctxt.Pop(); } return /*res.Count == 0 ? null :*/ (res.ToArray()); }
public AbstractType Visit(TemplateParameter.Node tpn) { TemplateParameterSymbol tpnBase; //TODO: Resolve the specialization type //var templateParameterType = TemplateInstanceHandler.ResolveTypeSpecialization(tmp, ctxt); if (ctxt.GetTemplateParam(tpn.NameHash, out tpnBase) && tpnBase.Parameter == tpn.TemplateParameter) { return(tpnBase); } return(new TemplateParameterSymbol(tpn, null, typeBase)); }
/// <summary> /// Resolves an identifier and returns the definition + its base type. /// Does not deduce any template parameters or nor filters out unfitting template specifications! /// </summary> public static AbstractType[] ResolveIdentifier(int idHash, ResolutionContext ctxt, ISyntaxRegion idObject, bool ModuleScope = false) { var loc = idObject is ISyntaxRegion ? ((ISyntaxRegion)idObject).Location : CodeLocation.Empty; if (ModuleScope) { ctxt.PushNewScope(ctxt.ScopedBlock.NodeRoot as DModule); } // If there are symbols that must be preferred, take them instead of scanning the ast else { TemplateParameterSymbol dedTemplateParam; if (ctxt.GetTemplateParam(idHash, out dedTemplateParam)) { return new[] { dedTemplateParam } } ; } var res = NameScan.SearchAndResolve(ctxt, loc, idHash, idObject); if (ModuleScope) { ctxt.Pop(); } if (res.Count != 0) { return /*res.Count == 0 ? null :*/ (res.ToArray()); } // Support some very basic static typing if no phobos is given atm if (idHash == Evaluation.stringTypeHash) { res.Add(Evaluation.GetStringType(ctxt)); } else if (idHash == Evaluation.wstringTypeHash) { res.Add(Evaluation.GetStringType(ctxt, LiteralSubformat.Utf16)); } else if (idHash == Evaluation.dstringTypeHash) { res.Add(Evaluation.GetStringType(ctxt, LiteralSubformat.Utf32)); } return(res.ToArray()); }
/// <summary> /// Resolves an identifier and returns the definition + its base type. /// Does not deduce any template parameters or nor filters out unfitting template specifications! /// </summary> public static AbstractType[] ResolveIdentifier(int idHash, ResolutionContext ctxt, object idObject, bool ModuleScope = false) { var loc = idObject is ISyntaxRegion ? ((ISyntaxRegion)idObject).Location : CodeLocation.Empty; if (ModuleScope) ctxt.PushNewScope(ctxt.ScopedBlock.NodeRoot as DModule); // If there are symbols that must be preferred, take them instead of scanning the ast else { TemplateParameterSymbol dedTemplateParam; if (ctxt.GetTemplateParam(idHash, out dedTemplateParam)) return new[] { dedTemplateParam }; } var res = NameScan.SearchAndResolve(ctxt, loc, idHash, idObject); if (ModuleScope) ctxt.Pop(); return /*res.Count == 0 ? null :*/ res.ToArray(); }