Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRansom committed Jul 25, 2016
1 parent ae16306 commit 0ae8402
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 53 deletions.
8 changes: 4 additions & 4 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ echo Usage:
echo.
echo build.cmd ^all^|ci^|ci_part1^|ci_part2^|microbuild^|proto^|net40^|coreclr^|debug^|release^|diag^|compiler^|pcls^|vs^
echo ^test-coreunit^|test-corecompile^|test-smoke^|test-coreclr^|test-pcls^|test-fsharp^|test-fsharpqa^|test-vs^
echo.
echo No arguments default to 'build'
echo. rate strings by comma
echo To specify multiple values, sepa
echo.
echo No arguments default to 'build'
echo.
echo To specify multiple values, separate strings by comma
echo.
echo.This builds the net40 build of the compiler without running tests
echo.
Expand Down
81 changes: 40 additions & 41 deletions src/fsharp/FSharp.Core/reflect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -390,45 +390,44 @@ module internal Impl =
// Which field holds the nested tuple?
let tupleEncField = maxTuple-1

let rec mkTupleType isStruct (asm:Assembly) (tys: Type[]) =
let tupleFullName n =
let refTupleTypes = Dictionary<Assembly, Type[]>()
let valueTupleTypes = Dictionary<Assembly, Type[]>()

let rec mkTupleType isStruct (asm:Assembly) (tys:Type[]) =
let table =
let makeIt n =
let tupleFullName n =
let structOffset = if isStruct then 9 else 0
let index = n - 1 + structOffset
tupleNames.[index]

match tys.Length with
| 1 -> asm.GetType(tupleFullName 1).MakeGenericType(tys)
| 2 -> asm.GetType(tupleFullName 2).MakeGenericType(tys)
| 3 -> asm.GetType(tupleFullName 3).MakeGenericType(tys)
| 4 -> asm.GetType(tupleFullName 4).MakeGenericType(tys)
| 5 -> asm.GetType(tupleFullName 5).MakeGenericType(tys)
| 6 -> asm.GetType(tupleFullName 6).MakeGenericType(tys)
| 7 -> asm.GetType(tupleFullName 7).MakeGenericType(tys)
| n when n >= maxTuple ->
let tysA = tys.[0..tupleEncField-1]
let tysB = tys.[maxTuple-1..]
let tyB = mkTupleType isStruct asm tysB
asm.GetType(tupleFullName 8).MakeGenericType(Array.append tysA [| tyB |])
| _ -> invalidArg "tys" (SR.GetString(SR.invalidTupleTypes))

if isStruct then
match n with
| 1 -> "System.ValueTuple`1"
| 2 -> "System.ValueTuple`2"
| 3 -> "System.ValueTuple`3"
| 4 -> "System.ValueTuple`4"
| 5 -> "System.ValueTuple`5"
| 6 -> "System.ValueTuple`6"
| 7 -> "System.ValueTuple`7"
| 8 -> "System.ValueTuple`8"
| _ -> "System.ValueTuple"
else
match n with
| 1 -> "System.Tuple`1"
| 2 -> "System.Tuple`2"
| 3 -> "System.Tuple`3"
| 4 -> "System.Tuple`4"
| 5 -> "System.Tuple`5"
| 6 -> "System.Tuple`6"
| 7 -> "System.Tuple`7"
| 8 -> "System.Tuple`8"
| _ -> "System.Tuple"

