public override ASTNode VisitStructdef([NotNull] llangParser.StructdefContext context) { string name = context.Iden().GetText(); List <Expression> defaultValues = new List <Expression>(); var fields = new Dictionary <string, (TypeSymbol, int)>(); if (context.structDeclList() != null) { for (int i = 0; i < context.structDeclList().ChildCount; i++) { VarDeclNode s = (VarDeclNode)Visit(context.structDeclList().GetChild(i)); fields.Add(s.name, (s.Type, 0)); defaultValues.Add(s.rhs); } } TypeSymbol ownType = TypeSymbol.STRUCT_SYMBOL(name, 0, fields); return(new StructDefNode(name, ownType, defaultValues, MakeSourceLoc(context))); // Technically useless for Codegen }
/// <summary> /// Exit a parse tree produced by <see cref="llangParser.structdef"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitStructdef([NotNull] llangParser.StructdefContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="llangParser.structdef"/>. /// <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 VisitStructdef([NotNull] llangParser.StructdefContext context) { return(VisitChildren(context)); }