예제 #1
0
        public virtual void Visit(IType type)
        {
            IArrayType arrayType = type as IArrayType;

            if (arrayType != null)
            {
                VisitArrayType(arrayType);
            }

            if (type.IsByRef)
            {
                VisitByRefType(type);
            }

            if (type.ConstructedInfo != null)
            {
                VisitConstructedType(type);
            }

            ICallableType callableType = type as ICallableType;

            if (callableType != null)
            {
                VisitCallableType(callableType);
            }
        }
 public ArrayElementValueIterator(IArrayValue arrayValue)
 {
     this._arrayValue = arrayValue;
     this._array      = (IArrayInstance)arrayValue.Symbol;
     this._type       = (IArrayType)arrayValue.DataType;
     this._indexIter  = new ArrayIndexIterator(this._type);
 }
예제 #3
0
 public bool TryGetInstance(string instancePath, out ISymbol symbol)
 {
     symbol = null;
     if (instancePath.StartsWith(this._arrayInstance.InstancePath, StringComparison.OrdinalIgnoreCase))
     {
         SymbolParser.ArrayIndexType type;
         IList <int[]> jaggedIndices = null;
         if (SymbolParser.TryParseIndices(instancePath.Substring(this._arrayInstance.InstancePath.Length), out jaggedIndices, out type))
         {
             if (this.IsOversampled && ArrayIndexConverter.IsOversamplingIndex(jaggedIndices[0], this._arrayType))
             {
                 symbol = ((ISymbolFactoryOversampled)this._symbolFactory).CreateOversamplingElement(this._arrayInstance);
             }
             else
             {
                 ISymbol    parent    = this._arrayInstance;
                 IArrayType arrayType = this._arrayType;
                 for (int i = 0; i < jaggedIndices.Count; i++)
                 {
                     symbol    = this._symbolFactory.CreateArrayElement(jaggedIndices[i], parent, arrayType);
                     parent    = symbol;
                     arrayType = symbol.DataType as IArrayType;
                 }
             }
             return(true);
         }
     }
     return(false);
 }
예제 #4
0
        public bool TryGetInstanceByName(string instanceNameWithIndices, out IList <ISymbol> symbols)
        {
            ISymbol item = null;
            string  str;

            SymbolParser.ArrayIndexType type;
            IList <int[]> list;

            symbols = new List <ISymbol>();
            string indicesStr = null;

            if (SymbolParser.TryParseArrayElement(instanceNameWithIndices, out str, out indicesStr, out list, out type) && (StringComparer.OrdinalIgnoreCase.Compare(str, this._arrayInstance.InstanceName) == 0))
            {
                ISymbol    parent    = this._arrayInstance;
                IArrayType arrayType = this._arrayType;
                for (int i = 0; i < list.Count; i++)
                {
                    item      = this._symbolFactory.CreateArrayElement(list[i], parent, arrayType);
                    parent    = item;
                    arrayType = parent.DataType as IArrayType;
                }
            }
            if (item != null)
            {
                symbols.Add(item);
            }
            return(symbols.Count > 0);
        }
예제 #5
0
        private static IArrayCreationExpression CreateArrayCreationExpression(IType elementType, CSharpElementFactory factory)
        {
            IArrayCreationExpression expression = (IArrayCreationExpression)factory.CreateExpression("new[]{}", new object[0]);
            IArrayType arrayType = TypeFactory.CreateArrayType(elementType, 1, null);

            return(factory.CreateArrayCreationExpression(arrayType, expression.ArrayInitializer));
        }
예제 #6
0
        public virtual void Visit(IType type)
        {
            IArrayType arrayType = type as IArrayType;

            if (arrayType != null)
            {
                VisitArrayType(arrayType);
            }

            if (type.IsByRef)
            {
                VisitByRefType(type);
            }

            if (type.ConstructedInfo != null)
            {
                VisitConstructedType(type);
            }
            else if (type.GenericInfo != null)
            {
                foreach (var gp in type.GenericInfo.GenericParameters)
                {
                    Visit(gp);
                }
            }

            ICallableType callableType = type as ICallableType;

            if (callableType != null)
            {
                VisitCallableType(callableType);
            }
        }
예제 #7
0
        internal static void CheckIndices(int[] indices, IArrayType arrayType, bool acceptOversampled)
        {
            IOversamplingSupport support = arrayType as IOversamplingSupport;
            bool flag = ((support != null) && support.IsOversampled) & acceptOversampled;

            ArrayIndexConverter.CheckIndices(indices, arrayType.Dimensions.LowerBounds, arrayType.Dimensions.UpperBounds, false, acceptOversampled);
        }
