From 2d573890b24b13cc8ef5d7ca9ad4c0516a39ee05 Mon Sep 17 00:00:00 2001 From: Jack Pappas Date: Thu, 3 Jul 2014 20:16:53 -0400 Subject: [PATCH 01/20] Implemented a test for overload resolution when calling an overloaded method or constructor where another overload contains a parameter whose type is a high-rank array (5-32). --- .../typecheck/full-rank-arrays/Class1.cs | 183 ++++++++++++++++++ .../full-rank-arrays/HighRankArrayTests.dll | Bin 0 -> 6144 bytes .../typecheck/full-rank-arrays/build.bat | 5 + .../fsharp/typecheck/full-rank-arrays/run.bat | 5 + .../fsharp/typecheck/full-rank-arrays/test.fs | 21 ++ .../typecheck/full-rank-arrays/test.fsx | 32 +++ tests/test.lst | 3 +- 7 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 tests/fsharp/typecheck/full-rank-arrays/Class1.cs create mode 100644 tests/fsharp/typecheck/full-rank-arrays/HighRankArrayTests.dll create mode 100644 tests/fsharp/typecheck/full-rank-arrays/build.bat create mode 100644 tests/fsharp/typecheck/full-rank-arrays/run.bat create mode 100644 tests/fsharp/typecheck/full-rank-arrays/test.fs create mode 100644 tests/fsharp/typecheck/full-rank-arrays/test.fsx diff --git a/tests/fsharp/typecheck/full-rank-arrays/Class1.cs b/tests/fsharp/typecheck/full-rank-arrays/Class1.cs new file mode 100644 index 0000000000..c20f006b0a --- /dev/null +++ b/tests/fsharp/typecheck/full-rank-arrays/Class1.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace HighRankArrayTests +{ + public sealed class ClassWithArrayCtor + { + private readonly Array m_array; + + public ClassWithArrayCtor(T[] array) + { + m_array = array; + } + + public ClassWithArrayCtor(T[,] array) + { + m_array = array; + } + + public ClassWithArrayCtor(T[,,] array) + { + m_array = array; + } + + public ClassWithArrayCtor(T[,,,] array) + { + m_array = array; + } + + public ClassWithArrayCtor(T[,,,,] array) + { + m_array = array; + } + + public ClassWithArrayCtor(T[,,,,,] array) + { + m_array = array; + } + + public ClassWithArrayCtor(T[,,,,,,] array) + { + m_array = array; + } + + public ClassWithArrayCtor(T[,,,,,,,] array) + { + m_array = array; + } + + public ClassWithArrayCtor(T[,,,,,,,,] array) + { + m_array = array; + } + + public ClassWithArrayCtor(T[,,,,,,,,,] array) + { + m_array = array; + } + + public ClassWithArrayCtor(T[,,,,,,,,,,] array) + { + m_array = array; + } + } + + public static class StaticClassWithGenericMethod + { + public static void Example(T[] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,,,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,,,,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,,,,,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,,,,,,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,,,,,,,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,,,,,,,,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,,,,,,,,,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,,,,,,,,,,] array) + { + throw new NotImplementedException(); + } + } + + public static class GenericStaticClassWithMethod + { + public static void Example(T[] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[, ,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[, , ,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[, , , ,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[, , , , ,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[, , , , , ,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[, , , , , , ,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[, , , , , , , ,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[, , , , , , , , ,] array) + { + throw new NotImplementedException(); + } + + public static void Example(T[, , , , , , , , , ,] array) + { + throw new NotImplementedException(); + } + } +} diff --git a/tests/fsharp/typecheck/full-rank-arrays/HighRankArrayTests.dll b/tests/fsharp/typecheck/full-rank-arrays/HighRankArrayTests.dll new file mode 100644 index 0000000000000000000000000000000000000000..050e92cc7cbb048afe1231935ce367df7aa0e766 GIT binary patch literal 6144 zcmeHLTWlOx8UD|#?buFyw{uTCt`kaVz4B!f;x=u4StoXg6XV_3h8W`6-N|~I*`3YI zY-0ztN(3zsRci85)B*(rMJiMUAq1s}Dyk~POVtM+5S1zw33x(6Dj*ez2;YBZ_ITH8 z6{vVfr2f`?=Y0RUedj-C&YAV}r>{|jh-&cMx<&LdQnnF^?+=$z+}!<2GyS;Xjh>gq zi8p$Z%a*4XTqo-qIX!LU^Nz2lOx-Q!bt|vOPbKu6lQE-BO^y4)u4g8QPKXFSweZYr zX|#7p>)9+e6Scxq7kFQdBGvJX;NcP-s0F&&!TP0L2Exx4p^?XBC)^KrCR3HLlQQUc zo--pv3mk~`wnVfAzI*$KcCRmcKduwimzCFpPnPkhZ?5>@uQvlwCbfmS!KCR#OHtQz z(_m8D2r@j;c06S^0`*bXv>jArt+a%P``U`9%tnaD%BakKlj90wZ5q|mwH~6cA@o9e z|97}g`)C_cqZWA-A{#$;d(xd=2gF^v4HFtm93K;5^m#2GiADRPL;XVo!@L%?WCP#B z9_W1xd$*S8Cf2z(;k#Bo>v4@GY&za|y{8kjj0|u2-eaey;z(D(_hFCsj@eEMoDI#z zd>7R>@V@%T{vqBoy!M@V*u{Bl3Hcys#M_m9rKbsb#8Ps8S-(QpfX_*Mi*6uaEB*r9 zEpb@lg2W3FuS$Gg;th%KiQkGk+M+S;)VS@C#I!b}jnhR4uA}d2PiS@YONqbNu1O87 zh;`vlv_kJ8M2p!KuqnwjydBKWg=`yYeFxfSbZ+^?_7^cbL1z`~LUi(q^-zQ!RV<3= zJgL|bjP+H;J^_W_Q|t_FqMs>dV|9L|*kjZ{zftTuwER)A=V>$jO|qxyNAwD`-&E{1 zYN7})3vt<-(A}um+tfmBiv0;YV7p>Bsg1f7YZC4B5yiSi2lXj7C^{*o*iq3%_bYZr zY^5>9E{JV3rPzwtPBV&qLF}M;#jcB;^jXEeA$F0e*h^wJ*^0d?_K>I8n_@3rQtWr4 zo31GKSE19F6sy-bD-f+a9e2=+vK|?xL>)dnMi@aY*{_r*FeQEwUo2(e$At~657QlCx+_fgglTt} z_JnC~nC=hLyTkNAnBEhneL;F;+Q}4c^Ff-lvdgnZ{`{!x8mmdu^Sx-swrSipJa69e zm!*H)cig3c4eCGPGQx>T5M31bd8LeGs-7Z(l}nU{i0hYeqCUu^1kUhg@oxo zVx>)w#+}@p@NUIBuTDDnL7!Dh^jBMWVup>N*o2g7LQ&RdfdE)yX!<9`w`+dzZtYd7|LLX0xgD{0z8tA*Z>ZCS*waCqk#u(87R05y zCCEo`3lcR2q$YTgn*&yhOOUN4pmn$frL_ip6Yjyl+5$(t{7{ju_Q2DC>#$@UfvXXB zqO#7ww;3nZnr&(o5WAPQaN4;yP}>xeKyGu$LcJ{^EeUQ7xl-H~I@Tn&hn_Oc9igjS zbZ6+RP~8QXOF)(2)_||+Z3`S_a@zw>x!R7vRUx)B z@KtK9(S>Mc&}so~6P&HbMiO;h?e+L%n2GlC=VDUZI`0~V zlTKc}G|6Sxx#&p^>USzP-3`|yeiu%*5X~myiOYZgwfWT5x5l1+$T&Uv{o@gCk-l&7 zw1)$F@wkybzZiGYMSdf_MI1y$!`2giF=ILUz`!ETMn3+%#p(cTmYf}T+_-H|8&*EJGEGxn(p>A-e)JXos;_MI zA^RW^5HgtCi7r>R<`;tqFHM!7>rLWW7yOcCA~!{+=p^_Q@F?41xS!thal|-oluZMDj zeAIKm0{daj5;_&otOwn0N3OqZG%0X7G(HRQ)(c_b4sp*>)G0kY{x;O-8T+zs9(~$~sX;k# zUXTAgZj>@;!~ad-`nVkE1lne0PveMG0V+8%tlvkSYM)Lo;N{b45ZVR^=P)fuU8ll! z997m;S|Mg1R3FEC2K_ovT|}(?vf2K3^W}NQWSlGeSs(57u|6!@jAA`J#3zRxU?Va* e_H^Yct#8NU-4Uh-|1-St;2oj%Ly`aI2>cs(7D.Example [| 2;3;4;5 |] + + member this.Y = + StaticClassWithGenericMethod.Example [| 1;2;3;4 |] + + member this.Z = + let foo = ClassWithArrayCtor ([| 1;3;5;7 |]) + () diff --git a/tests/fsharp/typecheck/full-rank-arrays/test.fsx b/tests/fsharp/typecheck/full-rank-arrays/test.fsx new file mode 100644 index 0000000000..99e1c0d1e5 --- /dev/null +++ b/tests/fsharp/typecheck/full-rank-arrays/test.fsx @@ -0,0 +1,32 @@ +// #TypeInference +(* Avoid ;; since it allows fsi to recover from type errors *) + +#r "HighRankArrayTests.dll" +open HighRankArrayTests + +(* In the F# 3.1 release and earlier versions, the compiler's overload resolution + breaks on the following class definition. The referenced assembly defines + several classes with various overloaded methods and constructors; some of these + overloads include parameters whose type is a "high-rank" array -- that is, + an array of rank 5-32. Arrays with these ranks are not currently supported by + F#, but it should still be possible to call one of the overloads which does + not include such a parameter. *) +type Class1() = + member this.X = + GenericStaticClassWithMethod.Example [| 2;3;4;5 |] + + member this.Y = + StaticClassWithGenericMethod.Example [| 1;2;3;4 |] + + member this.Z = + let foo = ClassWithArrayCtor ([| 1;3;5;7 |]) + () +(* avoid ;; -- to avoid fsi error recovery *) + +let _ = + (* May not be enough if fsi does error recovery... + * So avoid using ;; + *) + System.Console.WriteLine "Test Passed"; + System.IO.File.WriteAllText ("test.ok", "ok"); + exit 0 diff --git a/tests/test.lst b/tests/test.lst index a37bb5fc9c..79e0d3844f 100644 --- a/tests/test.lst +++ b/tests/test.lst @@ -174,4 +174,5 @@ Misc02 fsharp\tools\bundle Misc02 fsharp\tools\eval Misc02 ..\testsprivate\fsharp\tools\queries Misc02 fsharp\typecheck\misc -Misc02 fsharp\typecheck\sigs \ No newline at end of file +Misc02 fsharp\typecheck\sigs +Misc02 fsharp\typecheck\full-rank-arrays \ No newline at end of file From 585336c25040712047b5ee27e2bc7a359233f1a4 Mon Sep 17 00:00:00 2001 From: Jack Pappas Date: Thu, 3 Jul 2014 20:17:20 -0400 Subject: [PATCH 02/20] Extended support for array types to include all ranks supported by .NET (i.e., up to rank 32). This fixes a bug where the F# compiler wouldn't allow F# code to call an overloaded method or constructor when one or more of those overloads contained one or more parameters whose type was an array with rank greater than 4 (even when the overload being called did not include such a parameter). --- src/fsharp/FSComp.txt | 2 +- src/fsharp/FSharp.Core/prim-types-prelude.fs | 28 +++++ src/fsharp/FSharp.Core/prim-types-prelude.fsi | 112 ++++++++++++++++++ src/fsharp/creflect.fs | 13 +- src/fsharp/env.fs | 74 ++++++------ src/fsharp/patcompile.fs | 2 +- src/fsharp/tastops.fs | 105 ++++++++-------- src/fsharp/tastops.fsi | 5 +- 8 files changed, 234 insertions(+), 107 deletions(-) diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 71f4487804..2898eb2138 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -1285,7 +1285,7 @@ typeInfoCallsWord,"Calls" 3135,parsMutableOnAutoPropertyShouldBeGetSetNotJustSet,"To indicate that this property can be set, use 'member val PropertyName = expr with get,set'." 3136,chkNoByrefsOfByrefs,"Type '%s' is illegal because in byref, T cannot contain byref types." 3137,etTypeProviderNotApproved,"Type provider assembly '%s' is not trusted and will not be loaded for security reasons. This may cause subsequent build errors. See the 'F# Tools' section of Visual Studio options for more information." -3138,tastopsMaxArrayFour,"F# supports a maximum array rank of 4" +3138,tastopsMaxArrayThirtyTwo,"F# supports a maximum array rank of 32" 3139,tcNoIntegerForLoopInQuery,"In queries, use the form 'for x in n .. m do ...' for ranging over integers" 3140,tcNoWhileInQuery,"'while' expressions may not be used in queries" 3141,tcNoTryFinallyInQuery,"'try/finally' expressions may not be used in queries" diff --git a/src/fsharp/FSharp.Core/prim-types-prelude.fs b/src/fsharp/FSharp.Core/prim-types-prelude.fs index a11863f226..3f30de26bb 100644 --- a/src/fsharp/FSharp.Core/prim-types-prelude.fs +++ b/src/fsharp/FSharp.Core/prim-types-prelude.fs @@ -33,6 +33,34 @@ namespace Microsoft.FSharp.Core type ``[,]``<'T> = (# "!0[0 ...,0 ...]" #) type ``[,,]``<'T> = (# "!0[0 ...,0 ...,0 ...]" #) type ``[,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + type ``[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]``<'T> = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) type array<'T> = 'T[] diff --git a/src/fsharp/FSharp.Core/prim-types-prelude.fsi b/src/fsharp/FSharp.Core/prim-types-prelude.fsi index edd4008e61..e96bc75527 100644 --- a/src/fsharp/FSharp.Core/prim-types-prelude.fsi +++ b/src/fsharp/FSharp.Core/prim-types-prelude.fsi @@ -96,6 +96,118 @@ namespace Microsoft.FSharp.Core /// to manipulate values of this type, or the notation arr.[x1,x2,x3,x4] to get and set array /// values. type 'T ``[,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...]" #) + + /// Five dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Six dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Seven dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Eight dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Nine dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Ten dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Eleven dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twelve dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Thirteen dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Fourteen dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Fifteen dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Sixteen dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Seventeen dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Eighteen dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Nineteen dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twenty dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twenty-one dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twenty-two dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twenty-three dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twenty-four dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twenty-five dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twenty-six dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twenty-seven dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twenty-eight dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Twenty-nine dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Thirty dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Thirty-one dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) + + /// Thirty-two dimensional arrays, typically zero-based. Non-zero-based arrays + /// can be created using methods on the System.Array type. + type 'T ``[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]`` = (# "!0[0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...,0 ...]" #) /// Single dimensional, zero-based arrays, written int[], string[] etc. /// diff --git a/src/fsharp/creflect.fs b/src/fsharp/creflect.fs index ae60038107..ede051a0bd 100644 --- a/src/fsharp/creflect.fs +++ b/src/fsharp/creflect.fs @@ -125,7 +125,7 @@ let (|SimpleArrayLoopUpperBound|_|) expr = let (|SimpleArrayLoopBody|_|) g expr = match expr with | Expr.Lambda(_, a, b, ([_] as args), Expr.Let(TBind(forVarLoop, Expr.Op(TOp.ILAsm([I_ldelem_any(ILArrayShape [(Some 0, None)], _)], _), [elemTy], [arr; idx], m1), seqPoint), body, m2, freeVars), m, ty) -> - let body = Expr.Let(TBind(forVarLoop, mkCallArrayGet g m1 elemTy arr idx, seqPoint), body, m2, freeVars) + let body = Expr.Let(TBind(forVarLoop, mkCallArrayGet g m1 1 elemTy arr [idx], seqPoint), body, m2, freeVars) let expr = Expr.Lambda(newUnique(), a, b, args, body, m, ty) Some (arr, elemTy, expr) | _ -> None @@ -628,13 +628,10 @@ and ConvLValueExprCore cenv env expr = | TOp.ValFieldGetAddr(rfref),_,_ -> ConvRFieldGet cenv env m rfref tyargs args | TOp.ILAsm([ I_ldflda(fspec) ],_rtys),_,_ -> ConvLdfld cenv env m fspec tyargs args | TOp.ILAsm([ I_ldsflda(fspec) ],_rtys),_,_ -> ConvLdfld cenv env m fspec tyargs args - | TOp.ILAsm(([ I_ldelema(_ro,_isNativePtr,shape,_tyarg) ] ),_), (arr::idxs), [elemty] -> - match shape.Rank, idxs with - | 1, [idx1] -> ConvExpr cenv env (mkCallArrayGet cenv.g m elemty arr idx1) - | 2, [idx1; idx2] -> ConvExpr cenv env (mkCallArray2DGet cenv.g m elemty arr idx1 idx2) - | 3, [idx1; idx2; idx3] -> ConvExpr cenv env (mkCallArray3DGet cenv.g m elemty arr idx1 idx2 idx3) - | 4, [idx1; idx2; idx3; idx4] -> ConvExpr cenv env (mkCallArray4DGet cenv.g m elemty arr idx1 idx2 idx3 idx4) - | _ -> ConvExpr cenv env expr + | TOp.ILAsm(([ I_ldelema(_ro,_isNativePtr,shape,_tyarg) ] ),_), (arr::idxs), [elemty] + when shape.Rank = List.length idxs -> + assert (shape.Rank >= 1 && shape.Rank <= 32) + ConvExpr cenv env (mkCallArrayGet cenv.g m shape.Rank elemty arr idxs) | _ -> ConvExpr cenv env expr | _ -> ConvExpr cenv env expr diff --git a/src/fsharp/env.fs b/src/fsharp/env.fs index cc6016bb34..227a6bed59 100644 --- a/src/fsharp/env.fs +++ b/src/fsharp/env.fs @@ -194,10 +194,7 @@ type public TcGlobals = measureproduct_tcr : TyconRef measureinverse_tcr : TyconRef measureone_tcr : TyconRef - il_arr1_tcr : TyconRef; - il_arr2_tcr : TyconRef; - il_arr3_tcr : TyconRef; - il_arr4_tcr : TyconRef; + il_arr_tcr_map : TyconRef[]; tuple1_tcr : TyconRef; tuple2_tcr : TyconRef; tuple3_tcr : TyconRef; @@ -486,10 +483,7 @@ type public TcGlobals = range_op_vref : ValRef; range_int32_op_vref : ValRef; //range_step_op_vref : ValRef; - array_get_vref : ValRef; - array2D_get_vref : ValRef; - array3D_get_vref : ValRef; - array4D_get_vref : ValRef; + array_get_vref_map : ValRef[]; seq_collect_vref : ValRef; seq_collect_info : IntrinsicValRef; seq_using_info : IntrinsicValRef; @@ -517,12 +511,8 @@ type public TcGlobals = lazy_force_info : IntrinsicValRef; lazy_create_info : IntrinsicValRef; - - array_get_info : IntrinsicValRef; array_length_info : IntrinsicValRef; - array2D_get_info : IntrinsicValRef; - array3D_get_info : IntrinsicValRef; - array4D_get_info : IntrinsicValRef; + array_get_info_map : IntrinsicValRef[]; unpickle_quoted_info : IntrinsicValRef; cast_quotation_info : IntrinsicValRef; lift_value_info : IntrinsicValRef; @@ -630,10 +620,14 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa let query_builder_tcref = mk_MFLinq_tcref fslibCcu "QueryBuilder" let querySource_tcr = mk_MFLinq_tcref fslibCcu "QuerySource`2" let linqExpression_tcr = mkSysTyconRef ["System";"Linq";"Expressions"] "Expression`1" - let il_arr1_tcr = mk_MFCore_tcref fslibCcu "[]`1" - let il_arr2_tcr = mk_MFCore_tcref fslibCcu "[,]`1"; - let il_arr3_tcr = mk_MFCore_tcref fslibCcu "[,,]`1"; - let il_arr4_tcr = mk_MFCore_tcref fslibCcu "[,,,]`1"; + + let il_arr_tcr_map = + Array.init 32 (fun idx -> + let type_sig = + let rank = idx + 1 + if rank = 1 then "[]`1" + else "[" + (String.replicate (rank - 1) ",") + "]`1" + mk_MFCore_tcref fslibCcu type_sig) let bool_ty = mkNonGenericTy bool_tcr let int_ty = mkNonGenericTy int_tcr @@ -691,10 +685,9 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa let mkSeqTy ty1 = TType_app(seq_tcr,[ty1]) let mkQuerySourceTy ty1 ty2 = TType_app(querySource_tcr,[ty1; ty2]) let tcref_System_Collections_IEnumerable = mkSysTyconRef sysCollections "IEnumerable"; - let mkArrayType ty = TType_app(il_arr1_tcr, [ty]) - let mk_array2_typ ty = TType_app(il_arr2_tcr, [ty]) - let mk_array3_typ ty = TType_app(il_arr3_tcr, [ty]) - let mk_array4_typ ty = TType_app(il_arr4_tcr, [ty]) + let mkArrayType rank (ty : TType) : TType = + assert (rank >= 1 && rank <= 32) + TType_app(il_arr_tcr_map.[rank - 1], [ty]) let mkLazyTy ty = TType_app(lazy_tcr, [ty]) let mkPrintfFormatTy aty bty cty dty ety = TType_app(format_tcr, [aty;bty;cty;dty; ety]) @@ -914,9 +907,19 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa let enum_info = makeIntrinsicValRef(fslib_MFOperators_nleref, "enum" ,None ,Some "ToEnum" ,[vara], ([[int_ty]],varaTy)) let range_op_info = makeIntrinsicValRef(fslib_MFOperators_nleref, "op_Range" ,None ,None ,[vara], ([[varaTy];[varaTy]],mkSeqTy varaTy)) let range_int32_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeInt32" ,None ,None ,[], ([[int_ty];[int_ty];[int_ty]],mkSeqTy int_ty)) - let array2D_get_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "GetArray2D" ,None ,None ,[vara], ([[mk_array2_typ varaTy];[int_ty]; [int_ty]],varaTy)) - let array3D_get_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "GetArray3D" ,None ,None ,[vara], ([[mk_array3_typ varaTy];[int_ty]; [int_ty]; [int_ty]],varaTy)) - let array4D_get_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "GetArray4D" ,None ,None ,[vara], ([[mk_array4_typ varaTy];[int_ty]; [int_ty]; [int_ty]; [int_ty]],varaTy)) + + let array_get_info_map = + Array.init 32 (fun idx -> + let rank = idx + 1 + let intrinsicMethodName = + if rank = 1 then "GetArray" + else sprintf "GetArray%iD" rank + let argTypes = + [mkArrayType rank varaTy] :: (List.replicate rank [int_ty]) + makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, intrinsicMethodName ,None ,None ,[vara], (argTypes, varaTy))) + + let array_length_info = makeIntrinsicValRef(fslib_MFArrayModule_nleref, "length" ,None ,Some "Length" ,[vara], ([[mkArrayType 1 varaTy]], varaTy)) + let seq_collect_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "collect" ,None ,Some "Collect",[vara;varb;varc],([[varaTy --> varbTy]; [mkSeqTy varaTy]], mkSeqTy varcTy)) let seq_delay_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "delay" ,None ,Some "Delay" ,[varb], ([[unit_ty --> mkSeqTy varbTy]], mkSeqTy varbTy)) let seq_append_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "append" ,None ,Some "Append" ,[varb], ([[mkSeqTy varbTy]; [mkSeqTy varbTy]], mkSeqTy varbTy)) @@ -925,7 +928,7 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa let seq_finally_info = makeIntrinsicValRef(fslib_MFRuntimeHelpers_nleref, "EnumerateThenFinally" ,None ,None ,[varb], ([[mkSeqTy varbTy]; [unit_ty --> unit_ty]], mkSeqTy varbTy)) let seq_of_functions_info = makeIntrinsicValRef(fslib_MFRuntimeHelpers_nleref, "EnumerateFromFunctions" ,None ,None ,[vara;varb],([[unit_ty --> varaTy]; [varaTy --> bool_ty]; [varaTy --> varbTy]], mkSeqTy varbTy)) let create_event_info = makeIntrinsicValRef(fslib_MFRuntimeHelpers_nleref, "CreateEvent" ,None ,None ,[vara;varb],([[varaTy --> unit_ty]; [varaTy --> unit_ty]; [(obj_ty --> (varbTy --> unit_ty)) --> varaTy]], TType_app (fslib_IEvent2_tcr, [varaTy;varbTy]))) - let seq_to_array_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "toArray" ,None ,Some "ToArray",[varb], ([[mkSeqTy varbTy]], mkArrayType varbTy)) + let seq_to_array_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "toArray" ,None ,Some "ToArray",[varb], ([[mkSeqTy varbTy]], mkArrayType 1 varbTy)) let seq_to_list_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "toList" ,None ,Some "ToList" ,[varb], ([[mkSeqTy varbTy]], mkListTy varbTy)) let seq_map_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "map" ,None ,Some "Map" ,[vara;varb],([[varaTy --> varbTy]; [mkSeqTy varaTy]], mkSeqTy varbTy)) let seq_singleton_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "singleton" ,None ,Some "Singleton" ,[vara], ([[varaTy]], mkSeqTy varaTy)) @@ -940,9 +943,7 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa let splice_expr_info = makeIntrinsicValRef(fslib_MFExtraTopLevelOperators_nleref, "op_Splice" ,None ,None ,[vara], ([[mkQuotedExprTy varaTy]], varaTy)) let splice_raw_expr_info = makeIntrinsicValRef(fslib_MFExtraTopLevelOperators_nleref, "op_SpliceUntyped" ,None ,None ,[vara], ([[mkRawQuotedExprTy]], varaTy)) let new_decimal_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "MakeDecimal" ,None ,None ,[], ([[int_ty]; [int_ty]; [int_ty]; [bool_ty]; [byte_ty]], decimal_ty)) - let array_get_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "GetArray" ,None ,None ,[vara], ([[mkArrayType varaTy]; [int_ty]], varaTy)) - let array_length_info = makeIntrinsicValRef(fslib_MFArrayModule_nleref, "length" ,None ,Some "Length" ,[vara], ([[mkArrayType varaTy]], varaTy)) - let unpickle_quoted_info = makeIntrinsicValRef(fslib_MFQuotations_nleref, "Deserialize" ,Some "Expr" ,None ,[], ([[system_Type_typ ;mkListTy system_Type_typ ;mkListTy mkRawQuotedExprTy ; mkArrayType byte_ty]], mkRawQuotedExprTy )) + let unpickle_quoted_info = makeIntrinsicValRef(fslib_MFQuotations_nleref, "Deserialize" ,Some "Expr" ,None ,[], ([[system_Type_typ ;mkListTy system_Type_typ ;mkListTy mkRawQuotedExprTy ; mkArrayType 1 byte_ty]], mkRawQuotedExprTy )) let cast_quotation_info = makeIntrinsicValRef(fslib_MFQuotations_nleref, "Cast" ,Some "Expr" ,None ,[vara], ([[mkRawQuotedExprTy]], mkQuotedExprTy varaTy)) let lift_value_info = makeIntrinsicValRef(fslib_MFQuotations_nleref, "Value" ,Some "Expr" ,None ,[vara], ([[varaTy]], mkRawQuotedExprTy)) let query_value_info = makeIntrinsicValRef(fslib_MFExtraTopLevelOperators_nleref, "query" ,None ,None ,[], ([], mkQueryBuilderTy) ) @@ -986,7 +987,7 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa map_tcr_canon = mk_MFCollections_tcref fslibCcu "Map`2"; lazy_tcr_canon = lazy_tcr; refcell_tcr_nice = mk_MFCore_tcref fslibCcu "ref`1"; - array_tcr_nice = il_arr1_tcr; + array_tcr_nice = il_arr_tcr_map.[0]; option_tcr_nice = option_tcr_nice; list_tcr_nice = list_tcr_nice; lazy_tcr_nice = lazy_tcr_nice; @@ -1032,10 +1033,7 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa measureproduct_tcr = mk_MFCompilerServices_tcref fslibCcu "MeasureProduct`2"; measureinverse_tcr = mk_MFCompilerServices_tcref fslibCcu "MeasureInverse`1"; measureone_tcr = mk_MFCompilerServices_tcref fslibCcu "MeasureOne"; - il_arr1_tcr = il_arr1_tcr; - il_arr2_tcr = il_arr2_tcr; - il_arr3_tcr = il_arr3_tcr; - il_arr4_tcr = il_arr4_tcr; + il_arr_tcr_map = il_arr_tcr_map; tuple1_tcr = tuple1_tcr; tuple2_tcr = tuple2_tcr; tuple3_tcr = tuple3_tcr; @@ -1356,10 +1354,7 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa range_int32_op_vref = ValRefForIntrinsic range_int32_op_info; //range_step_op_vref = ValRefForIntrinsic range_step_op_info; array_length_info = array_length_info - array_get_vref = ValRefForIntrinsic array_get_info; - array2D_get_vref = ValRefForIntrinsic array2D_get_info; - array3D_get_vref = ValRefForIntrinsic array3D_get_info; - array4D_get_vref = ValRefForIntrinsic array4D_get_info; + array_get_vref_map = array_get_info_map |> Array.map ValRefForIntrinsic; seq_singleton_vref = ValRefForIntrinsic seq_singleton_info; seq_collect_vref = ValRefForIntrinsic seq_collect_info; seq_collect_info = seq_collect_info; @@ -1401,10 +1396,7 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa create_event_info = create_event_info; seq_to_list_info = seq_to_list_info; seq_to_array_info = seq_to_array_info; - array_get_info = array_get_info; - array2D_get_info = array2D_get_info; - array3D_get_info = array3D_get_info; - array4D_get_info = array4D_get_info; + array_get_info_map = array_get_info_map; unpickle_quoted_info = unpickle_quoted_info; cast_quotation_info = cast_quotation_info; lift_value_info = lift_value_info; diff --git a/src/fsharp/patcompile.fs b/src/fsharp/patcompile.fs index 3b18175425..54ea7cb69e 100644 --- a/src/fsharp/patcompile.fs +++ b/src/fsharp/patcompile.fs @@ -1098,7 +1098,7 @@ let CompilePatternBasic | TPat_array (argpats,ty,_) -> match discrim with | Test.ArrayLength (n,_) when List.length argpats = n -> - let accessf' j tpinst e' = mkCallArrayGet g exprm ty (accessf tpinst e') (mkInt g exprm j) + let accessf' j tpinst e' = mkCallArrayGet g exprm 1 ty (accessf tpinst e') [(mkInt g exprm j)] mkSubFrontiers path accessf' active' argpats (fun path j -> PathArray(path,ty,List.length argpats,j)) // Successful length tests refute all other lengths | Test.ArrayLength _ -> diff --git a/src/fsharp/tastops.fs b/src/fsharp/tastops.fs index d2e6c1515b..3f40bb53a1 100644 --- a/src/fsharp/tastops.fs +++ b/src/fsharp/tastops.fs @@ -528,14 +528,13 @@ let rec sizeMeasure g ms = let mkNativePtrType g ty = TType_app (g.nativeptr_tcr, [ty]) let mkByrefTy g ty = TType_app (g.byref_tcr, [ty]) -let mkArrayTy g n ty m = - if n = 1 then TType_app (g.il_arr1_tcr, [ty]) - elif n = 2 then TType_app (g.il_arr2_tcr, [ty]) - elif n = 3 then TType_app (g.il_arr3_tcr, [ty]) - elif n = 4 then TType_app (g.il_arr4_tcr, [ty]) - else - errorR(Error(FSComp.SR.tastopsMaxArrayFour(),m)); - TType_app (g.il_arr4_tcr, [ty]) +let mkArrayTy g rank ty m = + if rank < 1 || rank > 32 then + // TODO : Provide a better message for zero/negative inputs here. + errorR(Error(FSComp.SR.tastopsMaxArrayThirtyTwo(),m)); + TType_app (g.il_arr_tcr_map.[3], [ty]) + else + TType_app (g.il_arr_tcr_map.[rank - 1], [ty]) //-------------------------------------------------------------------------- @@ -1398,18 +1397,16 @@ let IsCompiledAsStaticPropertyWithField g (v:Val) = // Multi-dimensional array types... //------------------------------------------------------------------------- -let isArrayTyconRef g tcr = - tyconRefEq g tcr g.il_arr1_tcr || - tyconRefEq g tcr g.il_arr2_tcr || - tyconRefEq g tcr g.il_arr3_tcr || - tyconRefEq g tcr g.il_arr4_tcr +let isArrayTyconRef g tcr = + g.il_arr_tcr_map + |> Array.exists (tyconRefEq g tcr) -let rankOfArrayTyconRef g tcr = - if tyconRefEq g tcr g.il_arr1_tcr then 1 - elif tyconRefEq g tcr g.il_arr2_tcr then 2 - elif tyconRefEq g tcr g.il_arr3_tcr then 3 - elif tyconRefEq g tcr g.il_arr4_tcr then 4 - else failwith "rankOfArrayTyconRef: unsupported array rank" +let rankOfArrayTyconRef g tcr = + match g.il_arr_tcr_map |> Array.tryFindIndex (tyconRefEq g tcr) with + | Some idx -> + idx + 1 + | None -> + failwith "rankOfArrayTyconRef: unsupported array rank" //------------------------------------------------------------------------- // Misc functions on F# types @@ -1434,7 +1431,7 @@ let isByrefLikeTyconRef g tcref = isTypeConstructorEqualToOptional g g.system_RuntimeArgumentHandle_tcref tcref let isArrayTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> isArrayTyconRef g tcref | _ -> false) -let isArray1DTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> tyconRefEq g tcref g.il_arr1_tcr | _ -> false) +let isArray1DTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> tyconRefEq g tcref g.il_arr_tcr_map.[0] | _ -> false) let isUnitTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> tyconRefEq g g.unit_tcr_canon tcref | _ -> false) let isObjTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> tyconRefEq g g.system_Object_tcref tcref | _ -> false) let isVoidTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> tyconRefEq g g.system_Void_tcref tcref | _ -> false) @@ -5357,22 +5354,16 @@ let rec mkExprAddrOfExpr g mustTakeAddress useReadonlyForGenericArrayAddress mut (fun x -> x), mkStaticRecdFieldGetAddr(rfref,tinst,m) // LVALUE: "e.[n]" where e is an array of structs - | Expr.App(Expr.Val(vf,_,_),_,[elemTy],[aexpr;nexpr],_) - when (valRefEq g vf g.array_get_vref) -> - - let shape = ILArrayShape.SingleDimensional - let readonly = if isTyparTy g elemTy && useReadonlyForGenericArrayAddress then ReadonlyAddress else NormalAddress - let isNativePtr = - match addrExprVal with - | Some(vf) -> valRefEq g vf g.addrof2_vref - | _ -> false - (fun x -> x), Expr.Op (TOp.ILAsm ([IL.I_ldelema(readonly,isNativePtr,shape,mkILTyvarTy 0us)],[mkByrefTy g elemTy]), [elemTy],[aexpr;nexpr],m) - - // LVALUE: "e.[n1,n2]", "e.[n1,n2,n3]", "e.[n1,n2,n3,n4]" where e is an array of structs - | Expr.App(Expr.Val(vf,_,_),_,[elemTy],(aexpr::args),_) - when (valRefEq g vf g.array2D_get_vref || valRefEq g vf g.array3D_get_vref || valRefEq g vf g.array4D_get_vref) -> - - let shape = ILArrayShape.FromRank args.Length + // LVALUE: "e.[n1,n2]", "e.[n1,n2,n3]", "e.[n1,n2,n3,n4]", etc. where e is an array of structs + | Expr.App(Expr.Val(vf,_,_),_,[elemTy],(aexpr::args),_) + when (g.array_get_vref_map |> Array.exists (valRefEq g vf)) -> + + // Handle single-dimensional (rank 1) arrays separately. + let shape = + if valRefEq g vf g.array_get_vref_map.[0] then + ILArrayShape.SingleDimensional + else + ILArrayShape.FromRank args.Length let readonly = if isTyparTy g elemTy && useReadonlyForGenericArrayAddress then ReadonlyAddress else NormalAddress let isNativePtr = match addrExprVal with @@ -5858,10 +5849,12 @@ let mkCallGenericHashWithComparerOuter g m ty comp e1 = mkApps g (ty let mkCallSubtractionOperator g m ty e1 e2 = mkApps g (typedExprForIntrinsic g m g.unchecked_subtraction_info, [[ty; ty; ty]], [e1;e2], m) let mkCallArrayLength g m ty el = mkApps g (typedExprForIntrinsic g m g.array_length_info, [[ty]], [el], m) -let mkCallArrayGet g m ty e1 e2 = mkApps g (typedExprForIntrinsic g m g.array_get_info, [[ty]], [ e1 ; e2 ], m) -let mkCallArray2DGet g m ty e1 idx1 idx2 = mkApps g (typedExprForIntrinsic g m g.array2D_get_info, [[ty]], [ e1 ; idx1; idx2 ], m) -let mkCallArray3DGet g m ty e1 idx1 idx2 idx3 = mkApps g (typedExprForIntrinsic g m g.array3D_get_info, [[ty]], [ e1 ; idx1; idx2; idx3 ], m) -let mkCallArray4DGet g m ty e1 idx1 idx2 idx3 idx4 = mkApps g (typedExprForIntrinsic g m g.array4D_get_info, [[ty]], [ e1 ; idx1; idx2; idx3; idx4 ], m) + +let mkCallArrayGet g m rank ty e1 indices = + assert (rank = List.length indices) + assert (rank >= 1 && rank <= 32) + mkApps g (typedExprForIntrinsic g m g.array_get_info_map.[rank - 1], [[ty]], e1 :: indices, m) + let mkCallNewDecimal g m (e1,e2,e3,e4,e5) = mkApps g (typedExprForIntrinsic g m g.new_decimal_info, [], [ e1;e2;e3;e4;e5 ], m) let mkCallNewFormat g m aty bty cty dty ety e1 = mkApps g (typedExprForIntrinsic g m g.new_format_info, [[aty;bty;cty;dty;ety]], [ e1 ], m) @@ -6680,6 +6673,20 @@ let typarEnc _g (gtpsType,gtpsMethod) typar = | None -> warning(InternalError("Typar not found during XmlDoc generation",typar.Range)) "``0" // REVIEW: this should be ERROR not WARNING? +/// IL array type encodings. The array index is (rank - 1). +let private arrayTypeEncodings = + Array.init 32 (fun idx -> + let rank = idx + 1 + if rank = 1 then + // The easy case + "[]" + else + // REVIEW + // In fact IL supports 3 kinds of multidimensional arrays, and each kind of array has its own xmldoc spec. + // We don't support all these, and instead always pull xmldocs for 0-based-arbitrary-length ("0:") multidimensional arrays. + // This is probably the 99% case anyway. + "[" + System.String.Join (",", Array.create rank "0:") + "]") + let rec typeEnc g (gtpsType,gtpsMethod) ty = if verbose then dprintf "--> typeEnc"; match (stripTyEqns g ty) with @@ -6687,18 +6694,12 @@ let rec typeEnc g (gtpsType,gtpsMethod) ty = "Microsoft.FSharp.Core.FSharpTypeFunc" | _ when isArrayTy g ty -> let tcref,tinst = destAppTy g ty - let arraySuffix = - match rankOfArrayTyconRef g tcref with - // The easy case - | 1 -> "[]" - // REVIEW - // In fact IL supports 3 kinds of multidimensional arrays, and each kind of array has its own xmldoc spec. - // We don't support all these, and instead always pull xmldocs for 0-based-arbitrary-length ("0:") multidimensional arrays. - // This is probably the 99% case anyway. - | 2 -> "[0:,0:]" - | 3 -> "[0:,0:,0:]" - | 4 -> "[0:,0:,0:,0:]" - | _ -> failwith "impossible: rankOfArrayTyconRef: unsupported array rank" + let arraySuffix = + let arrayRank = rankOfArrayTyconRef g tcref + if arrayRank >= 1 && arrayRank <= 32 then + arrayTypeEncodings.[arrayRank - 1] + else + failwith "impossible: rankOfArrayTyconRef: unsupported array rank" typeEnc g (gtpsType,gtpsMethod) (List.head tinst) ^ arraySuffix | TType_ucase (UCRef(tcref,_),tinst) | TType_app (tcref,tinst) -> diff --git a/src/fsharp/tastops.fsi b/src/fsharp/tastops.fsi index ecbe9fc0dd..f55b8e20a5 100644 --- a/src/fsharp/tastops.fsi +++ b/src/fsharp/tastops.fsi @@ -1126,10 +1126,7 @@ val mkCallTypeDefOf : TcGlobals -> range -> TType -> Expr val mkCallCreateInstance : TcGlobals -> range -> TType -> Expr val mkCallCreateEvent : TcGlobals -> range -> TType -> TType -> Expr -> Expr -> Expr -> Expr val mkCallArrayLength : TcGlobals -> range -> TType -> Expr -> Expr -val mkCallArrayGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -val mkCallArray2DGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -val mkCallArray3DGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -> Expr -val mkCallArray4DGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -> Expr -> Expr +val mkCallArrayGet : TcGlobals -> range -> int -> TType -> Expr -> Expr list -> Expr val mkCallRaise : TcGlobals -> range -> TType -> Expr -> Expr val mkCallGenericComparisonWithComparerOuter : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr From 5922b61d7daaa84da61c1bb745f68f57fced1342 Mon Sep 17 00:00:00 2001 From: Jack Pappas Date: Thu, 3 Jul 2014 23:00:19 -0400 Subject: [PATCH 03/20] Implemented additional cases in parser to support zero-based, rank 5-32 arrays. Modified the test case to check that the type signature for a higher-ranking array is now parsed without errors. --- src/fsharp/pars.fsy | 84 +++++++++++++++++++ .../typecheck/full-rank-arrays/test.fsx | 5 ++ 2 files changed, 89 insertions(+) diff --git a/src/fsharp/pars.fsy b/src/fsharp/pars.fsy index 35324dfe3c..55221825b3 100644 --- a/src/fsharp/pars.fsy +++ b/src/fsharp/pars.fsy @@ -4274,6 +4274,90 @@ arrayTypeSuffix: | LBRACK COMMA COMMA COMMA RBRACK { 4 } + + | LBRACK COMMA COMMA COMMA COMMA RBRACK + { 5 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA RBRACK + { 6 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 7 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 8 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 9 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 10 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 11 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 12 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 13 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 14 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 15 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 16 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 17 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 18 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 19 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 20 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 21 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 22 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 23 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 24 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 25 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 26 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 27 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 28 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 29 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 30 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 31 } + + | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK + { 32 } appTypePrefixArguments: | typeArgActual COMMA typeArgActual typeArgListElements diff --git a/tests/fsharp/typecheck/full-rank-arrays/test.fsx b/tests/fsharp/typecheck/full-rank-arrays/test.fsx index 99e1c0d1e5..906c03318f 100644 --- a/tests/fsharp/typecheck/full-rank-arrays/test.fsx +++ b/tests/fsharp/typecheck/full-rank-arrays/test.fsx @@ -21,6 +21,11 @@ type Class1() = member this.Z = let foo = ClassWithArrayCtor ([| 1;3;5;7 |]) () + + member this.W (foo : int[,,,,,,,,,,]) = + printfn "Hello World!" + () + (* avoid ;; -- to avoid fsi error recovery *) let _ = From 93d7b98faf4b5186ef94dea5cf0dadb69b32cf89 Mon Sep 17 00:00:00 2001 From: ReedCopsey Date: Fri, 22 Aug 2014 13:31:18 -0700 Subject: [PATCH 04/20] Updated all templates (except tutorial) to include AssemblyInfo.fs setup in the same manner as default C# project templates --- .../ConsoleProjectTemplates.csproj | 1 + .../ConsoleApplication/AssemblyInfo.fs | 41 +++++++++++++++++++ .../ConsoleApplication.fsproj | 1 + .../fsConsoleApplication.vstemplate | 1 + .../LibraryProjectTemplates.csproj | 1 + .../ProjectTemplates/Library/AssemblyInfo.fs | 41 +++++++++++++++++++ .../ProjectTemplates/Library/Library.fsproj | 1 + .../Library/fsLibrary.vstemplate | 1 + .../NetCore259ProjectTemplates.csproj | 1 + .../NETCorePortableLibrary/AssemblyInfo.fs | 35 ++++++++++++++++ .../PortableLibrary.fsproj | 1 + .../fsNETCore259PortableLibrary.vstemplate | 1 + .../NetCore78ProjectTemplates.csproj | 1 + .../NetCorePortableLibrary/AssemblyInfo.fs | 35 ++++++++++++++++ .../PortableLibrary.fsproj | 1 + .../fsNETCore78PortableLibrary.vstemplate | 1 + .../NetCoreProjectTemplates.csproj | 1 + .../NETCorePortableLibrary/AssemblyInfo.fs | 35 ++++++++++++++++ .../PortableLibrary.fsproj | 1 + .../fsNETCore7PortableLibrary.vstemplate | 1 + .../PortableLibraryProjectTemplates.csproj | 1 + .../PortableLibrary/AssemblyInfo.fs | 35 ++++++++++++++++ .../PortableLibrary/PortableLibrary.fsproj | 1 + .../fsPortableLibrary.vstemplate | 1 + .../SilverlightLibrary/AssemblyInfo.fs | 41 +++++++++++++++++++ .../SilverlightLibrary.fsproj | 1 + .../fsSilverlightLibrary.vstemplate | 1 + .../SilverlightProjectTemplates.csproj | 1 + 28 files changed, 284 insertions(+) create mode 100644 vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/AssemblyInfo.fs create mode 100644 vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/AssemblyInfo.fs create mode 100644 vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/AssemblyInfo.fs create mode 100644 vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/AssemblyInfo.fs create mode 100644 vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/AssemblyInfo.fs create mode 100644 vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/AssemblyInfo.fs create mode 100644 vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/AssemblyInfo.fs diff --git a/vsintegration/src/Templates/ConsoleProjectTemplates/ConsoleProjectTemplates.csproj b/vsintegration/src/Templates/ConsoleProjectTemplates/ConsoleProjectTemplates.csproj index 160ea70e5c..daaaf910f7 100644 --- a/vsintegration/src/Templates/ConsoleProjectTemplates/ConsoleProjectTemplates.csproj +++ b/vsintegration/src/Templates/ConsoleProjectTemplates/ConsoleProjectTemplates.csproj @@ -71,6 +71,7 @@ + diff --git a/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/AssemblyInfo.fs b/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/AssemblyInfo.fs new file mode 100644 index 0000000000..b8f71aa625 --- /dev/null +++ b/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace $safeprojectname$.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +(* General Information about an assembly is controlled through the following +set of attributes. Change these attribute values to modify the information +associated with an assembly. *) +[] +[] +[] +[] +[] +[] +[] +[] + +(* Setting ComVisible to false makes the types in this assembly not visible +to COM components. If you need to access a type in this assembly from +COM, set the ComVisible attribute to true on that type. *) +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +(* Version information for an assembly consists of the following four values: + + Major Version + Minor Version + Build Number + Revision + +You can specify all the values or you can default the Build and Revision Numbers +by using the '*' as shown below: +[] *) +[] +[] + +do + () \ No newline at end of file diff --git a/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/ConsoleApplication.fsproj b/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/ConsoleApplication.fsproj index b141b51f7b..4be2f4de38 100644 --- a/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/ConsoleApplication.fsproj +++ b/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/ConsoleApplication.fsproj @@ -54,6 +54,7 @@ $endif$ + diff --git a/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/fsConsoleApplication.vstemplate b/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/fsConsoleApplication.vstemplate index cde224c1a3..55b9389d8c 100644 --- a/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/fsConsoleApplication.vstemplate +++ b/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/fsConsoleApplication.vstemplate @@ -15,6 +15,7 @@ + AssemblyInfo.fs Program.fs App.config diff --git a/vsintegration/src/Templates/LibraryProjectTemplates/LibraryProjectTemplates.csproj b/vsintegration/src/Templates/LibraryProjectTemplates/LibraryProjectTemplates.csproj index fb68bd508f..0e43203c44 100644 --- a/vsintegration/src/Templates/LibraryProjectTemplates/LibraryProjectTemplates.csproj +++ b/vsintegration/src/Templates/LibraryProjectTemplates/LibraryProjectTemplates.csproj @@ -77,6 +77,7 @@ + diff --git a/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/AssemblyInfo.fs b/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/AssemblyInfo.fs new file mode 100644 index 0000000000..b8f71aa625 --- /dev/null +++ b/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace $safeprojectname$.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +(* General Information about an assembly is controlled through the following +set of attributes. Change these attribute values to modify the information +associated with an assembly. *) +[] +[] +[] +[] +[] +[] +[] +[] + +(* Setting ComVisible to false makes the types in this assembly not visible +to COM components. If you need to access a type in this assembly from +COM, set the ComVisible attribute to true on that type. *) +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +(* Version information for an assembly consists of the following four values: + + Major Version + Minor Version + Build Number + Revision + +You can specify all the values or you can default the Build and Revision Numbers +by using the '*' as shown below: +[] *) +[] +[] + +do + () \ No newline at end of file diff --git a/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/Library.fsproj b/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/Library.fsproj index 5aa4bb5729..1afb6f8d25 100644 --- a/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/Library.fsproj +++ b/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/Library.fsproj @@ -49,6 +49,7 @@ $endif$ + diff --git a/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/fsLibrary.vstemplate b/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/fsLibrary.vstemplate index e3935ea7dd..0dc7bb10a0 100644 --- a/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/fsLibrary.vstemplate +++ b/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/fsLibrary.vstemplate @@ -15,6 +15,7 @@ + AssemblyInfo.fs Library1.fs Script.fsx diff --git a/vsintegration/src/Templates/NetCore259ProjectTemplates/NetCore259ProjectTemplates.csproj b/vsintegration/src/Templates/NetCore259ProjectTemplates/NetCore259ProjectTemplates.csproj index 015ee77f7a..81c56fd9f8 100644 --- a/vsintegration/src/Templates/NetCore259ProjectTemplates/NetCore259ProjectTemplates.csproj +++ b/vsintegration/src/Templates/NetCore259ProjectTemplates/NetCore259ProjectTemplates.csproj @@ -77,6 +77,7 @@ + diff --git a/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/AssemblyInfo.fs b/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/AssemblyInfo.fs new file mode 100644 index 0000000000..aa8eebe5dc --- /dev/null +++ b/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/AssemblyInfo.fs @@ -0,0 +1,35 @@ +namespace $safeprojectname$.AssemblyInfo + +open System.Resources +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +(* General Information about an assembly is controlled through the following +set of attributes. Change these attribute values to modify the information +associated with an assembly. *) +[] +[] +[] +[] +[] +[] +[] +[] +[] + +(* Version information for an assembly consists of the following four values: + + Major Version + Minor Version + Build Number + Revision + +You can specify all the values or you can default the Build and Revision Numbers +by using the '*' as shown below: +[] *) +[] +[] + +do + () \ No newline at end of file diff --git a/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/PortableLibrary.fsproj b/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/PortableLibrary.fsproj index 49a40b7072..e68950f639 100644 --- a/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/PortableLibrary.fsproj +++ b/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/PortableLibrary.fsproj @@ -41,6 +41,7 @@ + diff --git a/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/fsNETCore259PortableLibrary.vstemplate b/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/fsNETCore259PortableLibrary.vstemplate index 83d40c5dfd..104191439c 100644 --- a/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/fsNETCore259PortableLibrary.vstemplate +++ b/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/fsNETCore259PortableLibrary.vstemplate @@ -15,6 +15,7 @@ + AssemblyInfo.fs PortableLibrary1.fs Script.fsx diff --git a/vsintegration/src/Templates/NetCore78ProjectTemplates/NetCore78ProjectTemplates.csproj b/vsintegration/src/Templates/NetCore78ProjectTemplates/NetCore78ProjectTemplates.csproj index 94ea3c8af4..81362dda5d 100644 --- a/vsintegration/src/Templates/NetCore78ProjectTemplates/NetCore78ProjectTemplates.csproj +++ b/vsintegration/src/Templates/NetCore78ProjectTemplates/NetCore78ProjectTemplates.csproj @@ -77,6 +77,7 @@ + diff --git a/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/AssemblyInfo.fs b/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/AssemblyInfo.fs new file mode 100644 index 0000000000..aa8eebe5dc --- /dev/null +++ b/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/AssemblyInfo.fs @@ -0,0 +1,35 @@ +namespace $safeprojectname$.AssemblyInfo + +open System.Resources +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +(* General Information about an assembly is controlled through the following +set of attributes. Change these attribute values to modify the information +associated with an assembly. *) +[] +[] +[] +[] +[] +[] +[] +[] +[] + +(* Version information for an assembly consists of the following four values: + + Major Version + Minor Version + Build Number + Revision + +You can specify all the values or you can default the Build and Revision Numbers +by using the '*' as shown below: +[] *) +[] +[] + +do + () \ No newline at end of file diff --git a/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/PortableLibrary.fsproj b/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/PortableLibrary.fsproj index 591b5d1683..94641d6cae 100644 --- a/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/PortableLibrary.fsproj +++ b/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/PortableLibrary.fsproj @@ -41,6 +41,7 @@ + diff --git a/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/fsNETCore78PortableLibrary.vstemplate b/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/fsNETCore78PortableLibrary.vstemplate index de90102e75..c03031a59f 100644 --- a/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/fsNETCore78PortableLibrary.vstemplate +++ b/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/fsNETCore78PortableLibrary.vstemplate @@ -15,6 +15,7 @@ + AssemblyInfo.fs PortableLibrary1.fs Script.fsx diff --git a/vsintegration/src/Templates/NetCoreProjectTemplates/NetCoreProjectTemplates.csproj b/vsintegration/src/Templates/NetCoreProjectTemplates/NetCoreProjectTemplates.csproj index 7948833e2a..7f281b70e5 100644 --- a/vsintegration/src/Templates/NetCoreProjectTemplates/NetCoreProjectTemplates.csproj +++ b/vsintegration/src/Templates/NetCoreProjectTemplates/NetCoreProjectTemplates.csproj @@ -77,6 +77,7 @@ + diff --git a/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/AssemblyInfo.fs b/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/AssemblyInfo.fs new file mode 100644 index 0000000000..aa8eebe5dc --- /dev/null +++ b/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/AssemblyInfo.fs @@ -0,0 +1,35 @@ +namespace $safeprojectname$.AssemblyInfo + +open System.Resources +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +(* General Information about an assembly is controlled through the following +set of attributes. Change these attribute values to modify the information +associated with an assembly. *) +[] +[] +[] +[] +[] +[] +[] +[] +[] + +(* Version information for an assembly consists of the following four values: + + Major Version + Minor Version + Build Number + Revision + +You can specify all the values or you can default the Build and Revision Numbers +by using the '*' as shown below: +[] *) +[] +[] + +do + () \ No newline at end of file diff --git a/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/PortableLibrary.fsproj b/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/PortableLibrary.fsproj index eb18b4e92f..4da953f2ba 100644 --- a/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/PortableLibrary.fsproj +++ b/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/PortableLibrary.fsproj @@ -41,6 +41,7 @@ + diff --git a/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/fsNETCore7PortableLibrary.vstemplate b/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/fsNETCore7PortableLibrary.vstemplate index 2974651d31..86a55d608c 100644 --- a/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/fsNETCore7PortableLibrary.vstemplate +++ b/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/fsNETCore7PortableLibrary.vstemplate @@ -15,6 +15,7 @@ + AssemblyInfo.fs PortableLibrary1.fs Script.fsx diff --git a/vsintegration/src/Templates/PortableLibraryProjectTemplates/PortableLibraryProjectTemplates.csproj b/vsintegration/src/Templates/PortableLibraryProjectTemplates/PortableLibraryProjectTemplates.csproj index b54925ba95..020a19bb2b 100644 --- a/vsintegration/src/Templates/PortableLibraryProjectTemplates/PortableLibraryProjectTemplates.csproj +++ b/vsintegration/src/Templates/PortableLibraryProjectTemplates/PortableLibraryProjectTemplates.csproj @@ -77,6 +77,7 @@ + diff --git a/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/AssemblyInfo.fs b/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/AssemblyInfo.fs new file mode 100644 index 0000000000..aa8eebe5dc --- /dev/null +++ b/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/AssemblyInfo.fs @@ -0,0 +1,35 @@ +namespace $safeprojectname$.AssemblyInfo + +open System.Resources +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +(* General Information about an assembly is controlled through the following +set of attributes. Change these attribute values to modify the information +associated with an assembly. *) +[] +[] +[] +[] +[] +[] +[] +[] +[] + +(* Version information for an assembly consists of the following four values: + + Major Version + Minor Version + Build Number + Revision + +You can specify all the values or you can default the Build and Revision Numbers +by using the '*' as shown below: +[] *) +[] +[] + +do + () \ No newline at end of file diff --git a/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/PortableLibrary.fsproj b/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/PortableLibrary.fsproj index 1c582ff90e..fe584d57bd 100644 --- a/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/PortableLibrary.fsproj +++ b/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/PortableLibrary.fsproj @@ -40,6 +40,7 @@ + diff --git a/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/fsPortableLibrary.vstemplate b/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/fsPortableLibrary.vstemplate index 3d32317af4..9dffb0eafb 100644 --- a/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/fsPortableLibrary.vstemplate +++ b/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/fsPortableLibrary.vstemplate @@ -15,6 +15,7 @@ + AssemblyInfo.fs PortableLibrary1.fs Script.fsx diff --git a/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/AssemblyInfo.fs b/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/AssemblyInfo.fs new file mode 100644 index 0000000000..4c04052ace --- /dev/null +++ b/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace $safeprojectname$.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +(* General Information about an assembly is controlled through the following +set of attributes. Change these attribute values to modify the information +associated with an assembly. *) +[] +[] +[] +[] +[] +[] +[] +[] + +(* Setting ComVisible to false makes the types in this assembly not visible +to COM components. If you need to access a type in this assembly from +COM, set the ComVisible attribute to true on that type. *) +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +(* Version information for an assembly consists of the following four values: + + Major Version + Minor Version + Build Number + Revision + +You can specify all the values or you can default the Build and Revision Numbers +by using the '*' as shown below: +[] *) +[] +[] + +do + () \ No newline at end of file diff --git a/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/SilverlightLibrary.fsproj b/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/SilverlightLibrary.fsproj index 3696f7f3e0..ecaa7dbfc2 100644 --- a/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/SilverlightLibrary.fsproj +++ b/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/SilverlightLibrary.fsproj @@ -54,6 +54,7 @@ + diff --git a/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/fsSilverlightLibrary.vstemplate b/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/fsSilverlightLibrary.vstemplate index 6303391aed..7e78c338c0 100644 --- a/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/fsSilverlightLibrary.vstemplate +++ b/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/fsSilverlightLibrary.vstemplate @@ -15,6 +15,7 @@ + AssemblyInfo.fs Library1.fs Script.fsx diff --git a/vsintegration/src/Templates/SilverlightProjectTemplates/SilverlightProjectTemplates.csproj b/vsintegration/src/Templates/SilverlightProjectTemplates/SilverlightProjectTemplates.csproj index 957e7cf7a7..fa3c108ad4 100644 --- a/vsintegration/src/Templates/SilverlightProjectTemplates/SilverlightProjectTemplates.csproj +++ b/vsintegration/src/Templates/SilverlightProjectTemplates/SilverlightProjectTemplates.csproj @@ -76,6 +76,7 @@ + From 29551fb3bc9fe31cd9b7368222788a56f66d7d46 Mon Sep 17 00:00:00 2001 From: Enrico Sada Date: Fri, 5 Sep 2014 10:05:12 +0200 Subject: [PATCH 05/20] fix url of fsharp.org website in vs templates --- tests/fsharp/core/portable/portablelibrary1/script.fsx | 2 +- .../ProjectTemplates/ConsoleApplication/Program.fs | 2 +- .../LibraryProjectTemplates/ProjectTemplates/Library/Script.fsx | 2 +- .../ProjectTemplates/NETCorePortableLibrary/Script.fsx | 2 +- .../ProjectTemplates/NetCorePortableLibrary/Script.fsx | 2 +- .../ProjectTemplates/NETCorePortableLibrary/Script.fsx | 2 +- .../ProjectTemplates/PortableLibrary/Script.fsx | 2 +- .../ProjectTemplates/SilverlightLibrary/Script.fsx | 2 +- .../ProjectTemplates/Tutorial/Tutorial.fsx | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/fsharp/core/portable/portablelibrary1/script.fsx b/tests/fsharp/core/portable/portablelibrary1/script.fsx index b47e38a2f9..c6459e36e2 100644 --- a/tests/fsharp/core/portable/portablelibrary1/script.fsx +++ b/tests/fsharp/core/portable/portablelibrary1/script.fsx @@ -1,4 +1,4 @@ -// Learn more about F# at http://fsharp.net. See the 'F# Tutorial' project +// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project // for more guidance on F# programming. #load "PortableLibrary1.fs" diff --git a/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/Program.fs b/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/Program.fs index 4aa6a19242..2bcf7f9899 100644 --- a/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/Program.fs +++ b/vsintegration/src/Templates/ConsoleProjectTemplates/ProjectTemplates/ConsoleApplication/Program.fs @@ -1,4 +1,4 @@ -// Learn more about F# at http://fsharp.net +// Learn more about F# at http://fsharp.org // See the 'F# Tutorial' project for more help. [] diff --git a/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/Script.fsx b/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/Script.fsx index b0271a127d..de578c374d 100644 --- a/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/Script.fsx +++ b/vsintegration/src/Templates/LibraryProjectTemplates/ProjectTemplates/Library/Script.fsx @@ -1,4 +1,4 @@ -// Learn more about F# at http://fsharp.net. See the 'F# Tutorial' project +// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project // for more guidance on F# programming. #load "Library1.fs" diff --git a/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/Script.fsx b/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/Script.fsx index 92ed2ffdfa..82377f6da4 100644 --- a/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/Script.fsx +++ b/vsintegration/src/Templates/NetCore259ProjectTemplates/ProjectTemplates/NETCorePortableLibrary/Script.fsx @@ -1,4 +1,4 @@ -// Learn more about F# at http://fsharp.net. See the 'F# Tutorial' project +// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project // for more guidance on F# programming. #load "PortableLibrary1.fs" diff --git a/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/Script.fsx b/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/Script.fsx index 92ed2ffdfa..82377f6da4 100644 --- a/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/Script.fsx +++ b/vsintegration/src/Templates/NetCore78ProjectTemplates/ProjectTemplates/NetCorePortableLibrary/Script.fsx @@ -1,4 +1,4 @@ -// Learn more about F# at http://fsharp.net. See the 'F# Tutorial' project +// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project // for more guidance on F# programming. #load "PortableLibrary1.fs" diff --git a/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/Script.fsx b/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/Script.fsx index 92ed2ffdfa..82377f6da4 100644 --- a/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/Script.fsx +++ b/vsintegration/src/Templates/NetCoreProjectTemplates/ProjectTemplates/NETCorePortableLibrary/Script.fsx @@ -1,4 +1,4 @@ -// Learn more about F# at http://fsharp.net. See the 'F# Tutorial' project +// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project // for more guidance on F# programming. #load "PortableLibrary1.fs" diff --git a/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/Script.fsx b/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/Script.fsx index 92ed2ffdfa..82377f6da4 100644 --- a/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/Script.fsx +++ b/vsintegration/src/Templates/PortableLibraryProjectTemplates/ProjectTemplates/PortableLibrary/Script.fsx @@ -1,4 +1,4 @@ -// Learn more about F# at http://fsharp.net. See the 'F# Tutorial' project +// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project // for more guidance on F# programming. #load "PortableLibrary1.fs" diff --git a/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/Script.fsx b/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/Script.fsx index 1645346cbc..8c20b249d1 100644 --- a/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/Script.fsx +++ b/vsintegration/src/Templates/SilverlightProjectTemplates/ProjectTemplates/SilverlightLibrary/Script.fsx @@ -1,4 +1,4 @@ -// Learn more about F# at http://fsharp.net. See the 'F# Tutorial' project +// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project // for more guidance on F# programming. #load "Library1.fs" diff --git a/vsintegration/src/Templates/TutorialProjectTemplates/ProjectTemplates/Tutorial/Tutorial.fsx b/vsintegration/src/Templates/TutorialProjectTemplates/ProjectTemplates/Tutorial/Tutorial.fsx index 6ae98c213d..30b25fe0a9 100644 --- a/vsintegration/src/Templates/TutorialProjectTemplates/ProjectTemplates/Tutorial/Tutorial.fsx +++ b/vsintegration/src/Templates/TutorialProjectTemplates/ProjectTemplates/Tutorial/Tutorial.fsx @@ -6,7 +6,7 @@ // ******************************************************************************************************* // // For more about F#, see: -// http://fsharp.net +// http://fsharp.org // // For additional templates to use with F#, see the 'Online Templates' in Visual Studio, // 'New Project' --> 'Online Templates' From f436f27680f984a64c12152fafbaf20f6372a35d Mon Sep 17 00:00:00 2001 From: Anh-Dung Phan Date: Sun, 13 Jul 2014 13:52:56 +0000 Subject: [PATCH 06/20] Add keyboard shortcuts for FSI reset and clear all --- .../src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct b/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct index d3f9d62451..8105a01e81 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct +++ b/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct @@ -250,7 +250,14 @@ - + + + + + + + + From 571841f1fd0a971ca3d7956bae56c48f5c39d971 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Thu, 11 Sep 2014 20:03:45 -0700 Subject: [PATCH 07/20] Modify keybindings to Ctrl-AltR and Ctrl-Alt-C --- .../src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct b/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct index 8105a01e81..0b9947c11f 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct +++ b/vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiCommands.vsct @@ -252,12 +252,12 @@ - - - + + + - - + + From 844fc51fa7fb2be058abc8e18e2f3e300a970814 Mon Sep 17 00:00:00 2001 From: jackpappas Date: Sat, 12 Jul 2014 11:07:03 -0400 Subject: [PATCH 08/20] Use KeyValuePair to represent items in the DebuggerTypeProxy for the Map type. This makes it easier to view the items at a glance, rather than having to expand each item to view it's contents. The maximum number of items viewable in the debugger window is also increased from 1k to 10k. --- src/fsharp/FSharp.Core/map.fs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/fsharp/FSharp.Core/map.fs b/src/fsharp/FSharp.Core/map.fs index 416689adc5..4bff9c59eb 100644 --- a/src/fsharp/FSharp.Core/map.fs +++ b/src/fsharp/FSharp.Core/map.fs @@ -630,13 +630,7 @@ namespace Microsoft.FSharp.Collections MapDebugView<'Key,'Value when 'Key : comparison>(v: Map<'Key,'Value>) = [] - member x.Items = v |> Seq.truncate 1000 |> Seq.map (fun kvp -> { key = kvp.Key; value=kvp.Value}) |> Seq.toArray - - and - [] - [] - MapDebugViewKeyValuePair = { key:obj; value:obj } - + member x.Items = v |> Seq.truncate 10000 |> Seq.toArray #endif From 09e5eb5cf07a375b30dc48ed4d45be477ace0b8a Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Thu, 18 Sep 2014 14:01:03 -0700 Subject: [PATCH 09/20] Codeplex issue: 132 - FSI Shadowcopy -- causes a significant degrade in the fsi first execute time if you type 1+1;; 2+2;; there is a perhaps 1 second delay between hitting return and seeing the answer when shadow copy is enabled this delay does not occur when shadow copy is not enabled. subsequent statements to the first are not delayed significantly. The Fix is to enable LoaderOptimisation.MultiDomainHost -- this causes the clr to use the ngened images for assemblies that are signed, loaded from the gac and have corresponding ngen images. In the issue scenario, when enabling shadowcopy, the appdomain loader unable to load the ngen images in the appdomain doing the work. This is a known limitation of AppDomains. The solution is to make the assemblies shared accross appdomains I did some testing and for a script similar to the 1+1;; in the issue report I ran fsi with and without shadowcopyreferences enabled, with and without MultiDomainHost enabled a few hundred times the table below is the average times of each set of runs. In all cases Fsharp files were ngened and loaded from their standard VS install locations. Without MultiDomainHost With MultiDomainHost /shadowcopy- /shadowcopy+ /shadowcopy- /shadowcopy+ 56840.58411 118600.1729 61529.93774 71692.79377 As you can see the impact of shadowcpy is much smaller, close to without. The extra work here is due to creating a new appdomain so the devel it can be unloaded. MultiDomainHost causes static fields to be indirected and so there is a small degrade on with/without. The timings were done on a dualcore VM on a server that was not doing any other work. (changeset 1338154) --- src/fsharp/fsi/fsi.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 13742fb4dd..580ce4d0eb 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -2341,6 +2341,7 @@ type internal FsiEvaluationSession (argv:string[], inReader:TextReader, outWrite // Mark the main thread as STAThread since it is a GUI thread [] [] +[] let MainMain argv = ignore argv let argv = System.Environment.GetCommandLineArgs() From d2de9b8523073fc9802f702b283de180b209ca79 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Fri, 19 Sep 2014 15:36:18 -0700 Subject: [PATCH 10/20] Fix getentryassembly Codeplex issue: https://visualfsharp.codeplex.com/workitem/131 System.Reflection.Assembly.GetEntryAssembly() returns null if shadow copying is true, and the FSI assembly otherwise. Quite a few tools use GetEntryAssembly to get at FSI state, including some internal tools we use. They will break with the new FSI. Modified test2 to also verify that GetEntryAssembly() returns non-null. Added a bit more diagnostic output to test1 and test2 (changeset 1339032) --- src/fsharp/fsi/fsi.fs | 7 ++++--- tests/fsharp/core/fsi-shadowcopy/test1.fsx | 5 ++++- tests/fsharp/core/fsi-shadowcopy/test2.fsx | 18 +++++++++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 580ce4d0eb..7b9ad81364 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -2340,7 +2340,7 @@ type internal FsiEvaluationSession (argv:string[], inReader:TextReader, outWrite // Mark the main thread as STAThread since it is a GUI thread [] -[] +[] [] let MainMain argv = ignore argv @@ -2369,11 +2369,12 @@ let MainMain argv = fsi.Run() #endif - if argv |> Array.exists (fun x -> x = "/shadowcopyreferences" || x = "--shadowcopyreferences" || x = "/shadowcopyreferences+" || x = "--shadowcopyreferences+") then + let isShadowCopy x = (x = "/shadowcopyreferences" || x = "--shadowcopyreferences" || x = "/shadowcopyreferences+" || x = "--shadowcopyreferences+") + if AppDomain.CurrentDomain.IsDefaultAppDomain() && argv |> Array.exists isShadowCopy then let setupInformation = AppDomain.CurrentDomain.SetupInformation setupInformation.ShadowCopyFiles <- "true" let helper = AppDomain.CreateDomain("FSI_Domain", null, setupInformation) - helper.DoCallBack(fun() -> evaluateSession() ) + helper.ExecuteAssemblyByName(Assembly.GetExecutingAssembly().GetName()) |> ignore else evaluateSession() 0 diff --git a/tests/fsharp/core/fsi-shadowcopy/test1.fsx b/tests/fsharp/core/fsi-shadowcopy/test1.fsx index 2c7a131dac..6b1f4c531b 100644 --- a/tests/fsharp/core/fsi-shadowcopy/test1.fsx +++ b/tests/fsharp/core/fsi-shadowcopy/test1.fsx @@ -21,5 +21,8 @@ let next = compiled 30000;; if next = false then printfn "Succeeded -- compile fail because file locked due to --shadowcopyreferences-" use os = System.IO.File.CreateText "test1.ok" - os.Close();; + os.Close() +else + printfn "Failed -- compile succeeded but should have failed due to file lock because of --shadowcopyReferences-. Suspect test error";; + #quit;; diff --git a/tests/fsharp/core/fsi-shadowcopy/test2.fsx b/tests/fsharp/core/fsi-shadowcopy/test2.fsx index 2e9e56ecd3..1da068cbef 100644 --- a/tests/fsharp/core/fsi-shadowcopy/test2.fsx +++ b/tests/fsharp/core/fsi-shadowcopy/test2.fsx @@ -9,9 +9,14 @@ let compiled wait = c.WaitForExit(wait) |> ignore if c.ExitCode = 0 then true else false;; +// Verify that System.Reflection.Assembly.GetEntryAssembly() does not return null +// When GetEntryAssembly is called inside an appdomain, if the assembly wasn't started useng ExecuteAssembly +// GetEntryAssembly returns a null. this check ensures the appdomain is started the right way. +let verifyGetEntryAssembly = if System.Reflection.Assembly.GetEntryAssembly() = null then false else true + // Build the library let first = compiled 30000;; - + //reference it will not lock the assembly because FSI was started with --shadowCopyReferences+ #r "Library1.dll";; @@ -20,6 +25,13 @@ let next = compiled 30000;; //compile will succeed because shadow copy is enabled if next = true then printfn "Succeeded -- compile worked because file not locked due to --shadowcopyReferences+" - use os = System.IO.File.CreateText "test2.ok" - os.Close();; + if verifyGetEntryAssembly then + printfn "Succeeded -- GetEntryAssembly() returned not null" + use os = System.IO.File.CreateText "test2.ok" + os.Close() + else + printfn "Failed -- GetEntryAssembly() returned null" +else + printfn "Failed -- compile failed because file was locked should not have been looked due to --shadowcopyReferences+";; + #quit;; From e869b5fb68544bbdad30e766190a6bfb50748bf1 Mon Sep 17 00:00:00 2001 From: latkin Date: Tue, 30 Sep 2014 16:54:41 -0700 Subject: [PATCH 11/20] Adding some missing defines for queries (changeset 1345199) --- src/FSharpSource.targets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/FSharpSource.targets b/src/FSharpSource.targets index 3c1017a2ee..e61bfafd3d 100644 --- a/src/FSharpSource.targets +++ b/src/FSharpSource.targets @@ -226,6 +226,7 @@ $(DefineConstants);FSHARP_CORE_NETCORE_PORTABLE $(DefineConstants);FSHARP_CORE_NETCORE_PORTABLE78 + $(DefineConstants);QUERIES_IN_FSLIB $(DefineConstants);FX_NO_CONVERTER $(DefineConstants);FX_RESHAPED_REFLECTION $(DefineConstants);FX_NO_ARRAY_LONG_LENGTH @@ -261,6 +262,7 @@ $(DefineConstants);FSHARP_CORE_NETCORE_PORTABLE $(DefineConstants);FSHARP_CORE_NETCORE_PORTABLE259 + $(DefineConstants);QUERIES_IN_FSLIB $(DefineConstants);FX_NO_CONVERTER $(DefineConstants);FX_RESHAPED_REFLECTION $(DefineConstants);FX_NO_ARRAY_LONG_LENGTH From 3694b96bc29a850ddf6f60f1ffcd8ca66bc873da Mon Sep 17 00:00:00 2001 From: latkin Date: Wed, 1 Oct 2014 13:23:07 -0700 Subject: [PATCH 12/20] U+180E is no longer considered "whitespace" by the unicode 6.3.0 standard http://www.unicode.org/versions/Unicode6.3.0/#Database_Changes (changeset 1345930) --- tests/fsharpqa/Source/Libraries/Portable/parse_oracle.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fsharpqa/Source/Libraries/Portable/parse_oracle.cs b/tests/fsharpqa/Source/Libraries/Portable/parse_oracle.cs index 2cafb2a765..aa9349d471 100644 --- a/tests/fsharpqa/Source/Libraries/Portable/parse_oracle.cs +++ b/tests/fsharpqa/Source/Libraries/Portable/parse_oracle.cs @@ -101,7 +101,7 @@ static void Main(string[] args) // Misc whitespaces - var ws = "\x180E\x2000\x2001\x2002\x2003\x2004\x2005\x2006\x2007\x2008\x2009\x200A\x202F\x205F\x3000\x2028\x2029\x0009\x000A\x000B\x000C\x000D\x0085\x00A0"; + var ws = "\x2000\x2001\x2002\x2003\x2004\x2005\x2006\x2007\x2008\x2009\x200A\x202F\x205F\x3000\x2028\x2029\x0009\x000A\x000B\x000C\x000D\x0085\x00A0"; AssertEqual(ws + "123" + ws, onetwothee); #endif From b49825b9a5e399e9b365c796fd03d305ef0c3c29 Mon Sep 17 00:00:00 2001 From: latkin Date: Fri, 3 Oct 2014 16:23:09 -0700 Subject: [PATCH 13/20] Rolling back parser change for F# 3.1.X --- src/fsharp/pars.fsy | 84 ------------------- .../typecheck/full-rank-arrays/test.fsx | 4 - 2 files changed, 88 deletions(-) diff --git a/src/fsharp/pars.fsy b/src/fsharp/pars.fsy index 2d8b0e0a1c..0ffdee03ba 100644 --- a/src/fsharp/pars.fsy +++ b/src/fsharp/pars.fsy @@ -4274,90 +4274,6 @@ arrayTypeSuffix: | LBRACK COMMA COMMA COMMA RBRACK { 4 } - - | LBRACK COMMA COMMA COMMA COMMA RBRACK - { 5 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA RBRACK - { 6 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 7 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 8 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 9 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 10 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 11 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 12 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 13 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 14 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 15 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 16 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 17 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 18 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 19 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 20 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 21 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 22 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 23 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 24 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 25 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 26 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 27 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 28 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 29 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 30 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 31 } - - | LBRACK COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA COMMA RBRACK - { 32 } appTypePrefixArguments: | typeArgActual COMMA typeArgActual typeArgListElements diff --git a/tests/fsharp/typecheck/full-rank-arrays/test.fsx b/tests/fsharp/typecheck/full-rank-arrays/test.fsx index 906c03318f..28cc5fbce7 100644 --- a/tests/fsharp/typecheck/full-rank-arrays/test.fsx +++ b/tests/fsharp/typecheck/full-rank-arrays/test.fsx @@ -22,10 +22,6 @@ type Class1() = let foo = ClassWithArrayCtor ([| 1;3;5;7 |]) () - member this.W (foo : int[,,,,,,,,,,]) = - printfn "Hello World!" - () - (* avoid ;; -- to avoid fsi error recovery *) let _ = From 0a5f3e18d4f722c01ee852c93b5292d97289410b Mon Sep 17 00:00:00 2001 From: latkin Date: Fri, 3 Oct 2014 17:13:15 -0700 Subject: [PATCH 14/20] Expand\refactor tests a bit for consuming high-D arrays --- .../typecheck/full-rank-arrays/Class1.cs | 23 ++++++++++++++ .../full-rank-arrays/HighRankArrayTests.dll | Bin 6144 -> 0 bytes .../typecheck/full-rank-arrays/build.bat | 4 +++ .../fsharp/typecheck/full-rank-arrays/test.fs | 21 ------------ .../typecheck/full-rank-arrays/test.fsx | 30 +++++++++++++++--- 5 files changed, 53 insertions(+), 25 deletions(-) delete mode 100644 tests/fsharp/typecheck/full-rank-arrays/HighRankArrayTests.dll delete mode 100644 tests/fsharp/typecheck/full-rank-arrays/test.fs diff --git a/tests/fsharp/typecheck/full-rank-arrays/Class1.cs b/tests/fsharp/typecheck/full-rank-arrays/Class1.cs index c20f006b0a..f56a465284 100644 --- a/tests/fsharp/typecheck/full-rank-arrays/Class1.cs +++ b/tests/fsharp/typecheck/full-rank-arrays/Class1.cs @@ -180,4 +180,27 @@ public static void Example(T[, , , , , , , , , ,] array) throw new NotImplementedException(); } } + + public static class MethodsReturningHighDArrays + { + public static T1[,] Example1() + { + throw new NotImplementedException(); + } + + public static T1[,,,,,] Example1(int x) + { + throw new NotImplementedException(); + } + + public static T1[,] Example2() + { + throw new NotImplementedException(); + } + + public static T1[,,,,,,] Example2() + { + throw new NotImplementedException(); + } + } } diff --git a/tests/fsharp/typecheck/full-rank-arrays/HighRankArrayTests.dll b/tests/fsharp/typecheck/full-rank-arrays/HighRankArrayTests.dll deleted file mode 100644 index 050e92cc7cbb048afe1231935ce367df7aa0e766..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6144 zcmeHLTWlOx8UD|#?buFyw{uTCt`kaVz4B!f;x=u4StoXg6XV_3h8W`6-N|~I*`3YI zY-0ztN(3zsRci85)B*(rMJiMUAq1s}Dyk~POVtM+5S1zw33x(6Dj*ez2;YBZ_ITH8 z6{vVfr2f`?=Y0RUedj-C&YAV}r>{|jh-&cMx<&LdQnnF^?+=$z+}!<2GyS;Xjh>gq zi8p$Z%a*4XTqo-qIX!LU^Nz2lOx-Q!bt|vOPbKu6lQE-BO^y4)u4g8QPKXFSweZYr zX|#7p>)9+e6Scxq7kFQdBGvJX;NcP-s0F&&!TP0L2Exx4p^?XBC)^KrCR3HLlQQUc zo--pv3mk~`wnVfAzI*$KcCRmcKduwimzCFpPnPkhZ?5>@uQvlwCbfmS!KCR#OHtQz z(_m8D2r@j;c06S^0`*bXv>jArt+a%P``U`9%tnaD%BakKlj90wZ5q|mwH~6cA@o9e z|97}g`)C_cqZWA-A{#$;d(xd=2gF^v4HFtm93K;5^m#2GiADRPL;XVo!@L%?WCP#B z9_W1xd$*S8Cf2z(;k#Bo>v4@GY&za|y{8kjj0|u2-eaey;z(D(_hFCsj@eEMoDI#z zd>7R>@V@%T{vqBoy!M@V*u{Bl3Hcys#M_m9rKbsb#8Ps8S-(QpfX_*Mi*6uaEB*r9 zEpb@lg2W3FuS$Gg;th%KiQkGk+M+S;)VS@C#I!b}jnhR4uA}d2PiS@YONqbNu1O87 zh;`vlv_kJ8M2p!KuqnwjydBKWg=`yYeFxfSbZ+^?_7^cbL1z`~LUi(q^-zQ!RV<3= zJgL|bjP+H;J^_W_Q|t_FqMs>dV|9L|*kjZ{zftTuwER)A=V>$jO|qxyNAwD`-&E{1 zYN7})3vt<-(A}um+tfmBiv0;YV7p>Bsg1f7YZC4B5yiSi2lXj7C^{*o*iq3%_bYZr zY^5>9E{JV3rPzwtPBV&qLF}M;#jcB;^jXEeA$F0e*h^wJ*^0d?_K>I8n_@3rQtWr4 zo31GKSE19F6sy-bD-f+a9e2=+vK|?xL>)dnMi@aY*{_r*FeQEwUo2(e$At~657QlCx+_fgglTt} z_JnC~nC=hLyTkNAnBEhneL;F;+Q}4c^Ff-lvdgnZ{`{!x8mmdu^Sx-swrSipJa69e zm!*H)cig3c4eCGPGQx>T5M31bd8LeGs-7Z(l}nU{i0hYeqCUu^1kUhg@oxo zVx>)w#+}@p@NUIBuTDDnL7!Dh^jBMWVup>N*o2g7LQ&RdfdE)yX!<9`w`+dzZtYd7|LLX0xgD{0z8tA*Z>ZCS*waCqk#u(87R05y zCCEo`3lcR2q$YTgn*&yhOOUN4pmn$frL_ip6Yjyl+5$(t{7{ju_Q2DC>#$@UfvXXB zqO#7ww;3nZnr&(o5WAPQaN4;yP}>xeKyGu$LcJ{^EeUQ7xl-H~I@Tn&hn_Oc9igjS zbZ6+RP~8QXOF)(2)_||+Z3`S_a@zw>x!R7vRUx)B z@KtK9(S>Mc&}so~6P&HbMiO;h?e+L%n2GlC=VDUZI`0~V zlTKc}G|6Sxx#&p^>USzP-3`|yeiu%*5X~myiOYZgwfWT5x5l1+$T&Uv{o@gCk-l&7 zw1)$F@wkybzZiGYMSdf_MI1y$!`2giF=ILUz`!ETMn3+%#p(cTmYf}T+_-H|8&*EJGEGxn(p>A-e)JXos;_MI zA^RW^5HgtCi7r>R<`;tqFHM!7>rLWW7yOcCA~!{+=p^_Q@F?41xS!thal|-oluZMDj zeAIKm0{daj5;_&otOwn0N3OqZG%0X7G(HRQ)(c_b4sp*>)G0kY{x;O-8T+zs9(~$~sX;k# zUXTAgZj>@;!~ad-`nVkE1lne0PveMG0V+8%tlvkSYM)Lo;N{b45ZVR^=P)fuU8ll! z997m;S|Mg1R3FEC2K_ovT|}(?vf2K3^W}NQWSlGeSs(57u|6!@jAA`J#3zRxU?Va* e_H^Yct#8NU-4Uh-|1-St;2oj%Ly`aI2>cs(7D.Example [| 2;3;4;5 |] - - member this.Y = - StaticClassWithGenericMethod.Example [| 1;2;3;4 |] - - member this.Z = - let foo = ClassWithArrayCtor ([| 1;3;5;7 |]) - () diff --git a/tests/fsharp/typecheck/full-rank-arrays/test.fsx b/tests/fsharp/typecheck/full-rank-arrays/test.fsx index 28cc5fbce7..f06ed2f8cb 100644 --- a/tests/fsharp/typecheck/full-rank-arrays/test.fsx +++ b/tests/fsharp/typecheck/full-rank-arrays/test.fsx @@ -4,7 +4,7 @@ #r "HighRankArrayTests.dll" open HighRankArrayTests -(* In the F# 3.1 release and earlier versions, the compiler's overload resolution +(* In the F# 3.1.2 release and earlier versions, the compiler's overload resolution breaks on the following class definition. The referenced assembly defines several classes with various overloaded methods and constructors; some of these overloads include parameters whose type is a "high-rank" array -- that is, @@ -12,16 +12,38 @@ open HighRankArrayTests F#, but it should still be possible to call one of the overloads which does not include such a parameter. *) type Class1() = - member this.X = + member this.X1 = GenericStaticClassWithMethod.Example [| 2;3;4;5 |] - member this.Y = + member this.X2 = StaticClassWithGenericMethod.Example [| 1;2;3;4 |] - member this.Z = + member this.X3 = let foo = ClassWithArrayCtor ([| 1;3;5;7 |]) () + member this.X4 = + let y1 = MethodsReturningHighDArrays.Example1() + let y2 = MethodsReturningHighDArrays.Example1(2) + + StaticClassWithGenericMethod.Example(y1) + StaticClassWithGenericMethod.Example(y2) + ClassWithArrayCtor(y1) |> ignore + ClassWithArrayCtor(y2) |> ignore + + () + + member this.X5 = + let y1 = MethodsReturningHighDArrays.Example2<_>() + let y2 = MethodsReturningHighDArrays.Example2<_,_>() + + StaticClassWithGenericMethod.Example(y1) + StaticClassWithGenericMethod.Example(y2) + ClassWithArrayCtor(y1) |> ignore + ClassWithArrayCtor(y2) |> ignore + + () + (* avoid ;; -- to avoid fsi error recovery *) let _ = From 650df341c4a1316b9089660d5788a23e8ff687a9 Mon Sep 17 00:00:00 2001 From: latkin Date: Fri, 3 Oct 2014 17:17:56 -0700 Subject: [PATCH 15/20] Patch TP test covering array ranks --- tests/fsharpqa/Source/TypeProviders/Arrays/E_ArrayRank02.fsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/fsharpqa/Source/TypeProviders/Arrays/E_ArrayRank02.fsx b/tests/fsharpqa/Source/TypeProviders/Arrays/E_ArrayRank02.fsx index d5857df6df..4cc2d2aed1 100644 --- a/tests/fsharpqa/Source/TypeProviders/Arrays/E_ArrayRank02.fsx +++ b/tests/fsharpqa/Source/TypeProviders/Arrays/E_ArrayRank02.fsx @@ -1,9 +1,8 @@ // #Regression #TypeProvider #Arrays // This is regression test for DevDiv:213995 -// TP limit array rank to 4 -//F# supports a maximum array rank of 4$ +//System\.String\[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\].*has too many dimensions -type X = N.T<"System.String", 5> +type X = N.T<"System.String", 35> let _ = typeof From 4200e8b26c79d980154b097ec2a922b0a4eef25c Mon Sep 17 00:00:00 2001 From: latkin Date: Tue, 7 Oct 2014 15:09:55 -0700 Subject: [PATCH 16/20] After code review, rolling back more stuff not needed for basic typecheck scenario --- src/fsharp/creflect.fs | 13 +++++--- src/fsharp/env.fs | 39 ++++++++++++---------- src/fsharp/patcompile.fs | 2 +- src/fsharp/tastops.fs | 71 +++++++++++++++++++--------------------- src/fsharp/tastops.fsi | 5 ++- 5 files changed, 68 insertions(+), 62 deletions(-) diff --git a/src/fsharp/creflect.fs b/src/fsharp/creflect.fs index ede051a0bd..ae60038107 100644 --- a/src/fsharp/creflect.fs +++ b/src/fsharp/creflect.fs @@ -125,7 +125,7 @@ let (|SimpleArrayLoopUpperBound|_|) expr = let (|SimpleArrayLoopBody|_|) g expr = match expr with | Expr.Lambda(_, a, b, ([_] as args), Expr.Let(TBind(forVarLoop, Expr.Op(TOp.ILAsm([I_ldelem_any(ILArrayShape [(Some 0, None)], _)], _), [elemTy], [arr; idx], m1), seqPoint), body, m2, freeVars), m, ty) -> - let body = Expr.Let(TBind(forVarLoop, mkCallArrayGet g m1 1 elemTy arr [idx], seqPoint), body, m2, freeVars) + let body = Expr.Let(TBind(forVarLoop, mkCallArrayGet g m1 elemTy arr idx, seqPoint), body, m2, freeVars) let expr = Expr.Lambda(newUnique(), a, b, args, body, m, ty) Some (arr, elemTy, expr) | _ -> None @@ -628,10 +628,13 @@ and ConvLValueExprCore cenv env expr = | TOp.ValFieldGetAddr(rfref),_,_ -> ConvRFieldGet cenv env m rfref tyargs args | TOp.ILAsm([ I_ldflda(fspec) ],_rtys),_,_ -> ConvLdfld cenv env m fspec tyargs args | TOp.ILAsm([ I_ldsflda(fspec) ],_rtys),_,_ -> ConvLdfld cenv env m fspec tyargs args - | TOp.ILAsm(([ I_ldelema(_ro,_isNativePtr,shape,_tyarg) ] ),_), (arr::idxs), [elemty] - when shape.Rank = List.length idxs -> - assert (shape.Rank >= 1 && shape.Rank <= 32) - ConvExpr cenv env (mkCallArrayGet cenv.g m shape.Rank elemty arr idxs) + | TOp.ILAsm(([ I_ldelema(_ro,_isNativePtr,shape,_tyarg) ] ),_), (arr::idxs), [elemty] -> + match shape.Rank, idxs with + | 1, [idx1] -> ConvExpr cenv env (mkCallArrayGet cenv.g m elemty arr idx1) + | 2, [idx1; idx2] -> ConvExpr cenv env (mkCallArray2DGet cenv.g m elemty arr idx1 idx2) + | 3, [idx1; idx2; idx3] -> ConvExpr cenv env (mkCallArray3DGet cenv.g m elemty arr idx1 idx2 idx3) + | 4, [idx1; idx2; idx3; idx4] -> ConvExpr cenv env (mkCallArray4DGet cenv.g m elemty arr idx1 idx2 idx3 idx4) + | _ -> ConvExpr cenv env expr | _ -> ConvExpr cenv env expr | _ -> ConvExpr cenv env expr diff --git a/src/fsharp/env.fs b/src/fsharp/env.fs index 227a6bed59..cb9fecc279 100644 --- a/src/fsharp/env.fs +++ b/src/fsharp/env.fs @@ -483,7 +483,10 @@ type public TcGlobals = range_op_vref : ValRef; range_int32_op_vref : ValRef; //range_step_op_vref : ValRef; - array_get_vref_map : ValRef[]; + array_get_vref : ValRef; + array2D_get_vref : ValRef; + array3D_get_vref : ValRef; + array4D_get_vref : ValRef; seq_collect_vref : ValRef; seq_collect_info : IntrinsicValRef; seq_using_info : IntrinsicValRef; @@ -511,8 +514,11 @@ type public TcGlobals = lazy_force_info : IntrinsicValRef; lazy_create_info : IntrinsicValRef; + array_get_info : IntrinsicValRef; array_length_info : IntrinsicValRef; - array_get_info_map : IntrinsicValRef[]; + array2D_get_info : IntrinsicValRef; + array3D_get_info : IntrinsicValRef; + array4D_get_info : IntrinsicValRef; unpickle_quoted_info : IntrinsicValRef; cast_quotation_info : IntrinsicValRef; lift_value_info : IntrinsicValRef; @@ -907,18 +913,9 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa let enum_info = makeIntrinsicValRef(fslib_MFOperators_nleref, "enum" ,None ,Some "ToEnum" ,[vara], ([[int_ty]],varaTy)) let range_op_info = makeIntrinsicValRef(fslib_MFOperators_nleref, "op_Range" ,None ,None ,[vara], ([[varaTy];[varaTy]],mkSeqTy varaTy)) let range_int32_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeInt32" ,None ,None ,[], ([[int_ty];[int_ty];[int_ty]],mkSeqTy int_ty)) - - let array_get_info_map = - Array.init 32 (fun idx -> - let rank = idx + 1 - let intrinsicMethodName = - if rank = 1 then "GetArray" - else sprintf "GetArray%iD" rank - let argTypes = - [mkArrayType rank varaTy] :: (List.replicate rank [int_ty]) - makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, intrinsicMethodName ,None ,None ,[vara], (argTypes, varaTy))) - - let array_length_info = makeIntrinsicValRef(fslib_MFArrayModule_nleref, "length" ,None ,Some "Length" ,[vara], ([[mkArrayType 1 varaTy]], varaTy)) + let array2D_get_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "GetArray2D" ,None ,None ,[vara], ([[mkArrayType 2 varaTy];[int_ty]; [int_ty]],varaTy)) + let array3D_get_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "GetArray3D" ,None ,None ,[vara], ([[mkArrayType 3 varaTy];[int_ty]; [int_ty]; [int_ty]],varaTy)) + let array4D_get_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "GetArray4D" ,None ,None ,[vara], ([[mkArrayType 4 varaTy];[int_ty]; [int_ty]; [int_ty]; [int_ty]],varaTy)) let seq_collect_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "collect" ,None ,Some "Collect",[vara;varb;varc],([[varaTy --> varbTy]; [mkSeqTy varaTy]], mkSeqTy varcTy)) let seq_delay_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "delay" ,None ,Some "Delay" ,[varb], ([[unit_ty --> mkSeqTy varbTy]], mkSeqTy varbTy)) @@ -928,7 +925,7 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa let seq_finally_info = makeIntrinsicValRef(fslib_MFRuntimeHelpers_nleref, "EnumerateThenFinally" ,None ,None ,[varb], ([[mkSeqTy varbTy]; [unit_ty --> unit_ty]], mkSeqTy varbTy)) let seq_of_functions_info = makeIntrinsicValRef(fslib_MFRuntimeHelpers_nleref, "EnumerateFromFunctions" ,None ,None ,[vara;varb],([[unit_ty --> varaTy]; [varaTy --> bool_ty]; [varaTy --> varbTy]], mkSeqTy varbTy)) let create_event_info = makeIntrinsicValRef(fslib_MFRuntimeHelpers_nleref, "CreateEvent" ,None ,None ,[vara;varb],([[varaTy --> unit_ty]; [varaTy --> unit_ty]; [(obj_ty --> (varbTy --> unit_ty)) --> varaTy]], TType_app (fslib_IEvent2_tcr, [varaTy;varbTy]))) - let seq_to_array_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "toArray" ,None ,Some "ToArray",[varb], ([[mkSeqTy varbTy]], mkArrayType 1 varbTy)) + let seq_to_array_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "toArray" ,None ,Some "ToArray",[varb], ([[mkSeqTy varbTy]], mkArrayType 1 varbTy)) let seq_to_list_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "toList" ,None ,Some "ToList" ,[varb], ([[mkSeqTy varbTy]], mkListTy varbTy)) let seq_map_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "map" ,None ,Some "Map" ,[vara;varb],([[varaTy --> varbTy]; [mkSeqTy varaTy]], mkSeqTy varbTy)) let seq_singleton_info = makeIntrinsicValRef(fslib_MFSeqModule_nleref, "singleton" ,None ,Some "Singleton" ,[vara], ([[varaTy]], mkSeqTy varaTy)) @@ -943,6 +940,8 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa let splice_expr_info = makeIntrinsicValRef(fslib_MFExtraTopLevelOperators_nleref, "op_Splice" ,None ,None ,[vara], ([[mkQuotedExprTy varaTy]], varaTy)) let splice_raw_expr_info = makeIntrinsicValRef(fslib_MFExtraTopLevelOperators_nleref, "op_SpliceUntyped" ,None ,None ,[vara], ([[mkRawQuotedExprTy]], varaTy)) let new_decimal_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "MakeDecimal" ,None ,None ,[], ([[int_ty]; [int_ty]; [int_ty]; [bool_ty]; [byte_ty]], decimal_ty)) + let array_get_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "GetArray" ,None ,None ,[vara], ([[mkArrayType 1 varaTy]; [int_ty]], varaTy)) + let array_length_info = makeIntrinsicValRef(fslib_MFArrayModule_nleref, "length" ,None ,Some "Length" ,[vara], ([[mkArrayType 1 varaTy]], varaTy)) let unpickle_quoted_info = makeIntrinsicValRef(fslib_MFQuotations_nleref, "Deserialize" ,Some "Expr" ,None ,[], ([[system_Type_typ ;mkListTy system_Type_typ ;mkListTy mkRawQuotedExprTy ; mkArrayType 1 byte_ty]], mkRawQuotedExprTy )) let cast_quotation_info = makeIntrinsicValRef(fslib_MFQuotations_nleref, "Cast" ,Some "Expr" ,None ,[vara], ([[mkRawQuotedExprTy]], mkQuotedExprTy varaTy)) let lift_value_info = makeIntrinsicValRef(fslib_MFQuotations_nleref, "Value" ,Some "Expr" ,None ,[vara], ([[varaTy]], mkRawQuotedExprTy)) @@ -1354,7 +1353,10 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa range_int32_op_vref = ValRefForIntrinsic range_int32_op_info; //range_step_op_vref = ValRefForIntrinsic range_step_op_info; array_length_info = array_length_info - array_get_vref_map = array_get_info_map |> Array.map ValRefForIntrinsic; + array_get_vref = ValRefForIntrinsic array_get_info; + array2D_get_vref = ValRefForIntrinsic array2D_get_info; + array3D_get_vref = ValRefForIntrinsic array3D_get_info; + array4D_get_vref = ValRefForIntrinsic array4D_get_info; seq_singleton_vref = ValRefForIntrinsic seq_singleton_info; seq_collect_vref = ValRefForIntrinsic seq_collect_info; seq_collect_info = seq_collect_info; @@ -1396,7 +1398,10 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa create_event_info = create_event_info; seq_to_list_info = seq_to_list_info; seq_to_array_info = seq_to_array_info; - array_get_info_map = array_get_info_map; + array_get_info = array_get_info; + array2D_get_info = array2D_get_info; + array3D_get_info = array3D_get_info; + array4D_get_info = array4D_get_info; unpickle_quoted_info = unpickle_quoted_info; cast_quotation_info = cast_quotation_info; lift_value_info = lift_value_info; diff --git a/src/fsharp/patcompile.fs b/src/fsharp/patcompile.fs index 54ea7cb69e..3b18175425 100644 --- a/src/fsharp/patcompile.fs +++ b/src/fsharp/patcompile.fs @@ -1098,7 +1098,7 @@ let CompilePatternBasic | TPat_array (argpats,ty,_) -> match discrim with | Test.ArrayLength (n,_) when List.length argpats = n -> - let accessf' j tpinst e' = mkCallArrayGet g exprm 1 ty (accessf tpinst e') [(mkInt g exprm j)] + let accessf' j tpinst e' = mkCallArrayGet g exprm ty (accessf tpinst e') (mkInt g exprm j) mkSubFrontiers path accessf' active' argpats (fun path j -> PathArray(path,ty,List.length argpats,j)) // Successful length tests refute all other lengths | Test.ArrayLength _ -> diff --git a/src/fsharp/tastops.fs b/src/fsharp/tastops.fs index 3f40bb53a1..1a05079cd7 100644 --- a/src/fsharp/tastops.fs +++ b/src/fsharp/tastops.fs @@ -536,7 +536,6 @@ let mkArrayTy g rank ty m = else TType_app (g.il_arr_tcr_map.[rank - 1], [ty]) - //-------------------------------------------------------------------------- // Tuple compilation (types) //------------------------------------------------------------------------ @@ -1431,7 +1430,7 @@ let isByrefLikeTyconRef g tcref = isTypeConstructorEqualToOptional g g.system_RuntimeArgumentHandle_tcref tcref let isArrayTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> isArrayTyconRef g tcref | _ -> false) -let isArray1DTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> tyconRefEq g tcref g.il_arr_tcr_map.[0] | _ -> false) +let isArray1DTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> tyconRefEq g tcref g.il_arr_tcr_map.[0] | _ -> false) let isUnitTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> tyconRefEq g g.unit_tcr_canon tcref | _ -> false) let isObjTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> tyconRefEq g g.system_Object_tcref tcref | _ -> false) let isVoidTy g ty = ty |> stripTyEqns g |> (function TType_app(tcref,_) -> tyconRefEq g g.system_Void_tcref tcref | _ -> false) @@ -5354,16 +5353,22 @@ let rec mkExprAddrOfExpr g mustTakeAddress useReadonlyForGenericArrayAddress mut (fun x -> x), mkStaticRecdFieldGetAddr(rfref,tinst,m) // LVALUE: "e.[n]" where e is an array of structs - // LVALUE: "e.[n1,n2]", "e.[n1,n2,n3]", "e.[n1,n2,n3,n4]", etc. where e is an array of structs - | Expr.App(Expr.Val(vf,_,_),_,[elemTy],(aexpr::args),_) - when (g.array_get_vref_map |> Array.exists (valRefEq g vf)) -> - - // Handle single-dimensional (rank 1) arrays separately. - let shape = - if valRefEq g vf g.array_get_vref_map.[0] then - ILArrayShape.SingleDimensional - else - ILArrayShape.FromRank args.Length + | Expr.App(Expr.Val(vf,_,_),_,[elemTy],[aexpr;nexpr],_) + when (valRefEq g vf g.array_get_vref) -> + + let shape = ILArrayShape.SingleDimensional + let readonly = if isTyparTy g elemTy && useReadonlyForGenericArrayAddress then ReadonlyAddress else NormalAddress + let isNativePtr = + match addrExprVal with + | Some(vf) -> valRefEq g vf g.addrof2_vref + | _ -> false + (fun x -> x), Expr.Op (TOp.ILAsm ([IL.I_ldelema(readonly,isNativePtr,shape,mkILTyvarTy 0us)],[mkByrefTy g elemTy]), [elemTy],[aexpr;nexpr],m) + + // LVALUE: "e.[n1,n2]", "e.[n1,n2,n3]", "e.[n1,n2,n3,n4]" where e is an array of structs + | Expr.App(Expr.Val(vf,_,_),_,[elemTy],(aexpr::args),_) + when (valRefEq g vf g.array2D_get_vref || valRefEq g vf g.array3D_get_vref || valRefEq g vf g.array4D_get_vref) -> + + let shape = ILArrayShape.FromRank args.Length let readonly = if isTyparTy g elemTy && useReadonlyForGenericArrayAddress then ReadonlyAddress else NormalAddress let isNativePtr = match addrExprVal with @@ -5849,12 +5854,10 @@ let mkCallGenericHashWithComparerOuter g m ty comp e1 = mkApps g (ty let mkCallSubtractionOperator g m ty e1 e2 = mkApps g (typedExprForIntrinsic g m g.unchecked_subtraction_info, [[ty; ty; ty]], [e1;e2], m) let mkCallArrayLength g m ty el = mkApps g (typedExprForIntrinsic g m g.array_length_info, [[ty]], [el], m) - -let mkCallArrayGet g m rank ty e1 indices = - assert (rank = List.length indices) - assert (rank >= 1 && rank <= 32) - mkApps g (typedExprForIntrinsic g m g.array_get_info_map.[rank - 1], [[ty]], e1 :: indices, m) - +let mkCallArrayGet g m ty e1 e2 = mkApps g (typedExprForIntrinsic g m g.array_get_info, [[ty]], [ e1 ; e2 ], m) +let mkCallArray2DGet g m ty e1 idx1 idx2 = mkApps g (typedExprForIntrinsic g m g.array2D_get_info, [[ty]], [ e1 ; idx1; idx2 ], m) +let mkCallArray3DGet g m ty e1 idx1 idx2 idx3 = mkApps g (typedExprForIntrinsic g m g.array3D_get_info, [[ty]], [ e1 ; idx1; idx2; idx3 ], m) +let mkCallArray4DGet g m ty e1 idx1 idx2 idx3 idx4 = mkApps g (typedExprForIntrinsic g m g.array4D_get_info, [[ty]], [ e1 ; idx1; idx2; idx3; idx4 ], m) let mkCallNewDecimal g m (e1,e2,e3,e4,e5) = mkApps g (typedExprForIntrinsic g m g.new_decimal_info, [], [ e1;e2;e3;e4;e5 ], m) let mkCallNewFormat g m aty bty cty dty ety e1 = mkApps g (typedExprForIntrinsic g m g.new_format_info, [[aty;bty;cty;dty;ety]], [ e1 ], m) @@ -6673,20 +6676,6 @@ let typarEnc _g (gtpsType,gtpsMethod) typar = | None -> warning(InternalError("Typar not found during XmlDoc generation",typar.Range)) "``0" // REVIEW: this should be ERROR not WARNING? -/// IL array type encodings. The array index is (rank - 1). -let private arrayTypeEncodings = - Array.init 32 (fun idx -> - let rank = idx + 1 - if rank = 1 then - // The easy case - "[]" - else - // REVIEW - // In fact IL supports 3 kinds of multidimensional arrays, and each kind of array has its own xmldoc spec. - // We don't support all these, and instead always pull xmldocs for 0-based-arbitrary-length ("0:") multidimensional arrays. - // This is probably the 99% case anyway. - "[" + System.String.Join (",", Array.create rank "0:") + "]") - let rec typeEnc g (gtpsType,gtpsMethod) ty = if verbose then dprintf "--> typeEnc"; match (stripTyEqns g ty) with @@ -6694,12 +6683,18 @@ let rec typeEnc g (gtpsType,gtpsMethod) ty = "Microsoft.FSharp.Core.FSharpTypeFunc" | _ when isArrayTy g ty -> let tcref,tinst = destAppTy g ty - let arraySuffix = - let arrayRank = rankOfArrayTyconRef g tcref - if arrayRank >= 1 && arrayRank <= 32 then - arrayTypeEncodings.[arrayRank - 1] - else - failwith "impossible: rankOfArrayTyconRef: unsupported array rank" + let arraySuffix = + match rankOfArrayTyconRef g tcref with + // The easy case + | 1 -> "[]" + // REVIEW + // In fact IL supports 3 kinds of multidimensional arrays, and each kind of array has its own xmldoc spec. + // We don't support all these, and instead always pull xmldocs for 0-based-arbitrary-length ("0:") multidimensional arrays. + // This is probably the 99% case anyway. + | 2 -> "[0:,0:]" + | 3 -> "[0:,0:,0:]" + | 4 -> "[0:,0:,0:,0:]" + | _ -> failwith "impossible: rankOfArrayTyconRef: unsupported array rank" typeEnc g (gtpsType,gtpsMethod) (List.head tinst) ^ arraySuffix | TType_ucase (UCRef(tcref,_),tinst) | TType_app (tcref,tinst) -> diff --git a/src/fsharp/tastops.fsi b/src/fsharp/tastops.fsi index f55b8e20a5..ecbe9fc0dd 100644 --- a/src/fsharp/tastops.fsi +++ b/src/fsharp/tastops.fsi @@ -1126,7 +1126,10 @@ val mkCallTypeDefOf : TcGlobals -> range -> TType -> Expr val mkCallCreateInstance : TcGlobals -> range -> TType -> Expr val mkCallCreateEvent : TcGlobals -> range -> TType -> TType -> Expr -> Expr -> Expr -> Expr val mkCallArrayLength : TcGlobals -> range -> TType -> Expr -> Expr -val mkCallArrayGet : TcGlobals -> range -> int -> TType -> Expr -> Expr list -> Expr +val mkCallArrayGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr +val mkCallArray2DGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr +val mkCallArray3DGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -> Expr +val mkCallArray4DGet : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr -> Expr -> Expr val mkCallRaise : TcGlobals -> range -> TType -> Expr -> Expr val mkCallGenericComparisonWithComparerOuter : TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Expr From 037c4408def10ada3537992cec96de82707b9383 Mon Sep 17 00:00:00 2001 From: latkin Date: Tue, 7 Oct 2014 15:10:17 -0700 Subject: [PATCH 17/20] Expanding tests further --- .../typecheck/full-rank-arrays/Class1.cs | 100 +++++++++--------- .../typecheck/full-rank-arrays/test.fsx | 76 +++++++++++-- 2 files changed, 116 insertions(+), 60 deletions(-) diff --git a/tests/fsharp/typecheck/full-rank-arrays/Class1.cs b/tests/fsharp/typecheck/full-rank-arrays/Class1.cs index f56a465284..18b4fd3320 100644 --- a/tests/fsharp/typecheck/full-rank-arrays/Class1.cs +++ b/tests/fsharp/typecheck/full-rank-arrays/Class1.cs @@ -19,47 +19,47 @@ public ClassWithArrayCtor(T[,] array) m_array = array; } - public ClassWithArrayCtor(T[,,] array) + public ClassWithArrayCtor(T[, ,] array) { m_array = array; } - public ClassWithArrayCtor(T[,,,] array) + public ClassWithArrayCtor(T[, , ,] array) { m_array = array; } - public ClassWithArrayCtor(T[,,,,] array) + public ClassWithArrayCtor(T[, , , ,] array) { m_array = array; } - public ClassWithArrayCtor(T[,,,,,] array) + public ClassWithArrayCtor(T[, , , , ,] array) { m_array = array; } - public ClassWithArrayCtor(T[,,,,,,] array) + public ClassWithArrayCtor(T[, , , , , ,] array) { m_array = array; } - public ClassWithArrayCtor(T[,,,,,,,] array) + public ClassWithArrayCtor(T[, , , , , , ,] array) { m_array = array; } - public ClassWithArrayCtor(T[,,,,,,,,] array) + public ClassWithArrayCtor(T[, , , , , , , ,] array) { m_array = array; } - public ClassWithArrayCtor(T[,,,,,,,,,] array) + public ClassWithArrayCtor(T[, , , , , , , , ,] array) { m_array = array; } - public ClassWithArrayCtor(T[,,,,,,,,,,] array) + public ClassWithArrayCtor(T[, , , , , , , , , ,] array) { m_array = array; } @@ -69,57 +69,57 @@ public static class StaticClassWithGenericMethod { public static void Example(T[] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } - public static void Example(T[,,] array) + public static void Example(T[, ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } - public static void Example(T[,,,] array) + public static void Example(T[, , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } - public static void Example(T[,,,,] array) + public static void Example(T[, , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } - public static void Example(T[,,,,,] array) + public static void Example(T[, , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } - public static void Example(T[,,,,,,] array) + public static void Example(T[, , , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } - public static void Example(T[,,,,,,,] array) + public static void Example(T[, , , , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } - public static void Example(T[,,,,,,,,] array) + public static void Example(T[, , , , , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } - public static void Example(T[,,,,,,,,,] array) + public static void Example(T[, , , , , , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } - public static void Example(T[,,,,,,,,,,] array) + public static void Example(T[, , , , , , , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } } @@ -127,80 +127,80 @@ public static class GenericStaticClassWithMethod { public static void Example(T[] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[, ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[, , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[, , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[, , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[, , , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[, , , , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[, , , , , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[, , , , , , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } public static void Example(T[, , , , , , , , , ,] array) { - throw new NotImplementedException(); + Console.WriteLine(array); } } - - public static class MethodsReturningHighDArrays - { + + public static class MethodsReturningHighDArrays + { public static T1[,] Example1() { - throw new NotImplementedException(); + return new T1[1, 1]; } - - public static T1[,,,,,] Example1(int x) + + public static T1[, , , , ,] Example1(int x) { - throw new NotImplementedException(); + return new T1[1, 1, 1, 1, 1, 1]; } public static T1[,] Example2() { - throw new NotImplementedException(); + return new T1[1, 1]; } - public static T1[,,,,,,] Example2() + public static T1[, , , , , ,] Example2() { - throw new NotImplementedException(); + return new T1[1, 1, 1, 1, 1, 1, 1]; } } } diff --git a/tests/fsharp/typecheck/full-rank-arrays/test.fsx b/tests/fsharp/typecheck/full-rank-arrays/test.fsx index f06ed2f8cb..7acdf33058 100644 --- a/tests/fsharp/typecheck/full-rank-arrays/test.fsx +++ b/tests/fsharp/typecheck/full-rank-arrays/test.fsx @@ -3,6 +3,17 @@ #r "HighRankArrayTests.dll" open HighRankArrayTests +open System + +type 't``[,,,,,,,,,]`` with + member this.GetFirst() = + // not supported + // this.[0,0,0,0,0,0,0,0,0,0] + this.GetValue(0,0,0,0,0,0,0,0,0,0) + member this.SetFirst(x) = + // not supported + // this.[0,0,0,0,0,0,0,0,0,0] <- x + this.SetValue(x,0,0,0,0,0,0,0,0,0,0) (* In the F# 3.1.2 release and earlier versions, the compiler's overload resolution breaks on the following class definition. The referenced assembly defines @@ -12,44 +23,89 @@ open HighRankArrayTests F#, but it should still be possible to call one of the overloads which does not include such a parameter. *) type Class1() = - member this.X1 = + member this.X1 () = GenericStaticClassWithMethod.Example [| 2;3;4;5 |] + let x = Array.CreateInstance(typeof, 2, 2, 2, 2, 2, 2, 2) :?> ``[,,,,,,]`` + GenericStaticClassWithMethod.Example(x) - member this.X2 = + member this.X2 () = StaticClassWithGenericMethod.Example [| 1;2;3;4 |] + let x = Array.CreateInstance(typeof, 2, 2, 2, 2, 2, 2, 2) :?> ``[,,,,,,]`` + // not supported + // x.[0,1,0,1,0,1,0] <- 42 + // x.[1,0,1,0,1,0,1] |> printfn "%d" + x.SetValue(42,0,1,0,1,0,1,0) + downcast (x.GetValue(1,0,1,0,1,0,1)) |> printfn "%d" + StaticClassWithGenericMethod.Example(x) - member this.X3 = - let foo = ClassWithArrayCtor ([| 1;3;5;7 |]) + member this.X3 () = + ClassWithArrayCtor ([| 1;3;5;7 |]) |> printfn "%A" + let x = Array.CreateInstance(typeof, 2, 2, 2, 2, 2, 2) :?> ``[,,,,,]`` + // not supported + // x.[0,1,0,1,0,1] <- 42 + // x.[1,0,1,0,1,0] |> printfn "%d" + x.SetValue(42,0,1,0,1,0,1) + downcast (x.GetValue(1,0,1,0,1,0)) |> printfn "%d" + ClassWithArrayCtor(x) |> printfn "%A" () - member this.X4 = + member this.X4 () = let y1 = MethodsReturningHighDArrays.Example1() let y2 = MethodsReturningHighDArrays.Example1(2) StaticClassWithGenericMethod.Example(y1) StaticClassWithGenericMethod.Example(y2) - ClassWithArrayCtor(y1) |> ignore - ClassWithArrayCtor(y2) |> ignore + let x = Array.CreateInstance(typeof, 2, 2, 2, 2, 2, 2, 2, 2) :?> ``[,,,,,,,]`` + // not supported + // x.[0,1,0,1,0,1,0,1] <- 42 + // x.[1,0,1,0,1,0,1,0] |> printfn "%d" + x.SetValue(42,0,1,0,1,0,1,0,1) + downcast (x.GetValue(1,0,1,0,1,0,1,0)) |> printfn "%d" + StaticClassWithGenericMethod.Example(x) + + ClassWithArrayCtor(y1) |> printfn "%A" + ClassWithArrayCtor(y2) |> printfn "%A" () - member this.X5 = + member this.X5 () = let y1 = MethodsReturningHighDArrays.Example2<_>() let y2 = MethodsReturningHighDArrays.Example2<_,_>() StaticClassWithGenericMethod.Example(y1) StaticClassWithGenericMethod.Example(y2) - ClassWithArrayCtor(y1) |> ignore - ClassWithArrayCtor(y2) |> ignore + ClassWithArrayCtor(y1) |> printfn "%A" + ClassWithArrayCtor(y2) |> printfn "%A" () + member this.X6 () = + let getFirst (x:``[,,,,,,,,,]``<'t>) : 't = + downcast (x.GetFirst()) + let setFirst y (x:``[,,,,,,,,,]``<'t>) = + x.SetFirst(y) + + let x = Array.CreateInstance(typeof, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2) :?> ``[,,,,,,,,,]`` + x |> setFirst "foo" + x |> getFirst |> printfn "%s" + + + member this.RunTests() = + this.X1() + this.X2() + this.X3() + this.X4() + this.X5() + this.X6() + (* avoid ;; -- to avoid fsi error recovery *) let _ = (* May not be enough if fsi does error recovery... * So avoid using ;; *) + let x = Class1() + x.RunTests() System.Console.WriteLine "Test Passed"; System.IO.File.WriteAllText ("test.ok", "ok"); exit 0 From 7ef4078fda795183ea61c6e46d7ed850587b2fc0 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 7 Oct 2014 17:51:49 +0100 Subject: [PATCH 18/20] updates to docs to clarify build steps before test --- DEVGUIDE.html | 183 ++++++++++++++++++------------------------- tests/TESTGUIDE.html | 43 +++------- 2 files changed, 90 insertions(+), 136 deletions(-) diff --git a/DEVGUIDE.html b/DEVGUIDE.html index cf53e59b35..b981ad5b0c 100644 --- a/DEVGUIDE.html +++ b/DEVGUIDE.html @@ -323,104 +323,82 @@

F# Compiler + Library Open Contribution Repository

Questions? If you have questions about the source code, please ask in the issues and discussion forums.

-

Compilation Instructions

+

1. Building a Proto Compiler

The compiler is compiled as a set of .NET 4.0 components using a bootstrap process. - When you build the compiler using the standard instructions below, you get fsc.exe, fsi.exe, FSharp.Core.dll, FSharp.Compiler.dll and some related DLLs.

- -

1. Building a Proto Compiler

-

This uses the lkg compiler to build. Note that you need the .NET framework 3.5 installed on your machine in order to complete this step.

-    cd src 
-    gacutil /i ..\lkg\FSharp-2.0.50726.900\bin\FSharp.Core.dll
-    msbuild fsharp-proto-build.proj
+    gacutil /i lkg\FSharp-2.0.50726.900\bin\FSharp.Core.dll
+    msbuild src/fsharp-proto-build.proj
     
-

2. Building an F# (Debug) library, compiler, type providers and unit tests

+

2. Building an F# (Debug) library and compiler

-

This uses the proto compiler to build FSharp.Core.dll, FSharp.Compiler.dll and fsc.exe to run on for Mono/.NET 4.0.

+

This uses the proto compiler to build FSharp.Core.dll, FSharp.Compiler.dll and fsc.exe.

-        msbuild fsharp-library-build.proj /p:TargetFramework=net40
-        msbuild fsharp-compiler-build.proj /p:TargetFramework=net40
-        msbuild fsharp-typeproviders-build.proj /p:TargetFramework=net40
-        msbuild fsharp-library-unittests-build.proj /p:TargetFramework=net40
-        msbuild fsharp-library-build.proj /p:TargetFramework=net20
-        msbuild fsharp-library-build.proj /p:TargetFramework=portable47
-        msbuild fsharp-library-build.proj /p:TargetFramework=portable7
+        msbuild src/fsharp-library-build.proj 
+        msbuild src/fsharp-compiler-build.proj 
     
-

- Use this script to add the built FSharp.Core to the - GAC, add required strong name validation skips, and NGen the compiler and libraries. - This requires admin privileges. -

-
-        update.cmd debug -ngen
-    
- -

3. Running Tests

+

You can now use the updated commpiler in Debug\net40\bin\fsc.exe to develop and test basic language and tool features.

-

There are language tests under the tests directory. The test apparatus uses batch files, assuming Perl (ActiveState Perl 5.16.3 is known to work fine) is installed. You can run these on Windows using:

-
-    cd ..\tests
-    BuildTestTools.cmd debug
-    Runtests.cmd debug fsharp
-    Runtests.cmd debug fsharpqa
-    Runtests.cmd debug coreunit    
-
-

- For more details on how to run, debug, and write tests, see tests\TESTGUIDE.html. -

+

3. Full Steps Before Running Tests

-

You can also use the F# compiler and F# interactive as follows:

- -
-    ..\Debug\net40\bin\fsc.exe /help
-    ..\Debug\net40\bin\fsi.exe /help
-    ..\Debug\net40\bin\fsi.exe
-    1 + 1;;
-    #q;;
-
-

Compile hello world.

-
-    echo printfn "hello world" > hello.fs
-    ..\Debug\net40\bin\fsc.exe hello.fs
-    copy ..\Debug\net40\bin\FSharp.Core.dll .
-    hello.exe
-    del /q hello.fs
-    del /q FSharp.Core.dll 
-
- -

4. [Optional] Building and testing the "release" compiler

- -

This uses the proto compiler to build the FSharp.Compiler.dll and fsc.exe to run on for Mono/.NET 4.0.

+

See tests\TESTGUIDE.html to run tests.

+ +

Prior to a Debug test run, you need to complete all of these steps:

-    msbuild fsharp-compiler-build.proj /p:TargetFramework=net40 /p:Configuration=Release
+        msbuild src/fsharp-library-build.proj  /p:Configuration=Debug
+        msbuild src/fsharp-compiler-build.proj  /p:Configuration=Debug
+        msbuild src/fsharp-typeproviders-build.proj  /p:Configuration=Debug
+        msbuild src/fsharp-library-build.proj /p:TargetFramework=net20 /p:Configuration=Debug
+        msbuild src/fsharp-library-build.proj /p:TargetFramework=portable47 /p:Configuration=Debug
+        msbuild src/fsharp-library-build.proj /p:TargetFramework=portable7 /p:Configuration=Debug
+        msbuild src/fsharp-library-build.proj /p:TargetFramework=portable78 /p:Configuration=Debug
+        msbuild src/fsharp-library-build.proj /p:TargetFramework=portable259 /p:Configuration=Debug
+        msbuild src/fsharp-library-unittests-build.proj  /p:Configuration=Debug
+        msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable47 /p:Configuration=Debug
+        msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable7 /p:Configuration=Debug
+        msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable78 /p:Configuration=Debug
+        msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable259 /p:Configuration=Debug
+        src\update.cmd debug -ngen
+        tests\BuildTestTools.cmd Debug 
     
-

- Use this script to add the built FSharp.Core to the - GAC, add required strong name validation skips, and NGen the compiler and libraries. - This requires admin privileges. -

+

[Optional] If building and testing the Visual Studio bits (see below) you will also need:

-        update.cmd debug -ngen
+        msbuild vsintegration\fsharp-vsintegration-build.proj /p:Configuration=Debug
+        msbuild vsintegration\fsharp-vsintegration-unittests-build.proj /p:Configuration=Debug
     
+

Prior to a Release test run, you need to do all of these:

+
+        msbuild src/fsharp-library-build.proj  /p:Configuration=Release
+        msbuild src/fsharp-compiler-build.proj  /p:Configuration=Release
+        msbuild src/fsharp-typeproviders-build.proj  /p:Configuration=Release
+        msbuild src/fsharp-library-build.proj /p:TargetFramework=net20 /p:Configuration=Release
+        msbuild src/fsharp-library-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
+        msbuild src/fsharp-library-build.proj /p:TargetFramework=portable7 /p:Configuration=Release
+        msbuild src/fsharp-library-build.proj /p:TargetFramework=portable78 /p:Configuration=Release
+        msbuild src/fsharp-library-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
+        msbuild src/fsharp-library-unittests-build.proj  /p:Configuration=Release
+        msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
+        msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable7 /p:Configuration=Release
+        msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable78 /p:Configuration=Release
+        msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
+        src\update.cmd release -ngen
+        tests\BuildTestTools.cmd Release 
+    
+

[Optional] If building and testing the Visual Studio bits (see below) you will also need:

+
+        msbuild vsintegration\fsharp-vsintegration-build.proj /p:Configuration=Release
+        msbuild vsintegration\fsharp-vsintegration-unittests-build.proj /p:Configuration=Release
+    
- -

5. [Optional] Open a solution with Visual Studio

- -

- You can use "fsharp.sln" to browse source code using Visual Studio. - However, you need to complete step 1) and 2) in order to properly - open this solution. In addition, FSharp.Core.Unittests project requires NUnit installed. -

-

6. [Optional] Build Visual Studio components

+

4. [Optional] Build and Install Visual Studio components

To build the VS components:

@@ -428,59 +406,52 @@

6. [Optional] Build Visual Studio components

cd ..\vsintegration msbuild fsharp-vsintegration-build.proj - -

6. [Optional] Build and install Visual Studio components

To install the VS components:

-

- Ensure that the VSIX package is uninstalled, in VS select Tools/Extensions and Updates, - If the packages VisualStudio.FSharp.EnableOpenSource is installed, select Uninstall -

+
    +
  • + First ensure that the VSIX package is uninstalled, in VS select Tools/Extensions and Updates, + If the packages VisualStudio.FSharp.EnableOpenSource is installed, select Uninstall +
  • +
  • Then:
  • +
         ..\Debug\net40\bin\EnableOpenSource.vsix
     

- Restart Visual Studio, now it should be running the open source FSharp.VS.FSI. + Now restart Visual Studio, now it should be running your freshly built components.

-
-    

Notes on the build

-

- The compiler binaries produced are "private" and - strong-named signed with a test key (src\fsharp\test.snk). They use CLI assembly version nunmber 2.9.9.999. You can place these components in the GAC but they will not replace - the components used by Visual Studio or other normal F# programs. -

- -

- The prerequisites and build command line for compiling the source (on Windows) are shown - later in this README. Here's the logic of the build: -

    +
  • + The update.cmd script add the built FSharp.Core to the + GAC, adds required strong name validation skips, and NGens the compiler and libraries. + This requires admin privileges. +
  • +
  • + The compiler binaries produced are "private" and strong-named signed with a test key (src\fsharp\test.snk). +
  • We first need an existing F# compiler, using the one in the 'lkg' directory. Let's assume this compiler has an FSharp.Core.dll with version X.
  • We use this compiler to compile the source in this distribution, to produce a "proto" compiler, in the Proto directory. When run, this compiler still relies on the FSharp.Core.dll with version X.
  • - We use the proto compiler to compile the source for FSharp.Core.dll in this distribution, producing - an FSharp.Core.dll with the version identified in src\source-build-version, usually 1.9.999. + We use the proto compiler to compile the source for FSharp.Core.dll in this distribution.
  • We use the proto compiler to compile the source for FSharp.Compiler.dll, fsc.exe, fsi.exe and other - binaries found in this distribution. When run, these binaries will rely on the FSharp.Core.dll with version - 1.9.999. This is good, since it means the 1.9.999 binaries now form a consistent, bootstrapped compiler. If - you like you should now be able to throw away the compiler with version X. + binaries found in this distribution. +
  • +
  • + Some additional tools are required to build the compiler, notably fslex.exe, fsyacc.exe, + FSharp.PowerPack.Build.Tasks.dll, FsSrGen.exe, FSharp.SRGen.Build.Tasks.dll and the other + tools found in the lkg directory.
-

- Some additional tools are required to build the compiler, notably fslex.exe, fsyacc.exe, - FSharp.PowerPack.Build.Tasks.dll, FsSrGen.exe, FSharp.SRGen.Build.Tasks.dll and the other - tools found in the lkg directory. These are "Last Known Good" binaries created from a version of the F# Power Pack - on CodePlex. If you like you can throw away these binaries and use your own compiled versions of these tools. -

diff --git a/tests/TESTGUIDE.html b/tests/TESTGUIDE.html index 637ce533ba..db0ff996d0 100644 --- a/tests/TESTGUIDE.html +++ b/tests/TESTGUIDE.html @@ -2,7 +2,7 @@ - Visual F# Tests + F# Compiler, Core Library and Visual F# Tools Tests