当前位置: 首页>>代码示例>>C#>>正文


C# Cecil.ArrayType类代码示例

本文整理汇总了C#中Mono.Cecil.ArrayType的典型用法代码示例。如果您正苦于以下问题:C# ArrayType类的具体用法?C# ArrayType怎么用?C# ArrayType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ArrayType类属于Mono.Cecil命名空间,在下文中一共展示了ArrayType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsEqualTo

 public static bool IsEqualTo(this ArrayType a, ArrayType b)
 {
     if (a.Rank != b.Rank) {
         return false;
     }
     return true;
 }
开发者ID:arcanedreams,项目名称:Piranha,代码行数:7,代码来源:ComparisonExtensions.cs

示例2: updateArrayType

 protected virtual ArrayType updateArrayType(ArrayType a)
 {
     var rv = new ArrayType(update(a.ElementType));
     if (!a.IsVector) {
         foreach (var dim in a.Dimensions)
             rv.Dimensions.Add(dim);
     }
     return rv;
 }
开发者ID:n017,项目名称:NETDeob,代码行数:9,代码来源:TypeReferenceUpdaterBase.cs

示例3: AreSame

        internal bool AreSame(ArrayType a, ArrayType b)
        {
            if (a.Rank != b.Rank)
                return false;

            // TODO: dimensions

            return true;
        }
开发者ID:jinjingcai2014,项目名称:il-repack,代码行数:9,代码来源:ReflectionHelper.cs

示例4: TransformArrayInitializers

		bool TransformArrayInitializers(List<ILNode> body, ILExpression expr, int pos)
		{
			ILVariable v, v3;
			ILExpression newarrExpr;
			TypeReference elementType;
			ILExpression lengthExpr;
			int arrayLength;
			if (expr.Match(ILCode.Stloc, out v, out newarrExpr) &&
			    newarrExpr.Match(ILCode.Newarr, out elementType, out lengthExpr) &&
			    lengthExpr.Match(ILCode.Ldc_I4, out arrayLength) &&
			    arrayLength > 0) {
				ILExpression[] newArr;
				int initArrayPos;
				if (ForwardScanInitializeArrayRuntimeHelper(body, pos + 1, v, elementType, arrayLength, out newArr, out initArrayPos)) {
					var arrayType = new ArrayType(elementType, 1);
					arrayType.Dimensions[0] = new ArrayDimension(0, arrayLength);
					body[pos] = new ILExpression(ILCode.Stloc, v, new ILExpression(ILCode.InitArray, arrayType, newArr));
					body.RemoveAt(initArrayPos);
				}
				// Put in a limit so that we don't consume too much memory if the code allocates a huge array
				// and populates it extremely sparsly. However, 255 "null" elements in a row actually occur in the Mono C# compiler!
				const int maxConsecutiveDefaultValueExpressions = 300;
				List<ILExpression> operands = new List<ILExpression>();
				int numberOfInstructionsToRemove = 0;
				for (int j = pos + 1; j < body.Count; j++) {
					ILExpression nextExpr = body[j] as ILExpression;
					int arrayPos;
					if (nextExpr != null &&
					    nextExpr.Code.IsStoreToArray() &&
					    nextExpr.Arguments[0].Match(ILCode.Ldloc, out v3) &&
					    v == v3 &&
					    nextExpr.Arguments[1].Match(ILCode.Ldc_I4, out arrayPos) &&
					    arrayPos >= operands.Count &&
					    arrayPos <= operands.Count + maxConsecutiveDefaultValueExpressions) {
						while (operands.Count < arrayPos)
							operands.Add(new ILExpression(ILCode.DefaultValue, elementType));
						operands.Add(nextExpr.Arguments[2]);
						numberOfInstructionsToRemove++;
					} else {
						break;
					}
				}
				if (operands.Count == arrayLength) {
					var arrayType = new ArrayType(elementType, 1);
					arrayType.Dimensions[0] = new ArrayDimension(0, arrayLength);
					expr.Arguments[0] = new ILExpression(ILCode.InitArray, arrayType, operands);
					body.RemoveRange(pos + 1, numberOfInstructionsToRemove);

					new ILInlining(method).InlineIfPossible(body, ref pos);
					return true;
				}
			}
			return false;
		}
