Ejemplo n.º 1
0
        public TypeSymbol EmitLoad(ILBuilder il)
        {
            //if (_property.Getter == null)
            //    throw new InvalidOperationException();

            var stack  = +1;
            var getter = _property.GetMethod;

            var receiver = EmitReceiver(il);

            if (receiver != null)
            {
                stack -= 1;
            }

            il.EmitOpCode((getter.IsVirtual || getter.IsAbstract) ? ILOpCode.Callvirt : ILOpCode.Call, stack);

            var getterref = (_module != null)
                ? _module.Translate(getter, DiagnosticBag.GetInstance(), false)
                : getter;

            il.EmitToken(getterref, null, DiagnosticBag.GetInstance());    // TODO: Translate

            //
            return(getter.ReturnType);
        }
Ejemplo n.º 2
0
        private static Cci.IAssemblyReference TryGetAssemblyScope(
            NamespaceSymbol @namespace,
            Emit.PEModuleBuilder moduleBuilder,
            DiagnosticBag diagnostics
            )
        {
            AssemblySymbol containingAssembly = @namespace.ContainingAssembly;

            if (
                (object)containingAssembly != null &&
                (object)containingAssembly != moduleBuilder.CommonCompilation.Assembly
                )
            {
                var referenceManager = (
                    (CSharpCompilation)moduleBuilder.CommonCompilation
                    ).GetBoundReferenceManager();

                for (int i = 0; i < referenceManager.ReferencedAssemblies.Length; i++)
                {
                    if ((object)referenceManager.ReferencedAssemblies[i] == containingAssembly)
                    {
                        if (!referenceManager.DeclarationsAccessibleWithoutAlias(i))
                        {
                            return(moduleBuilder.Translate(containingAssembly, diagnostics));
                        }
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 3
0
        public FieldPlace_Raw(IFieldSymbol field, Emit.PEModuleBuilder module = null)
        {
            Contract.ThrowIfNull(field);

            field = GetRealDefinition(field);

            _field    = (FieldSymbol)field;
            _fieldref = (module != null) ? module.Translate((FieldSymbol)field, null, DiagnosticBag.GetInstance()) : (Cci.IFieldReference)field;
        }
Ejemplo n.º 4
0
 private static Cci.ITypeReference GetTypeReference(
     TypeSymbol type,
     SyntaxNode syntaxNode,
     Emit.PEModuleBuilder moduleBuilder,
     DiagnosticBag diagnostics
     )
 {
     return(moduleBuilder.Translate(type, syntaxNode, diagnostics));
 }