public override object VisitFunctionDeclaration([NotNull] CMinusParser.FunctionDeclarationContext context)
        {
            string functionType = SymbolTable.Symbol.RemoveExtras(context.typeSpecifier().GetText());
            string functionName = context.ID().GetText();

            List <SymbolTable.Symbol> parameters = (List <SymbolTable.Symbol>) this.Visit(context.parameters()); // Visit parameters

            SymbolTable.Symbol functionSymbol = new SymbolTable.Symbol(
                id: functionName,
                type: functionType,
                construct: SymbolTable.Symbol.Construct.FUNCTION,
                size: (uint)parameters.Count,
                scope: this.internalScope,
                pointerCount: 0
                );

            functionSymbol.AddMembers(parameters);

            bool success = this.symbolTable.AddSymbol(functionSymbol);

            if (!success)
            {
                this.EmitSemanticErrorMessage($"Symbol {functionName} already in symbol table as a {this.symbolTable.GetSymbol(functionName).construct}", context);
            }

            return(null);
        }
        public override object VisitFunctionDeclaration([NotNull] CMinusParser.FunctionDeclarationContext context)
        {
            this.inGlobalScope = false;
            this.writer.DisableGlobalBuffer();

            string functionLabel = this.labelGenerator.GenerateFunctionLabel(context.ID().GetText());

            this.writer.WriteLabel(functionLabel);

            this.writer.WriteNoOperation("PSP");

            this.EnterContext();
            this.Visit(context.parameters());

            this.Visit(context.compoundStatement());

            this.ExitContext();

            this.writer.WriteLabel(this.labelGenerator.FunctionReturnLabel());

            this.writer.WriteFunctionExit();

            this.writer.EnableGlobalBuffer();
            this.inGlobalScope = true;

            return(null);
        }
        public override object VisitFunctionDeclaration([NotNull] CMinusParser.FunctionDeclarationContext context)
        {
            string functionName = context.ID().GetText();

            SymbolTable.Symbol functionSymbol = this.symbolTable.GetSymbol(functionName);

            this.internalScope++;
            this.symbolTable.EnterScope();

            foreach (SymbolTable.Symbol member in functionSymbol.submembers)
            {
                bool success = this.symbolTable.AddSymbol(member);
                if (!success)
                {
                    this.EmitSemanticErrorMessage($"Symbol {member.id} already in symbol table as a {this.symbolTable.GetSymbol(member.id).construct}", context);
                }
            }

            this.Visit(context.compoundStatement());

            this.symbolTable.ExitScope();
            this.internalScope--;

            return(true);
        }
        public override object VisitFunctionDeclaration([NotNull] CMinusParser.FunctionDeclarationContext context)
        {
            this.writer.EnterFunction(context.ID().GetText(), context.typeSpecifier().GetText());
            this.Visit(context.compoundStatement());
            this.writer.ExitFunction();

            return(null);
        }