开发者ID:ALyman,项目名称:ILSpy,代码行数:54,代码来源:InitializerPeepholeTransforms.cs

示例5: WriteArrayDataValue

 private string WriteArrayDataValue(ArrayType arrayType)
 {
     base.Writer.WriteExternForIl2CppType(arrayType.ElementType);
     if (arrayType.Rank == 1)
     {
         return ("(void*)&" + MetadataWriter.Naming.ForIl2CppType(arrayType.ElementType, 0));
     }
     object[] args = new object[] { MetadataWriter.Naming.ForArrayType(arrayType) };
     base.WriteLine("Il2CppArrayType {0} = ", args);
     string[] initializers = new string[] { string.Format("&{0}", MetadataWriter.Naming.ForIl2CppType(arrayType.ElementType, 0)), arrayType.Rank.ToString(), 0.ToString(), 0.ToString(), MetadataWriter.Naming.Null, MetadataWriter.Naming.Null };
     base.WriteArrayInitializer(initializers, MetadataWriter.ArrayTerminator.None);
     return ("&" + MetadataWriter.Naming.ForArrayType(arrayType));
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:13,代码来源:Il2CppTypeWriter.cs

示例6: ArrayTypeEquality

        public void ArrayTypeEquality () {
            var at1 = new ArrayType(T1);
            var at2 = new ArrayType(T2);
            var at3 = new ArrayType(T3);
            var at4 = new ArrayType(T1, 2);

            Assert.IsFalse(TypeUtil.TypesAreEqual(at1, T1));

            Assert.IsFalse(TypeUtil.TypesAreEqual(at1, T1));
            Assert.IsTrue(TypeUtil.TypesAreEqual(at1, at1));
            Assert.IsFalse(TypeUtil.TypesAreEqual(at1, at2));
            Assert.IsFalse(TypeUtil.TypesAreEqual(at1, at3));

            Assert.IsFalse(TypeUtil.TypesAreEqual(at1, at4, true));
            Assert.IsFalse(TypeUtil.TypesAreEqual(at1, at4, false));
        }
开发者ID:GlennSandoval,项目名称:JSIL,代码行数:16,代码来源:APITests.cs

示例7: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            var args = new[] { Parameters.Count == 1 ? typeof(object) : typeof(IEnumerable<dynamic>), typeof(bool) };
              var printMethod = emitter.AssemblyImport(typeof(MirelleStdlib.Printer).GetMethod("Print", args));

              if (Parameters.Count == 1)
              {
            var currType = Parameters[0].GetExpressionType(emitter);
            Parameters[0].Compile(emitter);
            if (currType.IsAnyOf("int", "bool", "float", "complex"))
              emitter.EmitBox(emitter.ResolveType(currType));
              }
              else
              {
            var objType = emitter.AssemblyImport(typeof(object));
            var arrType = new ArrayType(objType);

            var tmpVariable = emitter.CurrentMethod.Scope.Introduce("object[]", arrType);

            // load count & create
            emitter.EmitLoadInt(Parameters.Count);
            emitter.EmitNewArray(objType);
            emitter.EmitSaveVariable(tmpVariable);

            int idx = 0;
            foreach (var curr in Parameters)
            {
              var currType = curr.GetExpressionType(emitter);
              emitter.EmitLoadVariable(tmpVariable);
              emitter.EmitLoadInt(idx);
              curr.Compile(emitter);

              if (currType.IsAnyOf("int", "bool", "float", "complex"))
            emitter.EmitBox(emitter.ResolveType(currType));

              emitter.EmitSaveIndex("object");

              idx++;
            }

            // return the created array
            emitter.EmitLoadVariable(tmpVariable);
              }

              emitter.EmitLoadBool(PrintLine);
              emitter.EmitCall(printMethod);
        }
