Esempio n. 1
0
        internal LocalDefinition DeclareLocal(
            ITypeReference type,
            object identity,
            string name,
            bool isCompilerGenerated,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray <TypedConstant> dynamicTransformFlags)
        {
            LocalDefinition local;

            if ((name != null) || !FreeSlots.TryPop(new LocalSignature(type, constraints), out local))
            {
                local = this.DeclareLocalInternal(type, identity, name, isCompilerGenerated, constraints, isDynamic, dynamicTransformFlags);
            }

            LocalMap.Add(identity, local);
            return(local);
        }
Esempio n. 2
0
        internal LocalDefinition DeclareLocal(
            Cci.ITypeReference type,
            ILocalSymbol symbol,
            string name,
            CommonSynthesizedLocalKind synthesizedKind,
            uint pdbAttributes,
            LocalSlotConstraints constraints,
            bool isDynamic,
            ImmutableArray <TypedConstant> dynamicTransformFlags)
        {
            LocalDefinition local;

            if ((name != null) || !FreeSlots.TryPop(new LocalSignature(type, constraints), out local))
            {
                local = this.DeclareLocalImpl(type, symbol, name, synthesizedKind, pdbAttributes, constraints, isDynamic, dynamicTransformFlags);
            }

            LocalMap.Add(symbol, local);
            return(local);
        }
Esempio n. 3
0
        internal LocalDefinition DeclareLocal(
            Cci.ITypeReference type,
            ILocalSymbolInternal symbol,
            string name,
            SynthesizedLocalKind kind,
            LocalDebugId id,
            LocalVariableAttributes pdbAttributes,
            LocalSlotConstraints constraints,
            ImmutableArray <TypedConstant> dynamicTransformFlags,
            ImmutableArray <TypedConstant> tupleElementNames,
            bool isSlotReusable)
        {
            if (!isSlotReusable || !FreeSlots.TryPop(new LocalSignature(type, constraints), out LocalDefinition local))
            {
                local = this.DeclareLocalImpl(type, symbol, name, kind, id, pdbAttributes, constraints, dynamicTransformFlags, tupleElementNames);
            }

            LocalMap.Add(symbol, local);
            return(local);
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cs"></param>
        public NameSection(CustomSection cs)
        {
            var stream           = new MemoryStream((byte[])cs.Content);
            var reader           = new Reader(stream);
            var previousSection  = NameSubsection.Module;
            var preSectionOffset = reader.Offset;

            while (reader.TryReadVarUInt7(out var id)) //At points where TryRead is used, the stream can safely end.
            {
                if (id != 0 && (NameSubsection)id < previousSection)
                {
                    throw new ModuleLoadException($"Sections out of order; section {(NameSubsection)id} encounterd after {previousSection}.", preSectionOffset);
                }
                var payloadLength = reader.ReadVarUInt32();

                switch ((NameSubsection)id)
                {
                case NameSubsection.Module:
                {
                    var nameLength = reader.ReadVarUInt32();
                    Name = reader.ReadString(nameLength);
                }
                break;

                case NameSubsection.Function:
                {
                    var count = reader.ReadVarUInt32();
                    Functions = new FunctionMap((int)count);
                    for (int i = 0; i < count; i++)
                    {
                        var index      = reader.ReadVarUInt32();
                        var nameLength = reader.ReadVarUInt32();
                        var name       = reader.ReadString(nameLength);
                        Functions.Add(index, name);
                    }
                }
                break;

                case NameSubsection.Local:
                {
                    var fun_count = reader.ReadVarUInt32();
                    Locals = new LocalMap((int)fun_count);
                    for (int f = 0; f < fun_count; f++)
                    {
                        var fun_index = reader.ReadVarUInt32();

                        var count   = reader.ReadVarUInt32();
                        var nameMap = new NameMap((int)count);
                        Locals.Add(fun_index, nameMap);
                        for (int i = 0; i < count; i++)
                        {
                            var index      = reader.ReadVarUInt32();
                            var nameLength = reader.ReadVarUInt32();
                            var name       = reader.ReadString(nameLength);
                            nameMap.Add(index, name);
                        }
                    }
                }
                break;
                }

                previousSection = (NameSubsection)id;
            }
        }