예제 #8
0
        private static ITypeName GetName(this IArrayType arrayType,
                                         IDictionary <DeclaredElementInstance, IName> seenElements)
        {
            var baseType = arrayType.ElementType.GetName(seenElements);

            return(Names.ArrayType(arrayType.Rank, baseType));
        }
예제 #9
0
        private Array createPrimitiveValueArray(IArrayInstance arraySymbol, byte[] rawData, int offset, DateTime utcReadTime)
        {
            Array           array       = null;
            IArrayType      dataType    = (IArrayType)arraySymbol.DataType;
            IDataType       elementType = dataType.ElementType;
            IResolvableType type3       = elementType as IResolvableType;

            if (type3 != null)
            {
                elementType = type3.ResolveType(DataTypeResolveStrategy.AliasReference);
            }
            int  elementCount = dataType.Dimensions.ElementCount;
            Type managed      = null;

            int[] dimensionLengths = dataType.Dimensions.GetDimensionLengths();
            Array.Reverse(dimensionLengths);
            array = !base.valueConverter.TryGetManagedType(elementType, out managed) ? Array.CreateInstance(typeof(object), dimensionLengths) : Array.CreateInstance(managed, dimensionLengths);
            foreach (int[] numArray2 in new ArrayIndexIterator(dataType, false))
            {
                int[] numArray3 = ArrayIndexConverter.NormalizeIndices(numArray2, dataType);
                Array.Reverse(numArray3);
                int    num2 = ArrayIndexConverter.IndicesToSubIndex(numArray2, dataType);
                object obj2 = this.CreateValue(arraySymbol.SubSymbols[num2], rawData, offset, utcReadTime);
                array.SetValue(obj2, numArray3);
                offset += elementType.ByteSize;
            }
            return(array);
        }
예제 #10
0
        internal static bool AreIndicesValid(int[] indices, IArrayType type, bool acceptOversampled)
        {
            IOversamplingSupport support = type as IOversamplingSupport;
            bool oversampled             = ((support != null) && support.IsOversampled) & acceptOversampled;

            return(ArrayIndexConverter.TryCheckIndices(indices, type.Dimensions.LowerBounds, type.Dimensions.UpperBounds, false, oversampled));
        }
예제 #11
0
        public virtual bool IsAssignableFrom(IType other)
        {
            if (other == this || other == Null.Default)
            {
                return(true);
            }

            if (other.IsArray)
            {
                IArrayType otherArray = (IArrayType)other;

                if (otherArray.GetArrayRank() != _rank)
                {
                    return(false);
                }

                IType otherEntityType = otherArray.GetElementType();
                if (_elementType.IsValueType || otherEntityType.IsValueType)
                {
                    return(_elementType == otherEntityType);
                }
                return(_elementType.IsAssignableFrom(otherEntityType));
            }

            return(false);
        }
예제 #12
0
        public override void PropagateChanges(MethodInvocationExpression eval, List chain)
        {
            ExpressionCollection items = new ExpressionCollection();

            foreach (object local1 in chain.Reversed)
            {
                if (!(local1 is ProcessAssignmentsToSpecialMembers.ChainItem))
                {
                }
                ProcessAssignmentsToSpecialMembers.ChainItem item = (ProcessAssignmentsToSpecialMembers.ChainItem)RuntimeServices.Coerce(local1, typeof(ProcessAssignmentsToSpecialMembers.ChainItem));
                if (item.Container is MethodInvocationExpression)
                {
                    break;
                }
                if (item.Container is SlicingExpression)
                {
                    SlicingExpression expression       = (SlicingExpression)item.Container;
                    Expression[]      expressionArray1 = new Expression[] { expression.Target.CloneNode(), expression.Indices[0].Begin.CloneNode(), this.CodeBuilder.CreateReference(item.Local) };
                    items.Add(this.CreateConstructorInvocation(this._sliceValueTypeChangeConstructor, expressionArray1));
                    break;
                }
                MemberReferenceExpression container = (MemberReferenceExpression)item.Container;
                Expression[] args = new Expression[] { container.Target.CloneNode(), this.CodeBuilder.CreateStringLiteral(container.Name), this.CodeBuilder.CreateReference(item.Local) };
                items.Add(this.CreateConstructorInvocation(this._valueTypeChangeConstructor, args));
            }
            MethodInvocationExpression expression3 = this.CodeBuilder.CreateMethodInvocation(this._propagateChanges);
            IArrayType arrayType = this._valueTypeChangeType.MakeArrayType(1);

            expression3.Arguments.Add(this.CodeBuilder.CreateArray(arrayType, items));
            eval.Arguments.Add(expression3);
        }
