Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRansom committed Oct 19, 2024
1 parent 337411e commit e62339c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 76 deletions.
1 change: 1 addition & 0 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ module AddAugmentationDeclarations =
let g = cenv.g
if AugmentTypeDefinitions.TyconIsCandidateForAugmentationWithCompare g tycon && scSet.Contains tycon.Stamp then
let tcref = mkLocalTyconRef tycon

let tcaug = tycon.TypeContents
let ty = if tcref.Deref.IsFSharpException then g.exn_ty else generalizedTyconRef g tcref
let m = tycon.Range
Expand Down
51 changes: 28 additions & 23 deletions src/Compiler/TypedTree/TypedTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ and copyAndRemapAndBindTyparsFull remapAttrib tyenv tps =
match tps with
| [] -> tps, tyenv
| _ ->
match tyenv.realsig with
| true ->
tps, tyenv
| false ->
//match tyenv.realsig with
//| true ->
// tps, tyenv
//| false ->
let tpsR = copyTypars false tps
let tyenv = { tyenv with tpinst = bindTypars tps (generalizeTypars tpsR) tyenv.tpinst }
(tps, tpsR) ||> List.iter2 (fun tporig tp ->
Expand Down Expand Up @@ -6333,55 +6333,60 @@ and copyTycon compgen (tycon: Tycon) =
| _ -> Construct.NewClonedTycon tycon

/// This operates over a whole nested collection of tycons and vals simultaneously *)
and copyAndRemapAndBindTyconsAndVals ctxt compgen tmenv tycons vs =
and copyAndRemapAndBindTyconsAndVals ctxt compgen tmenv tycons vs =

let tyconsR = tycons |> List.map (copyTycon compgen)

let tmenvinner = bindTycons tycons tyconsR tmenv

// Values need to be copied and renamed.
let vsR, tmenvinner = copyAndRemapAndBindVals ctxt compgen tmenvinner vs

// "if a type constructor is hidden then all its inner values and inner type constructors must also be hidden"
// Hence we can just lookup the inner tycon/value mappings in the tables.

let lookupVal (v: Val) =
let vref =
try
let res = tmenvinner.valRemap[v]
res
with :? KeyNotFoundException ->
// Hence we can just lookup the inner tycon/value mappings in the tables.

let lookupVal (v: Val) =
let vref =
try
let res = tmenvinner.valRemap[v]
res
with :? KeyNotFoundException ->
errorR(InternalError(sprintf "couldn't remap internal value '%s'" v.LogicalName, v.Range))
mkLocalValRef v
vref.Deref

let lookupTycon tycon =
let tcref =
try
let lookupTycon tycon =
let tcref =
try
let res = tmenvinner.tyconRefRemap[mkLocalTyconRef tycon]
res
with :? KeyNotFoundException ->
with :? KeyNotFoundException ->
errorR(InternalError("couldn't remap internal tycon " + showL(DebugPrint.tyconL tycon), tycon.Range))
mkLocalTyconRef tycon
tcref.Deref

(tycons, tyconsR) ||> List.iter2 (fun tcd tcdR ->
(tycons, tyconsR)
||> List.iter2 (fun tcd tcdR ->
let lookupTycon tycon = lookupTycon tycon
let tpsR, tmenvinner2 = tmenvCopyRemapAndBindTypars (remapAttribs ctxt tmenvinner) tmenvinner (tcd.entity_typars.Force(tcd.entity_range))

tcdR.entity_typars <- LazyWithContext.NotLazy tpsR
tcdR.entity_attribs <- tcd.entity_attribs |> remapAttribs ctxt tmenvinner2
tcdR.entity_tycon_repr <- tcd.entity_tycon_repr |> remapTyconRepr ctxt tmenvinner2

let typeAbbrevR = tcd.TypeAbbrev |> Option.map (remapType tmenvinner2)

tcdR.entity_tycon_tcaug <- tcd.entity_tycon_tcaug |> remapTyconAug tmenvinner2
tcdR.entity_modul_type <- MaybeLazy.Strict (tcd.entity_modul_type.Value
|> mapImmediateValsAndTycons lookupTycon lookupVal)
tcdR.entity_modul_type <- MaybeLazy.Strict (tcd.entity_modul_type.Value |> mapImmediateValsAndTycons lookupTycon lookupVal)

let exnInfoR = tcd.ExceptionInfo |> remapTyconExnInfo ctxt tmenvinner2
match tcdR.entity_opt_data with
| Some optData -> tcdR.entity_opt_data <- Some { optData with entity_tycon_abbrev = typeAbbrevR; entity_exn_info = exnInfoR }
| _ ->
| _ ->
tcdR.SetTypeAbbrev typeAbbrevR
tcdR.SetExceptionInfo exnInfoR)
tyconsR, vsR, tmenvinner

tyconsR, vsR, tmenvinner

and allTyconsOfTycon (tycon: Tycon) =
seq { yield tycon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1070,61 +1070,8 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value: not struct>(keepStron
FSharp """
namespace Equality
type SmallNonGenericTuple = SmallNonGenericTuple of int * string
type SmallGenericTuple<'a> = SmallGenericTuple of int * 'a
type BigNonGenericTuple = BigNonGenericTuple of int * string * byte * int * string * byte
type BigGenericTuple<'a> = BigGenericTuple of int * 'a * byte * int * 'a * byte
[<Struct>]
type SmallNonGenericTupleStruct = SmallNonGenericTupleStruct of int * string
[<Struct>]
type SmallGenericTupleStruct<'a> = SmallGenericTupleStruct of int * 'a
[<Struct>]
type BigNonGenericTupleStruct = BigNonGenericTupleStruct of int * string * byte * int * string * byte
[<Struct>]
type BigGenericTupleStruct<'a> = BigGenericTupleStruct of int * 'a * byte * int * 'a * byte
type ReferenceTuples() =
let numbers = Array.init 1000 id
member _.SmallNonGenericTuple() =
numbers
|> Array.countBy (fun n -> SmallNonGenericTuple(n, string n))
member _.SmallGenericTuple() =
numbers
|> Array.countBy (fun n -> SmallGenericTuple(n, string n))
member _.BigNonGenericTuple() =
numbers
|> Array.countBy (fun n -> BigNonGenericTuple(n, string n, byte n, n, string n, byte n))
member _.BigGenericTuple() =
numbers
|> Array.countBy (fun n -> BigGenericTuple(n, string n, byte n, n, string n, byte n))
member _.SmallNonGenericTupleStruct() =
numbers
|> Array.countBy (fun n -> SmallNonGenericTupleStruct(n, string n))
member _.SmallGenericTupleStruct() =
numbers
|> Array.countBy (fun n -> SmallGenericTupleStruct(n, string n))
member _.BigNonGenericTupleStruct() =
numbers
|> Array.countBy (fun n -> BigNonGenericTupleStruct(n, string n, byte n, n, string n, byte n))
member _.BigGenericTupleStruct() =
numbers
|> Array.countBy (fun n -> BigGenericTupleStruct(n, string n, byte n, n, string n, byte n))
"""
|> asLibrary
|> withRealInternalSignature realSig
Expand Down

0 comments on commit e62339c

Please sign in to comment.