public override bool VisitStmtVarDefBase([NotNull] GamaParser.StmtVarDefBaseContext context) { var name = context.Symbol().GetText(); var val = Top.FindValue(name); // Duplicate variable definition (parent frames can have same variable, it will be overriden in current frame) if (val != null) { NamespaceContext.Context.AddError(new ErrorDuplicateVariable(context)); return(false); } val = VisitExpression(context.expr()); if (val == null) { return(false); } /* LLVM */ CurrentBlock.PositionBuilderAtEnd(Builder); var alloc = Builder.BuildAlloca(val.Type.UnderlyingType, name); Builder.BuildStore(val.Value, alloc); Top.AddValue(name, new GamaValueRef(val.Type, alloc, true)); return(true); }
/// <summary> /// Visit a parse tree produced by the <c>StmtVarDefBase</c> /// labeled alternative in <see cref="GamaParser.stmtVarDef"/>. /// <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 VisitStmtVarDefBase([NotNull] GamaParser.StmtVarDefBaseContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by the <c>StmtVarDefBase</c> /// labeled alternative in <see cref="GamaParser.stmtVarDef"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitStmtVarDefBase([NotNull] GamaParser.StmtVarDefBaseContext context) { }