예제 #13
0
        /// <summary>
        /// Tests whether the specified type is the same type
        /// as the CodeTypeInfo parameter describes.
        /// </summary>
        static bool Is(IType t, CodeTypeInfo cti)
        {
            ITypeReference r = t as ITypeReference;

            if (r != null)
            {
                return(Is(r, cti));
            }

            IArrayType a = t as IArrayType;

            if (a != null && cti != null)
            {
                return(Is(a.ElementType, cti.ArrayElementType) &&
                       (a.Dimensions.Count == cti.ArrayDimensions || (a.Dimensions.Count == 0 && cti.ArrayDimensions == 1)));
            }

            IReferenceType rt = t as IReferenceType;

            if (rt != null)
            {
                return(Is(rt.ElementType, cti));
            }

            IGenericArgument ga = t as IGenericArgument;

            if (ga != null)
            {
                return(true);
            }

            return(false);
        }
예제 #14
0
        public override int TryReadArrayElementValue(ISymbol arraySymbol, int[] indices, out byte[] value, out DateTime readTime)
        {
            AdsErrorCode code;

            if (arraySymbol == null)
            {
                throw new ArgumentNullException("arraySymbol");
            }
            IArrayType dataType = arraySymbol.DataType as IArrayType;

            if (dataType == null)
            {
                throw new ArgumentException("Parameter 'arraySymbol' doesn't represent an array!", "arraySymbol");
            }
            ValueAccessMode mode = this.calcAccessMethod(arraySymbol);

            readTime = DateTime.MinValue;
            if ((indices == null) || (indices.Length == 0))
            {
                int byteSize = dataType.ByteSize;
                value = new byte[byteSize];
                int read = 0;
                if (mode != ValueAccessMode.IndexGroupOffset)
                {
                    code = this.TryReadSymbolic(arraySymbol, byteSize, value, out read);
                }
                else
                {
                    IAdsSymbol symbol2 = (IAdsSymbol)Symbol.Unwrap(arraySymbol);
                    code = this.Connection.RawInterface.Read(symbol2.IndexGroup, symbol2.IndexOffset, 0, byteSize, value, false, out read);
                }
            }
            else
            {
                ArrayType.CheckIndices(indices, dataType, false);
                int elementOffset = ArrayType.GetElementOffset(indices, dataType);
                int byteSize      = dataType.ElementType.ByteSize;
                value = new byte[byteSize];
                int read = 0;
                if (mode != ValueAccessMode.IndexGroupOffset)
                {
                    code = this.TryReadSymbolic(arraySymbol, byteSize, value, out read);
                }
                else
                {
                    IAdsSymbol symbol = (IAdsSymbol)Symbol.Unwrap(arraySymbol);
                    code = this.Connection.RawInterface.Read(symbol.IndexGroup, symbol.IndexOffset + ((uint)elementOffset), 0, byteSize, value, false, out read);
                }
            }
            if (code == AdsErrorCode.NoError)
            {
                readTime = DateTime.UtcNow;
            }
            else
            {
                value = null;
            }
            return((int)code);
        }
예제 #15
0
        internal static int GetElementOffset(int[] indices, IArrayType type)
        {
            int elementPosition = GetElementPosition(indices, type);
            int num3            = 0;

            num3 = (type.ElementType == null) ? (type.Size / type.Dimensions.ElementCount) : type.ElementType.Size;
            return(num3 * elementPosition);
        }
