Exemplo n.º 1
0
            public override int VisitMethod(MethodSymbol symbol, int a)
            {
                if (symbol.IsAbstract)
                {
                    return(0);
                }

                // Constructors require extra analysis before IL is generated, such as
                // calling the default base constructor. If we see a constructor here
                // we emit what amounts to an empty body (with the right base call) until
                // this analysis is implemented.

                if (symbol.Name == MethodSymbol.InstanceConstructorName && symbol is SourceMethodSymbol)
                {
                    moduleBeingBuilt.SetMethodBody(symbol, this.BOGUSDefineCtor(symbol));
                    return(0);
                }
                else if (symbol.Name == MethodSymbol.StaticConstructorName)
                {
                    Debug.Fail(MethodSymbol.StaticConstructorName + " method body analysis not implemented");
                    return(0);
                }

                var block         = compilation.BindMethodBody(symbol, this.diagnostics);
                var analyzedBlock = compilation.AnalyzeMethodBody(symbol, block, mapFileNameToDebugDoc != null, this.diagnostics);
                var emittedBody   = compilation.EmitMethodBody(this.moduleBeingBuilt, symbol, analyzedBlock, mapFileNameToDebugDoc);

                moduleBeingBuilt.SetMethodBody(symbol, emittedBody);

                if (symbol.Name == "Main")
                {
                    // TODO: diagnostics if there is more than one of these, check signatures, etc.
                    moduleBeingBuilt.SetEntryPoint((SourceMethodSymbol)symbol);
                }

                return(0);
            }