コード例 #1
0
        public override void ExitVoid_methodDeclaration(DecafParser.Void_methodDeclarationContext context)
        {
            parameterList = null;
            SymbolType theReturnType = SymbolType.Tvoid;
            List<SymbolType> theParameters = new List<SymbolType>();

            theScopeManager.GetAndExitScope();
            DecafParser.ParameterContext[] parameterGroup = context.parameter();

            foreach (DecafParser.ParameterContext item in parameterGroup)
                theParameters.Add(getNodeType(item));

            MethodSymbol theSymbolRepresentation = new MethodSymbol(theReturnType, theParameters);

            theScopeManager.AddSymbol(context.Id().GetText(), theSymbolRepresentation);

            if (theScopeManager.HasReturn)
            {
                if (!(TypeHelper.isEquivalentType(theScopeManager.ReturnType, SymbolType.Tvoid)))
                {
                    throw new Exception("Return Type Mismatch");
                }
            }

            theScopeManager.resetReturn();
        }