예제 #16
0
 private void ReifyExplodeExpression(IArrayType expectedArrayType, UnaryExpression explodeExpression)
 {
     if (explodeExpression.Operator != UnaryOperatorType.Explode)
     {
         throw new InvalidOperationException();
     }
     ReifyArrayLiteralType(expectedArrayType, explodeExpression.Operand);
 }
        private static bool TryGetCollectionValues(IObjectReference objectReference, out ReadOnlyCollection <IValue> values, out IType elementType)
        {
            IArrayReference arrayReference = objectReference as IArrayReference;

            if (arrayReference == null)
            {
                int size;
                if (TryGetCollectionSize(objectReference, out size))
                {
                    IClassType classType = objectReference.GetReferenceType() as IClassType;
                    if (classType != null)
                    {
                        IObjectReference collectionObject = null;

                        ReadOnlyCollection <IInterfaceType> interfaces = classType.GetInterfaces(true);
                        if (interfaces.Any(i => i.GetName() == "java.util.Collection"))
                        {
                            collectionObject = objectReference;
                        }
                        else if (interfaces.Any(i => i.GetName() == "java.util.Map"))
                        {
                            IMethod entrySetMethod             = classType.GetConcreteMethod("entrySet", "()Ljava/util/Set;");
                            IStrongValueHandle <IValue> result = objectReference.InvokeMethod(null, entrySetMethod, InvokeOptions.None);
                            if (result != null)
                            {
                                collectionObject = result.Value as IObjectReference;
                            }
                        }

                        if (collectionObject != null)
                        {
                            IClassType collectionObjectType = collectionObject.GetReferenceType() as IClassType;
                            if (collectionObjectType != null)
                            {
                                IMethod toArrayMethod = collectionObjectType.GetConcreteMethod("toArray", "()[Ljava/lang/Object;");
                                IStrongValueHandle <IValue> result = collectionObject.InvokeMethod(null, toArrayMethod, InvokeOptions.None);
                                if (result != null)
                                {
                                    arrayReference = result.Value as IArrayReference;
                                }
                            }
                        }
                    }
                }
            }

            if (arrayReference != null)
            {
                values = arrayReference.GetValues();
                IArrayType arrayType = (IArrayType)arrayReference.GetReferenceType();
                elementType = arrayType.GetComponentType();
                return(true);
            }

            values      = null;
            elementType = null;
            return(false);
        }
예제 #18
0
 public InefficientMultidimensionalArrayUsageQuickFix(InefficientMultidimensionalArrayUsageWarning warning)
 {
     myWarning                 = warning;
     myVariableDeclaration     = warning.VariableDeclaration;
     myTreeNodePointers        = warning.Usages;
     myArrayCreationExpression = warning.ArrayCreationExpression;
     myType = (myVariableDeclaration.Type as IArrayType).NotNull("type != null");
     myMultipleDeclaration = warning.MultiplyDeclaration;
 }
예제 #19
0
 public override void VisitArrayType(IArrayType type)
 {
     base.VisitArrayType(type);
     _formatter.Write("[]");
     for (int i = 0; i < type.Dimensions.Count; i++)
     {
         _formatter.Write("[]");
     }
 }
예제 #20
0
        private bool InferArrayType(IArrayType formalType, IType actualType, TypeInference inference)
        {
            IArrayType actualArrayType = actualType as IArrayType;

            return
                ((actualArrayType != null) &&
                 (actualArrayType.Rank == formalType.Rank) &&
                 (Infer(formalType.ElementType, actualType.ElementType, inference)));
        }
예제 #21
0
 protected override int OnGetSize()
 {
     if (base.size == 0)
     {
         IArrayType type = this.UpdateDynamicType();
         base.size = type.Size;
     }
     return(base.size);
 }
예제 #22
0
        public override int TryWriteArrayElementValue(ISymbol arraySymbol, int[] indices, byte[] value, int valOffset, out DateTime writeTime)
        {
            if (this.Connection == null)
            {
                throw new AdsException("Connection not established!");
            }
            if (arraySymbol == null)
            {
                throw new ArgumentNullException("arraySymbol");
            }
            AdsErrorCode    noError   = AdsErrorCode.NoError;
            IArrayType      arrayType = null;
            IResolvableType dataType  = arraySymbol.DataType as IResolvableType;

            arrayType = (dataType == null) ? (arraySymbol.DataType as IArrayType) : (dataType.ResolveType(DataTypeResolveStrategy.AliasReference) as IArrayType);
            if (arrayType == null)
            {
                throw new ArgumentException("Is not an array type", "arraySymbol");
            }
            ValueAccessMode mode = this.calcAccessMethod(arraySymbol);

            writeTime = DateTime.MinValue;
            if ((indices == null) || (indices.Length == 0))
            {
                int        byteSize = arraySymbol.ByteSize;
                IAdsSymbol symbol2  = (IAdsSymbol)Symbol.Unwrap(arraySymbol);
                if (value.Length != byteSize)
                {
                    throw new ArgumentException("Value array size mismatch!", "value");
                }
                if (mode == ValueAccessMode.IndexGroupOffset)
                {
                    noError = this.Connection.RawInterface.Write(symbol2.IndexGroup, symbol2.IndexOffset, valOffset, byteSize, value, false);
                }
            }
            else
            {
                ArrayType.CheckIndices(indices, arrayType, false);
                int elementOffset = ArrayType.GetElementOffset(indices, arrayType);
                int byteSize      = arrayType.ElementType.ByteSize;
                if (mode != ValueAccessMode.IndexGroupOffset)
                {
                    noError = this.TryWriteSymbolic(arraySymbol, valOffset, byteSize, value);
                }
                else
                {
                    IAdsSymbol symbol = (IAdsSymbol)Symbol.Unwrap(arraySymbol);
                    noError = this.Connection.RawInterface.Write(symbol.IndexGroup, symbol.IndexOffset + ((uint)elementOffset), valOffset, byteSize, value, false);
                }
            }
            if (noError != AdsErrorCode.NoError)
            {
                writeTime = DateTime.UtcNow;
            }
            return((int)noError);
        }
