Esempio n. 1
0
        private void DefineFunction(LeafParser.Def_funcContext def, LeafParser.Attribute_addContext[]?attribs)
        {
            var decl = def.function_decl();
            var impl = def.function_impl();
            var name = def.Id().GetText();

            try
            {
                var func = DefineFunction(name, decl, impl, def.generic_def_list(), attribs);

                if (!Namespace.Functions.TryGetValue(name, out var group))
                {
                    group = new OverloadGroup(name, Namespace);
                    Namespace.Functions.Add(name, group);
                }

                group.AddImplementation(func);
            }
            catch (CompilationException e)
            { throw new CompilationException($"Could not compile function '{name}'.", this, def.Start.Line, e); }
        }
Esempio n. 2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="LeafParser.def_func"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitDef_func([NotNull] LeafParser.Def_funcContext context)
 {
     return(VisitChildren(context));
 }