Ejemplo n.º 1
0
        private LinkerSymbol CreateParameterDefinition(MosaParameter parameter)
        {
            // Emit parameter name
            var parameterNameSymbol = EmitStringWithLength(Metadata.NameString + parameter, parameter.FullName);

            // Emit parameter table
            var parameterTableSymbol = Linker.DefineSymbol(Metadata.MethodDefinition + parameter.FullName, SectionKind.ROData, TypeLayout.NativePointerAlignment, 0);
            var writer = new EndianAwareBinaryWriter(parameterTableSymbol.Stream, Architecture.Endianness);

            // 1. Pointer to Name
            Linker.Link(LinkType.AbsoluteAddress, NativePatchType, parameterTableSymbol, writer.Position, parameterNameSymbol, 0);
            writer.WriteZeroBytes(TypeLayout.NativePointerSize);

            // 2. Pointer to Custom Attributes
            if (parameter.CustomAttributes.Count > 0)
            {
                var customAttributeListSymbol = CreateCustomAttributesTable(parameter);
                Linker.Link(LinkType.AbsoluteAddress, NativePatchType, parameterTableSymbol, writer.Position, customAttributeListSymbol, 0);
            }
            writer.WriteZeroBytes(TypeLayout.NativePointerSize);

            // 3. Attributes
            writer.Write((uint)parameter.ParameterAttributes, TypeLayout.NativePointerSize);

            // 4. Pointer to Parameter Type
            Linker.Link(LinkType.AbsoluteAddress, NativePatchType, parameterTableSymbol, writer.Position, Metadata.TypeDefinition + parameter.ParameterType.FullName, 0);
            writer.WriteZeroBytes(TypeLayout.NativePointerSize);

            return(parameterTableSymbol);
        }
Ejemplo n.º 2
0
        private LinkerSymbol CreateParameterDefinition(MosaParameter parameter)
        {
            // Emit parameter name
            var parameterNameSymbol = EmitStringWithLength(parameter + Metadata.NameString, parameter.FullName);

            // Emit parameter table
            var parameterTableSymbol = Linker.CreateSymbol(parameter.FullName + Metadata.MethodDefinition, SectionKind.ROData, TypeLayout.NativePointerAlignment, 0);
            var writer1 = new EndianAwareBinaryWriter(parameterTableSymbol.Stream, Architecture.Endianness);

            // 1. Pointer to Name
            Linker.Link(LinkType.AbsoluteAddress, NativePatchType, parameterTableSymbol, (int)writer1.Position, 0, parameterNameSymbol, 0);
            writer1.WriteZeroBytes(TypeLayout.NativePointerSize);

            // 2. Pointer to Custom Attributes
            if (parameter.CustomAttributes.Count > 0)
            {
                var customAttributeListSymbol = CreateCustomAttributesTable(parameter);
                Linker.Link(LinkType.AbsoluteAddress, NativePatchType, parameterTableSymbol, (int)writer1.Position, 0, customAttributeListSymbol, 0);
            }
            writer1.WriteZeroBytes(TypeLayout.NativePointerSize);

            // 3. Attributes
            writer1.Write((uint)parameter.ParameterAttributes, TypeLayout.NativePointerSize);

            // 4. Pointer to Parameter Type
            Linker.Link(LinkType.AbsoluteAddress, NativePatchType, parameterTableSymbol, (int)writer1.Position, 0, parameter.ParameterType.FullName + Metadata.TypeDefinition, SectionKind.ROData, 0);
            writer1.WriteZeroBytes(TypeLayout.NativePointerSize);

            // Return parameterTableSymbol for linker usage
            return parameterTableSymbol;
        }
Ejemplo n.º 3
0
 public MosaParameter.Mutator MutateParameter(MosaParameter Parameter)
 {
     return new MosaParameter.Mutator(Parameter);
 }
Ejemplo n.º 4
0
 public MosaParameter CreateParameter(MosaParameter source = null)
 {
     if (source == null)
     {
         return new MosaParameter()
         {
             ID = id++,
             TypeSystem = typeSystem
         };
     }
     else
     {
         MosaParameter result = source.Clone();
         result.ID = id++;
         return result;
     }
 }