LocalVarSig.LocalVariable ReadLocalVariable(byte [] data, int pos, out int start)
        {
            start = pos;
            LocalVarSig.LocalVariable lv = new LocalVarSig.LocalVariable();
            lv.ByRef = false;
            int cursor;

            while (true)
            {
                lv.CustomMods = ReadCustomMods(data, start, out start);
                cursor        = start;
                int current = Utilities.ReadCompressedInteger(data, start, out start);
                if (current == (int)ElementType.Pinned)                  // the only possible constraint
                {
                    lv.Constraint |= Constraint.Pinned;
                }
                else if (current == (int)ElementType.ByRef)
                {
                    lv.ByRef = true;
                }
                else
                {
                    lv.Type = this.ReadType(data, cursor, out start);
                    break;
                }
            }
            return(lv);
        }
        LocalVarSig.LocalVariable [] ReadLocalVariables(int length, byte [] data, int pos)
        {
            int start = pos;

            LocalVarSig.LocalVariable [] types = new LocalVarSig.LocalVariable [length];
            for (int i = 0; i < length; i++)
            {
                types [i] = this.ReadLocalVariable(data, start, out start);
            }
            return(types);
        }
예제 #3
0
 void Write(LocalVarSig.LocalVariable var)
 {
     Write(var.CustomMods);
     if ((var.Constraint & Constraint.Pinned) != 0)
     {
         Write(ElementType.Pinned);
     }
     if (var.ByRef)
     {
         Write(ElementType.ByRef);
     }
     Write(var.Type);
 }
예제 #4
0
        public LocalVarSig.LocalVariable GetLocalVariableSig(VariableDefinition var)
        {
            LocalVarSig.LocalVariable lv = new LocalVarSig.LocalVariable ();
            TypeReference type = var.VariableType;

            lv.CustomMods = m_reflectWriter.GetCustomMods (type);

            if (type is PinnedType) {
                lv.Constraint |= Constraint.Pinned;
                type = (type as PinnedType).ElementType;
            }

            if (type is ReferenceType) {
                lv.ByRef = true;
                type = (type as ReferenceType).ElementType;
            }

            lv.Type = m_reflectWriter.GetSigType (type);

            return lv;
        }
예제 #5
0
		LocalVarSig GetLocalVarSig (VariableDefinitionCollection vars)
		{
			LocalVarSig lvs = new LocalVarSig ();
			lvs.CallingConvention |= 0x7;
			lvs.Count = vars.Count;
			lvs.LocalVariables = new LocalVarSig.LocalVariable [lvs.Count];
			for (int i = 0; i < lvs.Count; i++) {
				LocalVarSig.LocalVariable lv = new LocalVarSig.LocalVariable ();
				TypeReference type = vars [i].VariableType;

				lv.CustomMods = m_reflectWriter.GetCustomMods (type);

				if (type is PinnedType) {
					lv.Constraint |= Constraint.Pinned;
					type = (type as PinnedType).ElementType;
				}

				if (type is ReferenceType) {
					lv.ByRef = true;
					type = (type as ReferenceType).ElementType;
				}

				lv.Type = m_reflectWriter.GetSigType (type);

				lvs.LocalVariables [i] = lv;
			}
			return lvs;
		}
예제 #6
0
 public byte [] CompressLocalVar(LocalVarSig.LocalVariable var)
 {
     m_sigWriter.Empty();
     Write(var);
     return(m_sigWriter.ToArray());
 }
예제 #7
0
 LocalVarSig.LocalVariable[] ReadLocalVariables(int length, byte [] data, int pos)
 {
     int start = pos;
     LocalVarSig.LocalVariable [] types = new LocalVarSig.LocalVariable [length];
     for (int i = 0; i < length; i++)
         types [i] = ReadLocalVariable (data, start, out start);
     return types;
 }
예제 #8
0
        LocalVarSig.LocalVariable ReadLocalVariable(byte [] data, int pos, out int start)
        {
            start = pos;
            LocalVarSig.LocalVariable lv = new LocalVarSig.LocalVariable ();
            lv.ByRef = false;
            int cursor;
            while (true) {
                lv.CustomMods = ReadCustomMods (data, start, out start);
                cursor = start;
                int current = Utilities.ReadCompressedInteger (data, start, out start);
                if (current == (int) ElementType.Pinned) // the only possible constraint
                    lv.Constraint |= Constraint.Pinned;
                else if (current == (int) ElementType.ByRef) {
                    lv.ByRef = true;

                    if (lv.CustomMods == null || lv.CustomMods.Length == 0)
                        lv.CustomMods = ReadCustomMods (data, start, out start);
                } else {
                    lv.Type = ReadType (data, cursor, out start);
                    break;
                }
            }
            return lv;
        }