match tys.Length with
| 1 -> asm.GetType(tupleFullName 1).MakeGenericType(tys)
| 2 -> asm.GetType(tupleFullName 2).MakeGenericType(tys)
| 3 -> asm.GetType(tupleFullName 3).MakeGenericType(tys)
| 4 -> asm.GetType(tupleFullName 4).MakeGenericType(tys)
| 5 -> asm.GetType(tupleFullName 5).MakeGenericType(tys)
| 6 -> asm.GetType(tupleFullName 6).MakeGenericType(tys)
| 7 -> asm.GetType(tupleFullName 7).MakeGenericType(tys)
| n when n >= maxTuple ->
let tysA = tys.[0..tupleEncField-1]
let tysB = tys.[maxTuple-1..]
let tyB = mkTupleType isStruct asm tysB
asm.GetType(tupleFullName 8).MakeGenericType(Array.append tysA [| tyB |])
| _ -> invalidArg "tys" (SR.GetString(SR.invalidTupleTypes))
match refTupleTypes.TryGetValue(asm). ->
| false, _ ->
let table = Array init<Type> 9
try
for i = 1 .. 8 do table.[i] <- makeIt i
refTupleTypes.Add(asm, table)
with
| :? ArgumentException ->
| _ - reraise()
table
| true, table -> table

let rec getTupleTypeInfo (typ:Type) =
if not (isTupleType (typ) ) then invalidArg "typ" (SR.GetString1(SR.notATupleType, typ.FullName));
Expand Down Expand Up @@ -774,13 +773,13 @@ type FSharpType =
invalidArg "types" (SR.GetString(SR.nullsNotAllowedInArray))
Impl.mkTupleType false asm types

static member MakeTupleTypeWithAssembly (asm:Assembly) (types:Type[]) =
static member MakeTupleType (asm:Assembly, types:Type[]) =
Impl.checkNonNull "types" types
if types |> Array.exists (function null -> true | _ -> false) then
invalidArg "types" (SR.GetString(SR.nullsNotAllowedInArray))
Impl.mkTupleType false asm types

static member MakeStructTupleTypeWithAssembly (asm:Assembly) (types:Type[]) =
static member MakeValueTupleType (asm:Assembly, types:Type[]) =
Impl.checkNonNull "types" types
if types |> Array.exists (function null -> true | _ -> false) then
invalidArg "types" (SR.GetString(SR.nullsNotAllowedInArray))
Expand Down Expand Up @@ -875,7 +874,7 @@ type FSharpValue =
let (f : (obj -> obj) -> obj) = downcast o
f implementation

static member MakeTuple(tupleElements: obj[],tupleType:Type) =
static member MakeTuple(tupleElements: obj[], tupleType:Type) =
Impl.checkNonNull "tupleElements" tupleElements
Impl.checkTupleType("tupleType",tupleType)
Impl.getTupleConstructor tupleType tupleElements
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/FSharp.Core/reflect.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ type FSharpType =
/// <summary>Returns a <c>System.Type</c> representing an F# tuple type with the given element types</summary>
/// <param name="types">An array of types for the tuple elements.</param>
/// <returns>The type representing the tuple containing the input elements.</returns>
static member MakeTupleTypeWithAssembly: asm:Assembly -> types:Type[] -> Type
static member MakeTupleType: asm:Assembly * types:Type[] -> Type

/// <summary>Returns a <c>System.Type</c> representing an F# struct tuple type with the given element types</summary>
/// <param name="types">An array of types for the tuple elements.</param>
/// <returns>The type representing the struct tuple containing the input elements.</returns>
static member MakeStructTupleTypeWithAssembly: asm:Assembly -> types:Type[] -> Type
static member MakeValueTupleType: asm:Assembly * types:Type[] -> Type

/// <summary>Return true if the <c>typ</c> is a representation of an F# tuple type </summary>
/// <param name="typ">The type to check.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="..\..\..\..\..\packages\System.ValueTuple.4.0.0-rc3-24212-01\lib\netstandard1.1\System.ValueTuple.dll">
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(OpenBuild)' == 'True' ">
<Reference Include="$(OpenDrop)\FSharp.Core.dll">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="..\..\..\..\..\packages\System.ValueTuple.4.0.0-rc3-24212-01\lib\netstandard1.1\System.ValueTuple.dll">
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(OpenBuild)' == 'True' ">
<Reference Include="$(OpenDrop)\FSharp.Core.dll">
Expand Down

0 comments on commit 0ae8402

Please sign in to comment.