开发者ID:menozz,项目名称:mirelle,代码行数:47,代码来源:PrintNode.cs

示例8: ComSafeArrayMarshalInfoWriter

 public ComSafeArrayMarshalInfoWriter(ArrayType type, MarshalInfo marshalInfo) : base(type)
 {
     this._elementType = type.ElementType;
     this._marshalInfo = marshalInfo as SafeArrayMarshalInfo;
     if (this._marshalInfo == null)
     {
         throw new InvalidOperationException(string.Format("SafeArray type '{0}' has invalid MarshalAsAttribute.", type.FullName));
     }
     if ((this._marshalInfo.ElementType == VariantType.BStr) && (this._elementType.MetadataType != MetadataType.String))
     {
         throw new InvalidOperationException(string.Format("SafeArray(BSTR) type '{0}' has invalid MarshalAsAttribute.", type.FullName));
     }
     NativeType nativeElementType = this.GetNativeElementType();
     this._elementTypeMarshalInfoWriter = MarshalDataCollector.MarshalInfoWriterFor(this._elementType, MarshalType.COM, new MarshalInfo(nativeElementType), false, false, false, null);
     string name = string.Format("Il2CppSafeArray/*{0}*/*", this._marshalInfo.ElementType.ToString().ToUpper());
     this._marshaledTypes = new MarshaledType[] { new MarshaledType(name, name) };
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:17,代码来源:ComSafeArrayMarshalInfoWriter.cs

示例9: GetTypeSpec

		TypeSpecification GetTypeSpec (TypeSpecification original, ImportContext context)
		{
			TypeSpecification typeSpec;

			TypeReference elementType = ImportTypeReference (original.ElementType, context);
			if (original is PointerType) {
				typeSpec = new PointerType (elementType);
			} else if (original is ArrayType) { // deal with complex arrays
				typeSpec = new ArrayType (elementType);
			} else if (original is ReferenceType) {
				typeSpec = new ReferenceType (elementType);
			} else if (original is GenericInstanceType) {
				GenericInstanceType git = original as GenericInstanceType;
				GenericInstanceType genElemType = new GenericInstanceType (elementType);

				context.GenericContext.CheckProvider (genElemType.GetOriginalType (), git.GenericArguments.Count);
				foreach (TypeReference arg in git.GenericArguments)
					genElemType.GenericArguments.Add (ImportTypeReference (arg, context));

				typeSpec = genElemType;
			} else if (original is ModifierOptional) {
				TypeReference mt = (original as ModifierOptional).ModifierType;
				typeSpec = new ModifierOptional (elementType, ImportTypeReference (mt, context));
			} else if (original is ModifierRequired) {
				TypeReference mt = (original as ModifierRequired).ModifierType;
				typeSpec = new ModifierRequired (elementType, ImportTypeReference (mt, context));
			} else if (original is SentinelType) {
				typeSpec = new SentinelType (elementType);
			} else if (original is FunctionPointerType) {
				FunctionPointerType ori = original as FunctionPointerType;

				FunctionPointerType fnptr = new FunctionPointerType (
					ori.HasThis,
					ori.ExplicitThis,
					ori.CallingConvention,
					new MethodReturnType (ImportTypeReference (ori.ReturnType.ReturnType, context)));

				foreach (ParameterDefinition parameter in ori.Parameters)
					fnptr.Parameters.Add (new ParameterDefinition (ImportTypeReference (parameter.ParameterType, context)));

				typeSpec = fnptr;
			} else
				throw new ReflectionException ("Unknown element type: {0}", original.GetType ().Name);

			return typeSpec;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:46,代码来源:DefaultImporter.cs

示例10: FixPlatformVersion

        public TypeReference FixPlatformVersion(TypeReference reference)
        {
            if (targetPlatformDirectory == null)
                return reference;

            AssemblyNameReference scopeAsm = reference.Scope as AssemblyNameReference;
            if (scopeAsm != null)
            {
                AssemblyDefinition platformAsm = TryGetPlatformAssembly(scopeAsm);
                if (platformAsm != null)
                {
                    TypeReference newTypeRef;
                    if (reference is TypeSpecification)
                    {
                        TypeSpecification refSpec = reference as TypeSpecification;
                        TypeReference fet = FixPlatformVersion(refSpec.ElementType);
                        if (reference is ArrayType)
                        {
                            var array = (ArrayType)reference;
                            var imported_array = new ArrayType(fet);
                            if (array.IsVector)
                                return imported_array;

                            var dimensions = array.Dimensions;
                            var imported_dimensions = imported_array.Dimensions;

                            imported_dimensions.Clear();

                            for (int i = 0; i < dimensions.Count; i++)
                            {
                                var dimension = dimensions[i];

                                imported_dimensions.Add(new ArrayDimension(dimension.LowerBound, dimension.UpperBound));
                            }

                            return imported_array;
                        }
                        else if (reference is PointerType)
                            return new PointerType(fet);
                        else if (reference is ByReferenceType)
                            return new ByReferenceType(fet);
                        else if (reference is PinnedType)
                            return new PinnedType(fet);
                        else if (reference is SentinelType)
                            return new SentinelType(fet);
                        else if (reference is OptionalModifierType)
                            return new OptionalModifierType(FixPlatformVersion(((OptionalModifierType)reference).ModifierType), fet);
                        else if (reference is RequiredModifierType)
                            return new RequiredModifierType(FixPlatformVersion(((RequiredModifierType)reference).ModifierType), fet);
                        else if (reference is GenericInstanceType)
                        {
                            var instance = (GenericInstanceType)reference;
                            var element_type = FixPlatformVersion(instance.ElementType);
                            var imported_instance = new GenericInstanceType(element_type);

                            var arguments = instance.GenericArguments;
                            var imported_arguments = imported_instance.GenericArguments;

                            for (int i = 0; i < arguments.Count; i++)
                                imported_arguments.Add(FixPlatformVersion(arguments[i]));

                            return imported_instance;
                        }
                        else if (reference is FunctionPointerType)
                            throw new NotImplementedException();
                        else
                            throw new InvalidOperationException();
                    }
                    else
                    {
                        newTypeRef = new TypeReference(reference.Namespace, reference.Name, reference.Module,
                            platformAsm.Name);
                    }
                    foreach (var gp in reference.GenericParameters)
                        newTypeRef.GenericParameters.Add(FixPlatformVersion(gp, newTypeRef));
                    newTypeRef.IsValueType = reference.IsValueType;
                    if (reference.DeclaringType != null)
                        newTypeRef.DeclaringType = FixPlatformVersion(reference.DeclaringType);
                    return newTypeRef;
                }
            }
            return reference;
        }
开发者ID:Fininvest,项目名称:il-repack,代码行数:83,代码来源:PlatformFixer.cs

示例11: VerifyIsConstrainedToNSObject

        protected override bool VerifyIsConstrainedToNSObject(TypeReference type, out TypeReference constrained_type)
        {
            constrained_type = null;

            var gp = type as GenericParameter;
            if (gp != null) {
                if (!gp.HasConstraints)
                    return false;
                foreach (var c in gp.Constraints) {
                    if (IsNSObject (c)) {
                        constrained_type = c;
                        return true;
                    }
                }
                return false;
            }

            var git = type as GenericInstanceType;
            if (git != null) {
                var rv = true;
                if (git.HasGenericArguments) {
                    var newGit = new GenericInstanceType (git.ElementType);
                    for (int i = 0; i < git.GenericArguments.Count; i++) {
                        TypeReference constr;
                        rv &= VerifyIsConstrainedToNSObject (git.GenericArguments [i], out constr);
                        newGit.GenericArguments.Add (constr ?? git.GenericArguments [i]);
                    }
                    constrained_type = newGit;
                }
                return rv;
            }

            var el = type as ArrayType;
            if (el != null) {
                var rv = VerifyIsConstrainedToNSObject (el.ElementType, out constrained_type);
                if (constrained_type == null)
                    return rv;
                constrained_type = new ArrayType (constrained_type, el.Rank);
                return rv;
            }

            var rt = type as ByReferenceType;
            if (rt != null) {
                var rv = VerifyIsConstrainedToNSObject (rt.ElementType, out constrained_type);
                if (constrained_type == null)
                    return rv;
                constrained_type = new ByReferenceType (constrained_type);
                return rv;
            }

            var tr = type as PointerType;
            if (tr != null) {
                var rv = VerifyIsConstrainedToNSObject (tr.ElementType, out constrained_type);
                if (constrained_type == null)
                    return rv;
                constrained_type = new PointerType (constrained_type);
                return rv;
            }

            return true;
        }
开发者ID:yudhitech,项目名称:xamarin-macios,代码行数:61,代码来源:StaticRegistrar.cs

示例12: ImportStilettoReferences

        private void ImportStilettoReferences(ModuleDefinition module, StilettoReferences stilettoReferences)
        {
            Binding = module.Import(stilettoReferences.Binding);
            Binding_Ctor = module.Import(stilettoReferences.Binding_Ctor);
            Binding_GetDependencies = module.Import(stilettoReferences.Binding_GetDependencies);
            Binding_Resolve = module.Import(stilettoReferences.Binding_Resolve);
            Binding_Get = module.Import(stilettoReferences.Binding_Get);
            Binding_InjectProperties = module.Import(stilettoReferences.Binding_InjectProperties);
            Binding_RequiredByGetter = module.Import(stilettoReferences.Binding_RequiredBy_Getter);
            Binding_IsLibrarySetter = module.Import(stilettoReferences.Binding_IsLibrary_Setter);

            BindingArray = new ArrayType(Binding);

            ProviderMethodBindingBase = module.Import(stilettoReferences.ProviderMethodBindingBase);
            ProviderMethodBindingBase_Ctor = module.Import(stilettoReferences.ProviderMethodBindingBase_Ctor);

            RuntimeModule = module.Import(stilettoReferences.RuntimeModule);
            RuntimeModule_Ctor = module.Import(stilettoReferences.RuntimeModule_Ctor);
            RuntimeModule_ModuleGetter = module.Import(stilettoReferences.RuntimeModule_Module_Getter);

            Container = module.Import(stilettoReferences.Container);
            Container_Create = module.Import(stilettoReferences.Container_Create);
            Container_CreateWithPlugins = module.Import(stilettoReferences.Container_CreateWithPlugins);

            IPlugin = module.Import(stilettoReferences.IPlugin);
            IPlugin_GetInjectBinding = module.Import(stilettoReferences.IPlugin_GetInjectBinding);
            IPlugin_GetLazyInjectBinding = module.Import(stilettoReferences.IPlugin_GetLazyInjectBinding);
            IPlugin_GetIProviderInjectBinding = module.Import(stilettoReferences.IPlugin_GetIProviderInjectBinding);
            IPlugin_GetRuntimeModue = module.Import(stilettoReferences.IPlugin_GetRuntimeModue);

            IProviderOfT = module.Import(stilettoReferences.IProviderOfT);
            IProviderOfT_Get = module.Import(stilettoReferences.IProviderOfT_Get);

            Resolver = module.Import(stilettoReferences.Resolver);
            Resolver_RequestBinding = module.Import(stilettoReferences.Resolver_RequestBinding);

            InjectAttribute = module.Import(stilettoReferences.InjectAttribute);
            ModuleAttribute = module.Import(stilettoReferences.ModuleAttribute);
            ProvidesAttribute = module.Import(stilettoReferences.ProvidesAttribute);
            NamedAttribute = module.Import(stilettoReferences.NamedAttribute);
            SingletonAttribute = module.Import(stilettoReferences.SingletonAttribute);

            ProcessedAssemblyAttribute = module.Import(stilettoReferences.ProcessedAssemblyAttribute);
            ProcessedAssemblyAttribute_Ctor = module.Import(stilettoReferences.ProcessedAssemblyAttribute_Ctor);
        }
开发者ID:paulcbetts,项目名称:stiletto,代码行数:45,代码来源:References.cs

示例13: ImportTypeSpecification

        TypeReference ImportTypeSpecification(TypeReference type, ImportGenericContext context)
        {
            switch (type.etype) {
            case ElementType.SzArray:
                var vector = (ArrayType) type;
                return new ArrayType (ImportType (vector.ElementType, context));
            case ElementType.Ptr:
                var pointer = (PointerType) type;
                return new PointerType (ImportType (pointer.ElementType, context));
            case ElementType.ByRef:
                var byref = (ByReferenceType) type;
                return new ByReferenceType (ImportType (byref.ElementType, context));
            case ElementType.Pinned:
                var pinned = (PinnedType) type;
                return new PinnedType (ImportType (pinned.ElementType, context));
            case ElementType.Sentinel:
                var sentinel = (SentinelType) type;
                return new SentinelType (ImportType (sentinel.ElementType, context));
            case ElementType.CModOpt:
                var modopt = (OptionalModifierType) type;
                return new OptionalModifierType (
                    ImportType (modopt.ModifierType, context),
                    ImportType (modopt.ElementType, context));
            case ElementType.CModReqD:
                var modreq = (RequiredModifierType) type;
                return new RequiredModifierType (
                    ImportType (modreq.ModifierType, context),
                    ImportType (modreq.ElementType, context));
            case ElementType.Array:
                var array = (ArrayType) type;
                var imported_array = new ArrayType (ImportType (array.ElementType, context));
                if (array.IsVector)
                    return imported_array;

                var dimensions = array.Dimensions;
                var imported_dimensions = imported_array.Dimensions;

                imported_dimensions.Clear ();

                for (int i = 0; i < dimensions.Count; i++) {
                    var dimension = dimensions [i];

                    imported_dimensions.Add (new ArrayDimension (dimension.LowerBound, dimension.UpperBound));
                }

                return imported_array;
            case ElementType.GenericInst:
                var instance = (GenericInstanceType) type;
                var element_type = ImportType (instance.ElementType, context);
                var imported_instance = new GenericInstanceType (element_type);

                var arguments = instance.GenericArguments;
                var imported_arguments = imported_instance.GenericArguments;

                for (int i = 0; i < arguments.Count; i++)
                    imported_arguments.Add (ImportType (arguments [i], context));

                return imported_instance;
            case ElementType.Var:
                var var_parameter = (GenericParameter) type;
                return context.TypeParameter (type.DeclaringType.FullName, var_parameter.Position);
            case ElementType.MVar:
                var mvar_parameter = (GenericParameter) type;
                return context.MethodParameter (mvar_parameter.DeclaringMethod.Name, mvar_parameter.Position);
            case ElementType.FnPtr:
                var funcPtr = (FunctionPointerType)type;
                var imported = new FunctionPointerType() {
                    HasThis = funcPtr.HasThis,
                    ExplicitThis = funcPtr.ExplicitThis,
                    CallingConvention = funcPtr.CallingConvention,
                    ReturnType = ImportType (funcPtr.ReturnType, context)
                };
                var parameters = funcPtr.Parameters;
                for (int i = 0; i < parameters.Count; i++)
                    imported.Parameters.Add(
                        new ParameterDefinition (ImportType (parameters [i].ParameterType, context)));
                return imported;
            }

            throw new NotSupportedException (type.etype.ToString ());
        }
开发者ID:KonajuGames,项目名称:cecil,代码行数:81,代码来源:Import.cs

示例14: ReplaceWhileLoopAndEnumerator

        private JSForLoop ReplaceWhileLoopAndEnumerator(JSWhileLoop wl, JSExpression backingStore, JSExpression enumerator, TypeInfo enumeratorType, string arrayMember, string lengthMember)
        {
            var loopId = _NextLoopId++;
            var arrayVariableName = String.Format("a${0:x}", loopId);
            var indexVariableName = String.Format("i${0:x}", loopId);
            var lengthVariableName = String.Format("l${0:x}", loopId);

            var currentPropertyReference = enumeratorType.Definition.Properties.First((p) => p.Name == "Current");
            var currentPropertyInfo = enumeratorType.Source.GetProperty(currentPropertyReference);

            var itemType = currentPropertyInfo.ReturnType;
            var arrayType = new ArrayType(itemType);

            var arrayVariable = new JSVariable(
                arrayVariableName, arrayType, Function.Method.Reference,
                JSDotExpression.New(backingStore, new JSStringIdentifier(arrayMember, arrayType))
            );
            var indexVariable = new JSVariable(
                indexVariableName, TypeSystem.Int32, Function.Method.Reference,
                JSLiteral.New(0)
            );
            var lengthVariable = new JSVariable(
                lengthVariableName, TypeSystem.Int32, Function.Method.Reference,
                JSDotExpression.New(backingStore, new JSStringIdentifier(lengthMember, TypeSystem.Int32))
            );

            var initializer = new JSVariableDeclarationStatement(
                new JSBinaryOperatorExpression(
                    JSOperator.Assignment, arrayVariable, arrayVariable.DefaultValue, arrayVariable.IdentifierType
                ),
                new JSBinaryOperatorExpression(
                    JSOperator.Assignment, indexVariable, indexVariable.DefaultValue, indexVariable.IdentifierType
                ),
                new JSBinaryOperatorExpression(
                    JSOperator.Assignment, lengthVariable, lengthVariable.DefaultValue, lengthVariable.IdentifierType
                )
            );

            var condition = new JSBinaryOperatorExpression(
                JSBinaryOperator.LessThan,
                indexVariable, lengthVariable, TypeSystem.Boolean
            );

            var increment = new JSUnaryOperatorExpression(
                JSUnaryOperator.PostIncrement,
                indexVariable, TypeSystem.Int32
            );

            var result = new JSForLoop(
                initializer, condition, new JSExpressionStatement(increment),
                wl.Statements.ToArray()
            );
            result.Index = wl.Index;

            new PropertyAccessReplacer(
                enumerator, new JSProperty(currentPropertyReference, currentPropertyInfo),
                new JSIndexerExpression(
                    arrayVariable, indexVariable,
                    itemType
                )
            ).Visit(result);

            return result;
        }
开发者ID:poizan42,项目名称:JSIL,代码行数:64,代码来源:OptimizeArrayEnumerators.cs

示例15: GetTypeRefFromSig

        public TypeReference GetTypeRefFromSig(SigType t, GenericContext context)
        {
            switch (t.ElementType) {
            case ElementType.Class :
                CLASS c = t as CLASS;
                return GetTypeDefOrRef (c.Type, context);
            case ElementType.ValueType :
                VALUETYPE vt = t as VALUETYPE;
                TypeReference vtr = GetTypeDefOrRef (vt.Type, context);
                vtr.IsValueType = true;
                return vtr;
            case ElementType.String :
                return SearchCoreType (Constants.String);
            case ElementType.Object :
                return SearchCoreType (Constants.Object);
            case ElementType.Void :
                return SearchCoreType (Constants.Void);
            case ElementType.Boolean :
                return SearchCoreType (Constants.Boolean);
            case ElementType.Char :
                return SearchCoreType (Constants.Char);
            case ElementType.I1 :
                return SearchCoreType (Constants.SByte);
            case ElementType.U1 :
                return SearchCoreType (Constants.Byte);
            case ElementType.I2 :
                return SearchCoreType (Constants.Int16);
            case ElementType.U2 :
                return SearchCoreType (Constants.UInt16);
            case ElementType.I4 :
                return SearchCoreType (Constants.Int32);
            case ElementType.U4 :
                return SearchCoreType (Constants.UInt32);
            case ElementType.I8 :
                return SearchCoreType (Constants.Int64);
            case ElementType.U8 :
                return SearchCoreType (Constants.UInt64);
            case ElementType.R4 :
                return SearchCoreType (Constants.Single);
            case ElementType.R8 :
                return SearchCoreType (Constants.Double);
            case ElementType.I :
                return SearchCoreType (Constants.IntPtr);
            case ElementType.U :
                return SearchCoreType (Constants.UIntPtr);
            case ElementType.TypedByRef :
                return SearchCoreType (Constants.TypedReference);
            case ElementType.Array :
                ARRAY ary = t as ARRAY;
                return new ArrayType (GetTypeRefFromSig (ary.Type, context), ary.Shape);
            case ElementType.SzArray :
                SZARRAY szary = t as SZARRAY;
                ArrayType at = new ArrayType (GetTypeRefFromSig (szary.Type, context));
                return at;
            case ElementType.Ptr :
                PTR pointer = t as PTR;
                if (pointer.Void)
                    return new PointerType (SearchCoreType (Constants.Void));
                return new PointerType (GetTypeRefFromSig (pointer.PtrType, context));
            case ElementType.FnPtr :
                FNPTR funcptr = t as FNPTR;
                FunctionPointerType fnptr = new FunctionPointerType (funcptr.Method.HasThis, funcptr.Method.ExplicitThis,
                    funcptr.Method.MethCallConv, GetMethodReturnType (funcptr.Method, context));

                for (int i = 0; i < funcptr.Method.ParamCount; i++) {
                    Param p = funcptr.Method.Parameters [i];
                    fnptr.Parameters.Add (BuildParameterDefinition (i, p, context));
                }

                CreateSentinelIfNeeded (fnptr, funcptr.Method);

                return fnptr;
            case ElementType.Var:
                VAR var = t as VAR;
                context.CheckProvider (context.Type, var.Index + 1);

                if (context.Type is GenericInstanceType)
                    return (context.Type as GenericInstanceType).GenericArguments [var.Index];
                else
                    return context.Type.GenericParameters [var.Index];
            case ElementType.MVar:
                MVAR mvar = t as MVAR;
                context.CheckProvider (context.Method, mvar.Index + 1);

                if (context.Method is GenericInstanceMethod)
                    return (context.Method as GenericInstanceMethod).GenericArguments [mvar.Index];
                else
                    return context.Method.GenericParameters [mvar.Index];
            case ElementType.GenericInst:
                GENERICINST ginst = t as GENERICINST;
                GenericInstanceType instance = new GenericInstanceType (GetTypeDefOrRef (ginst.Type, context));
                instance.IsValueType = ginst.ValueType;
                context.CheckProvider (instance.GetOriginalType (), ginst.Signature.Arity);

                for (int i = 0; i < ginst.Signature.Arity; i++)
                    instance.GenericArguments.Add (GetGenericArg (
                        ginst.Signature.Types [i], context));

                return instance;
            default:
//.........这里部分代码省略.........
开发者ID:contra,项目名称:DotNOS,代码行数:101,代码来源:ReflectionReader.cs


注:本文中的Mono.Cecil.ArrayType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。