private void CompileProtoTemplate(ProtoTemplate tmpl)
{
Debug.Assert(tmpl != null && tmpl.Function != null && tmpl.Function.Definition.NodeType == QilNodeType.Unknown);
EnterScope(tmpl);
CheckSingletonFocus();
_funcFocus.StartFocus(tmpl.Function.Arguments, !IsDebug ? tmpl.Flags : XslFlags.FullFocus);
foreach (QilParameter arg in tmpl.Function.Arguments)
{
if (arg.Name.NamespaceUri != XmlReservedNs.NsXslDebug)
{
Debug.Assert(tmpl is Template, "Only templates can have explicit arguments");
if (IsDebug)
{
Debug.Assert(arg.DefaultValue == null, "Argument must not be compiled yet");
VarPar xslParam = (VarPar)arg.Annotation;
QilList nsListParam = EnterScope(xslParam);
arg.DefaultValue = CompileVarParValue(xslParam);
ExitScope();
arg.DefaultValue = SetDebugNs(arg.DefaultValue, nsListParam);
}
else
{
// in !IsDebug we compile argument default value in PrecompileProtoTemplatesHeaders()
}
_scope.AddVariable(arg.Name, arg);
}
}
tmpl.Function.Definition = CompileInstructions(tmpl.Content);
// tmpl.Function.Definition = AddCurrentPositionLast(tmpl.Function.Definition); We don't mask Cur,Pos,Last parameters with Cur,Pos,Last wariables any more
// tmpl.Function.Definition = SetDebugNs(tmpl.Function.Definition, nsList); We add it as parameter now.
_funcFocus.StopFocus();
ExitScope();
}