private HLLocation ProcessCreateArrayExpression(ICreateArray pExpression) { if (pExpression.Rank != 1 || pExpression.Sizes.Count() != 1 || pExpression.LowerBounds.Count() > 0) { throw new NotSupportedException(); } HLType typeElement = HLDomain.GetOrCreateType(pExpression.ElementType); HLLocation locationInstance = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type))); HLLocation locationSize = ProcessExpression(pExpression.Sizes.First()); mCurrentBlock.EmitNewArray(locationInstance.AddressOf(), locationSize, locationInstance.Type, typeElement); IExpression[] initializers = pExpression.Initializers.ToArray(); for (int indexInitializer = 0; indexInitializer < initializers.Length; ++indexInitializer) { HLLocation locationInitializer = ProcessExpression(initializers[indexInitializer]); HLLocation locationArrayElement = HLArrayElementLocation.Create(locationInstance, HLInt32LiteralLocation.Create(indexInitializer), typeElement); mCurrentBlock.EmitAssignment(locationArrayElement, locationInitializer); } return(locationInstance); }
private HLLocation ProcessCompileTimeConstantExpression(ICompileTimeConstant pExpression) { if (pExpression.Value == null) { return(HLNullLocation.Create(HLDomain.GetOrCreateType(pExpression.Type))); } if (pExpression.Type.ResolvedType.IsEnum) { return(HLEnumLiteralLocation.Create(HLDomain.GetOrCreateType(pExpression.Type), pExpression.Value.ToString())); } if (pExpression.Value is bool) { return(HLBooleanLiteralLocation.Create((bool)pExpression.Value)); } if (pExpression.Value is sbyte) { return(HLInt8LiteralLocation.Create((sbyte)pExpression.Value)); } if (pExpression.Value is byte) { return(HLUInt8LiteralLocation.Create((byte)pExpression.Value)); } if (pExpression.Value is char) { return(HLCharLiteralLocation.Create((char)pExpression.Value)); } if (pExpression.Value is short) { return(HLInt16LiteralLocation.Create((short)pExpression.Value)); } if (pExpression.Value is ushort) { return(HLUInt16LiteralLocation.Create((ushort)pExpression.Value)); } if (pExpression.Value is float) { return(HLFloat32LiteralLocation.Create((float)pExpression.Value)); } if (pExpression.Value is int) { return(HLInt32LiteralLocation.Create((int)pExpression.Value)); } if (pExpression.Value is uint) { return(HLUInt32LiteralLocation.Create((uint)pExpression.Value)); } if (pExpression.Value is double) { return(HLFloat64LiteralLocation.Create((double)pExpression.Value)); } if (pExpression.Value is long) { return(HLInt64LiteralLocation.Create((long)pExpression.Value)); } if (pExpression.Value is ulong) { return(HLUInt64LiteralLocation.Create((ulong)pExpression.Value)); } if (pExpression.Value is string) { return(HLStringLiteralLocation.Create((string)pExpression.Value)); } throw new NotSupportedException(); }