コード例 #1
0
        public override void ExitMethodCall(DecafParser.MethodCallContext context)
        {
            string theId = context.Id().GetText();

            if (!theScopeManager.CheckScope(context.Id().GetText(), symbolCategory.Cmethod)) //checks if the method is already declared
            {
                int line = context.start.Line;
                throw new Exception("Undeclared Identifier at line " + line.ToString());
            }
            else
            {
                MethodSymbol theSymbol = theScopeManager.FindSymbol(context.Id().GetText(), symbolCategory.Cmethod) as MethodSymbol;
                List<SymbolType> MyparameterList = new List<SymbolType>();
                #region methodCall parameter handling

                for (int i = 0; i < context.arg().Length; i++)
                {
                    DecafParser.ArgContext argument = context.arg(i);
                    MyparameterList.Add(getNodeType(argument));
                }

                if (!theSymbol.checkParameterList(MyparameterList))

                    if (!TypeHelper.checkLists(MyparameterList, parameterList))
                    {
                        throw new Exception("Argument Mismatch Errror");
                    }

                #endregion
                setNodeType(context, theSymbol.Type);
            }
        }