public override int VisitFunction_def_stmt(BRAQParser.Function_def_stmtContext context) { if (current_method == null) { Console.WriteLine("Huh!?"); return(0); } method_end = il.DefineLabel(); foreach (var l in locals) { il.DeclareLocal(typerResult.local_types[l]); } if (current_method.return_type != typeof(void)) { return_holder = il.DeclareLocal(current_method.return_type); } context.function_body.Accept(this); il.MarkLabel(method_end.Value); if (current_method.return_type != typeof(void)) { il.Emit(OpCodes.Ldloc, return_holder); } il.Emit(OpCodes.Ret); return(0); }
public OwnMethodInfo(string name, List <Pair <string, Type> > arguments, Type returnType, BRAQParser.Function_def_stmtContext body) { this.name = name; this.arguments = arguments; return_type = returnType; this.body = body; }
public override int VisitFunction_def_stmt(BRAQParser.Function_def_stmtContext context) { foreach (var typedId in context.typed_id()) { function_argument_scope[typedId.id_name.Text] = typedId; } inside_function = true; context.function_body.Accept(this); if (assigned.ContainsValue(false)) { string msg = $"variable {assigned.First(x => !x.Value).Key} was never assigned, cannot solve type."; Console.WriteLine(msg); throw new TypesolvingError(); } inside_function = false; function_argument_scope.Clear(); return(0); }
/// <summary> /// Visit a parse tree produced by <see cref="BRAQParser.function_def_stmt"/>. /// <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 VisitFunction_def_stmt([NotNull] BRAQParser.Function_def_stmtContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="BRAQParser.function_def_stmt"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitFunction_def_stmt([NotNull] BRAQParser.Function_def_stmtContext context) { }
public override Type VisitFunction_def_stmt(BRAQParser.Function_def_stmtContext context) { context.function_body.Accept(this); return(result_box.methodInfo.return_type); }