예제 #23
0
        public int CompareTo(object obj)
        {
            IArrayType type = obj as IArrayType;

            if (type == null)
            {
                return(-1);
            }
            return(CompareItems.CompareArrayTypes(this, type));
        }
예제 #24
0
        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            if (this.resolvedAlias.Category != DataTypeCategory.Array)
            {
                return(base.TryGetIndex(binder, indexes, ref result));
            }
            IArrayType resolvedAlias = (IArrayType)this.resolvedAlias;

            return(DynamicArrayInstance.TryGetIndex(this, resolvedAlias, binder, indexes, out result));
        }
예제 #25
0
 /// <summary>
 /// Determine if two array types are equal
 /// </summary>
 /// <param name="iat1">Reference method signature</param>
 /// <param name="iat2">Method declaration signature</param>
 /// <returns></returns>
 internal static bool ArrayTypesAreEqual(IArrayType iat1, IArrayType iat2)
 {
     if (iat1.Rank != iat2.Rank || !iat1.ElementType.Equals(iat2.ElementType))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
예제 #26
0
 internal static bool TryGetIndex(DynamicSymbol symbol, IArrayType arrayType, GetIndexBinder binder, object[] indexes, out object result)
 {
     int[] indices = new int[indexes.GetLength(0)];
     for (int i = 0; i < indexes.GetLength(0); i++)
     {
         indices[i] = (int)indexes[i];
     }
     ArrayType.CheckIndices(indices, arrayType, false);
     result = symbol.SubSymbols[ArrayType.GetElementPosition(indices, arrayType)];
     return(true);
 }
예제 #27
0
 public ISymbolCollection CreateArrayElementInstances(ISymbol parentInstance, IArrayType arrayType)
 {
     if (parentInstance == null)
     {
         throw new ArgumentNullException("parentInstance");
     }
     if (arrayType == null)
     {
         throw new ArgumentNullException("arrayType");
     }
     return(this.OnCreateArrayElementInstances(parentInstance, arrayType));
 }
예제 #28
0
        public IArrayType GetArrayType(IType elementType, int rank)
        {
            ArrayHash  key    = new ArrayHash(elementType, rank);
            IArrayType entity = (IArrayType)_arrayCache[key];

            if (null == entity)
            {
                entity = new ArrayType(this, elementType, rank);
                _arrayCache.Add(key, entity);
            }
            return(entity);
        }
예제 #29
0
        public IArrayType GetArrayType(IType elementType, int rank)
        {
            ArrayHash  key = new ArrayHash(elementType, rank);
            IArrayType tag = (IArrayType)_arrayCache[key];

            if (null == tag)
            {
                tag = new ArrayType(this, elementType, rank);
                _arrayCache.Add(key, tag);
            }
            return(tag);
        }
예제 #30
0
        private void ReifyArrayLiteralType(IArrayType expectedArrayType, Expression array)
        {
            var explodeExpression = array as UnaryExpression;

            if (explodeExpression != null)
            {
                ReifyExplodeExpression(expectedArrayType, explodeExpression);
            }
            else
            {
                ReifyArrayLiteralExpression(expectedArrayType, (ArrayLiteralExpression)array);
            }
            BindExpressionType(array, expectedArrayType);
        }
예제 #31
0
파일: TypeVisitor.cs 프로젝트: 0xb1dd1e/boo
		public virtual void VisitArrayType(IArrayType arrayType)
		{
			Visit(arrayType.ElementType);
		}
예제 #32
0
파일: EmitAssembly.cs 프로젝트: hlizard/boo
		private void LoadSingleDimensionalArrayElementAddress(SlicingExpression slicing, IArrayType arrayType)
		{
			EmitNormalizedArrayIndex(slicing, slicing.Indices[0].Begin);
			_il.Emit(OpCodes.Ldelema, GetSystemType(arrayType.ElementType));
		}
예제 #33
0
파일: ReifyTypes.cs 프로젝트: 0xb1dd1e/boo
		private void ReifyArrayLiteralExpression(IArrayType expectedArrayType, ArrayLiteralExpression arrayLiteralExpression)
		{
			arrayLiteralExpression.Type = (ArrayTypeReference)CodeBuilder.CreateTypeReference(expectedArrayType);
		}
예제 #34
0
		private bool InferArrayType(IArrayType formalType, IType actualType, TypeInference inference)
		{
			IArrayType actualArrayType = actualType as IArrayType;
			return
				(actualArrayType != null) &&
				(actualArrayType.Rank == formalType.Rank) &&
				(Infer(formalType.ElementType, actualType.ElementType, inference));
		}
예제 #35
0
파일: ReifyTypes.cs 프로젝트: 0xb1dd1e/boo
		private void ReifyArrayLiteralType(IArrayType expectedArrayType, Expression array)
		{
			var explodeExpression = array as UnaryExpression;
			if (explodeExpression != null)
				ReifyExplodeExpression(expectedArrayType, explodeExpression);
			else
				ReifyArrayLiteralExpression(expectedArrayType, (ArrayLiteralExpression)array);
			BindExpressionType(array, expectedArrayType);
		}
예제 #36
0
파일: ReifyTypes.cs 프로젝트: 0xb1dd1e/boo
		private void ReifyExplodeExpression(IArrayType expectedArrayType, UnaryExpression explodeExpression)
		{
			if (explodeExpression.Operator != UnaryOperatorType.Explode)
				throw new InvalidOperationException();
			ReifyArrayLiteralType(expectedArrayType, explodeExpression.Operand);
		}
예제 #37
0
 private bool InferArrayType(IArrayType formalType, IType actualType, Inference inference)
 {
     IArrayType actualArrayType = actualType as IArrayType;
     return
         (actualArrayType != null) &&
         (actualArrayType.GetArrayRank() == formalType.GetArrayRank()) &&
         (Infer(formalType.GetElementType(), actualType.GetElementType(), inference));
 }
예제 #38
0
		public TypeSystemServices(CompilerContext context)
		{
			if (null == context) throw new ArgumentNullException("context");

			_context = context;
			_anonymousCallablesManager = new AnonymousCallablesManager(this);

			_findImplicitConversionOperator =
				new MemoizedFunction<IType, IType, IMethod>((fromType, toType) => FindConversionOperator("op_Implicit", fromType, toType));
			_findExplicitConversionOperator =
				new MemoizedFunction<IType, IType, IMethod>((fromType, toType) => FindConversionOperator("op_Explicit", fromType, toType));

			My<CurrentScope>.Instance.Changed += (sender, args) => ClearScopeDependentMemoizedFunctions();

			_canBeReachedByPromotion = new MemoizedFunction<IType, IType, bool>(CanBeReachedByPromotionImpl);

			DuckType = Map(typeof(Builtins.duck));
			IQuackFuType = Map(typeof(IQuackFu));
			VoidType = Map(Types.Void);
			ObjectType = Map(Types.Object);
			RegexType = Map(Types.Regex);
			ValueTypeType = Map(typeof(ValueType));
			EnumType = Map(typeof(Enum));
			ArrayType = Map(Types.Array);
			TypeType = Map(Types.Type);
			StringType = Map(Types.String);
			BoolType = Map(Types.Bool);
			SByteType = Map(Types.SByte);
			CharType = Map(Types.Char);
			ShortType = Map(Types.Short);
			IntType = Map(Types.Int);
			LongType = Map(Types.Long);
			ByteType = Map(Types.Byte);
			UShortType = Map(Types.UShort);
			UIntType = Map(Types.UInt);
			ULongType = Map(Types.ULong);
			SingleType = Map(Types.Single);
			DoubleType = Map(Types.Double);
			DecimalType = Map(Types.Decimal);
			TimeSpanType = Map(Types.TimeSpan);
			DateTimeType = Map(Types.DateTime);
			RuntimeServicesType = Map(Types.RuntimeServices);
			BuiltinsType = Map(Types.Builtins);
			ListType = Map(Types.List);
			HashType = Map(Types.Hash);
			ICallableType = Map(Types.ICallable);
			IEnumerableType = Map(Types.IEnumerable);
			IEnumeratorType = Map(typeof(IEnumerator));
			ICollectionType = Map(Types.ICollection);
			IDisposableType = Map(typeof(IDisposable));
			IntPtrType = Map(Types.IntPtr);
			UIntPtrType = Map(Types.UIntPtr);
			MulticastDelegateType = Map(Types.MulticastDelegate);
			DelegateType = Map(Types.Delegate);
			SystemAttribute = Map(typeof(Attribute));
			ConditionalAttribute = Map(typeof(ConditionalAttribute));
			IEnumerableGenericType = Map(Types.IEnumerableGeneric);
			IEnumeratorGenericType = Map(typeof(IEnumerator<>));
			ICollectionGenericType = Map(typeof(ICollection<>));
			IListGenericType = Map(typeof (IList<>));
			IListType = Map(typeof (IList));
			IAstMacroType = Map(typeof(IAstMacro));
			IAstGeneratorMacroType = Map(typeof(IAstGeneratorMacro));
			AstNodeType = Map(typeof(Node));

			ObjectArrayType = ObjectType.MakeArrayType(1);

			PreparePrimitives();
			PrepareBuiltinFunctions();
		}
예제 #39
0
 public virtual void VisitArrayType(IArrayType value)
 {
     this.VisitType(value.ElementType);
     this.VisitArrayDimensionCollection(value.Dimensions);
 }
예제 #40
0
파일: EmitAssembly.cs 프로젝트: hlizard/boo
		private void EmitAssignmentToMultiDimensionalArrayElement(IArrayType arrayType, SlicingExpression slice, BinaryExpression node)
		{
			var elementType = arrayType.ElementType;
			LoadArrayIndices(slice);
			var temp = LoadAssignmentOperand(elementType, node);
			CallArrayMethod(arrayType, "Set", typeof(void), ParameterTypesForArraySet(arrayType));
			FlushAssignmentOperand(elementType, temp);
		}
예제 #41
0
파일: EmitAssembly.cs 프로젝트: hlizard/boo
		private void EmitAssignmentToSingleDimensionalArrayElement(IArrayType arrayType, SlicingExpression slice, BinaryExpression node)
		{
			var elementType = arrayType.ElementType;

			var index = slice.Indices[0];
			EmitNormalizedArrayIndex(slice, index.Begin);

			var opcode = GetStoreEntityOpCode(elementType);
			bool stobj = IsStobj(opcode);
			if (stobj) _il.Emit(OpCodes.Ldelema, GetSystemType(elementType));

			var temp = LoadAssignmentOperand(elementType, node);

			if (stobj)
				_il.Emit(opcode, GetSystemType(elementType));
			else
				_il.Emit(opcode);

			FlushAssignmentOperand(elementType, temp);
		}
예제 #42
0
파일: EmitAssembly.cs 프로젝트: hlizard/boo
		private static Type[] ParameterTypesForArrayGet(IArrayType arrayType)
		{
			return Enumerable.Range(0, arrayType.Rank).Select(_ => typeof(int)).ToArray();
		}
예제 #43
0
파일: EmitAssembly.cs 프로젝트: hlizard/boo
		private void LoadMultiDimensionalArrayElement(SlicingExpression node, IArrayType arrayType)
		{
			LoadArrayIndices(node);
			CallArrayMethod(arrayType, "Get", GetSystemType(arrayType.ElementType), ParameterTypesForArrayGet(arrayType));
		}
예제 #44
0
파일: EmitAssembly.cs 프로젝트: hlizard/boo
		private Type[] ParameterTypesForArraySet(IArrayType arrayType)
		{
			var types = new Type[arrayType.Rank + 1];
			for (var i = 0; i < arrayType.Rank; ++i)
				types[i] = typeof(int);
			types[arrayType.Rank] = GetSystemType(arrayType.ElementType);
			return types;
		}
예제 #45
0
        public TypeSystemServices(CompilerContext context)
        {
            if (null == context) throw new ArgumentNullException("context");

            _context = context;
            _anonymousCallablesManager = new AnonymousCallablesManager(this);
            _genericsServices = new GenericsServices(context);

            CodeBuilder = new BooCodeBuilder(this);

            Cache(typeof(Builtins.duck), DuckType = new DuckTypeImpl(this));
            Cache(IQuackFuType = new ExternalType(this, typeof(IQuackFu)));
            Cache(VoidType = new VoidTypeImpl(this));
            Cache(ObjectType = new ExternalType(this, Types.Object));
            Cache(RegexType = new ExternalType(this, Types.Regex));
            Cache(ValueTypeType = new ExternalType(this, typeof(ValueType)));
            Cache(EnumType = new ExternalType(this, typeof(Enum)));
            Cache(ArrayType = new ExternalType(this, Types.Array));
            Cache(TypeType = new ExternalType(this, Types.Type));
            Cache(StringType = new ExternalType(this, Types.String));
            Cache(BoolType = new ExternalType(this, Types.Bool));
            Cache(SByteType = new ExternalType(this, Types.SByte));
            Cache(CharType = new ExternalType(this, Types.Char));
            Cache(ShortType = new ExternalType(this, Types.Short));
            Cache(IntType = new ExternalType(this, Types.Int));
            Cache(LongType = new ExternalType(this, Types.Long));
            Cache(ByteType = new ExternalType(this, Types.Byte));
            Cache(UShortType = new ExternalType(this, Types.UShort));
            Cache(UIntType = new ExternalType(this, Types.UInt));
            Cache(ULongType = new ExternalType(this, Types.ULong));
            Cache(SingleType = new ExternalType(this, Types.Single));
            Cache(DoubleType = new ExternalType(this, Types.Double));
            Cache(DecimalType = new ExternalType(this, Types.Decimal));
            Cache(TimeSpanType = new ExternalType(this, Types.TimeSpan));
            Cache(DateTimeType = new ExternalType(this, Types.DateTime));
            Cache(RuntimeServicesType = new ExternalType(this, Types.RuntimeServices));
            Cache(BuiltinsType = new ExternalType(this, Types.Builtins));
            Cache(ListType = new ExternalType(this, Types.List));
            Cache(HashType = new ExternalType(this, Types.Hash));
            Cache(ICallableType = new ExternalType(this, Types.ICallable));
            Cache(IEnumerableType = new ExternalType(this, Types.IEnumerable));
            Cache(IEnumeratorType = new ExternalType(this, typeof(IEnumerator)));
            Cache(ICollectionType = new ExternalType(this, Types.ICollection));
            Cache(IListType = new ExternalType(this, Types.IList));
            Cache(IDictionaryType = new ExternalType(this, Types.IDictionary));
            Cache(IntPtrType = new ExternalType(this, Types.IntPtr));
            Cache(UIntPtrType = new ExternalType(this, Types.UIntPtr));
            Cache(MulticastDelegateType = new ExternalType(this, Types.MulticastDelegate));
            Cache(DelegateType = new ExternalType(this, Types.Delegate));
            Cache(SystemAttribute = new ExternalType(this, typeof(System.Attribute)));
            Cache(ConditionalAttribute = new ExternalType(this, typeof(System.Diagnostics.ConditionalAttribute)));
            Cache(IEnumerableGenericType = new ExternalType(this, typeof(System.Collections.Generic.IEnumerable<>)));
            Cache(IEnumeratorGenericType = new ExternalType(this, typeof(System.Collections.Generic.IEnumerator<>)));

            ObjectArrayType = GetArrayType(ObjectType, 1);

            PreparePrimitives();
            PrepareBuiltinFunctions();
        }
예제 #46
0
 private void ReifyArrayLiteralType(IArrayType expectedArrayType, Expression array)
 {
     ((ArrayLiteralExpression)array).Type = (ArrayTypeReference)CodeBuilder.CreateTypeReference(expectedArrayType);
     BindExpressionType(array, expectedArrayType);
 }
예제 #47
0
파일: EmitAssembly.cs 프로젝트: hlizard/boo
		private void LoadMultiDimensionalArrayElementAddress(SlicingExpression slicing, IArrayType arrayType)
		{
			LoadArrayIndices(slicing);
			CallArrayMethod(arrayType, "Address", GetSystemType(arrayType.ElementType).MakeByRefType(), ParameterTypesForArrayGet(arrayType));
		}
예제 #48
0
 private StaticArrayTypeWrapper MakeArrayType(IArrayType arrayTypeHandle)
 {
     return MakeType(arrayTypeHandle.ElementType).MakeArrayType(arrayTypeHandle.Rank);
 }
 public virtual IType TransformArrayType(IArrayType value)
 {
     /* value.ElementType */
     this.TransformType(value.ElementType);
     /* value.Dimensions.AddRange( */
     this.TransformArrayDimensionCollection(value.Dimensions) /* ) */ ;
     return value;
 }