Skip to content

Commit

Permalink
Fixed merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ncave committed Dec 8, 2023
1 parent cb7ce73 commit b9cfa2b
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 52 deletions.
19 changes: 14 additions & 5 deletions fcs/fcs-fable/System.Collections.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module Immutable =
type ImmutableArray<'T> =
static member CreateBuilder() = ResizeArray<'T>()

[<Sealed>]
type ImmutableHashSet<'T>(values: 'T seq) =
let xs = HashSet<'T>(values)

Expand Down Expand Up @@ -62,13 +63,21 @@ module Immutable =
member _.GetEnumerator(): IEnumerator<'T> =
xs.GetEnumerator()

type ImmutableDictionary<'Key, 'Value when 'Key: equality>(pairs: KeyValuePair<'Key, 'Value> seq) =
let xs = Dictionary<'Key, 'Value>()
do for pair in pairs do xs.Add(pair.Key, pair.Value)
[<Sealed>]
type ImmutableDictionary<'Key, 'Value when 'Key: equality>(xs: Dictionary<'Key, 'Value>) =
static member Create(comparer: IEqualityComparer<'Key>) =
ImmutableDictionary<'Key, 'Value>(Dictionary(comparer))

static member CreateRange(items) = ImmutableDictionary<'Key, 'Value>(items)
static member Empty = ImmutableDictionary<'Key, 'Value>(Array.empty)
static member CreateRange(items: IEnumerable<KeyValuePair<'Key, 'Value>>) =
let xs = Dictionary<'Key, 'Value>()
for pair in items do
xs.Add(pair.Key, pair.Value)
ImmutableDictionary<'Key, 'Value>(xs)

static member Empty =
ImmutableDictionary<'Key, 'Value>(Dictionary())

member _.IsEmpty = xs.Count = 0
member _.Item with get (key: 'Key): 'Value = xs[key]
member _.ContainsKey (key: 'Key) = xs.ContainsKey(key)

Expand Down
2 changes: 1 addition & 1 deletion fcs/fcs-fable/TcImports_shim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ module TcImports =
XmlDocumentationInfo = None
}

let optdata = lazy (
let optdata = InterruptibleLazy(fun _ ->
match memoize_opt.Apply ccuName with
| None -> None
| Some data ->
Expand Down
4 changes: 2 additions & 2 deletions fcs/fcs-fable/fcs-fable.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
<!-- <Compile Include="$(FSharpSourcesRoot)/Facilities/CompilerLocation.fs" /> -->
<Compile Include="$(FSharpSourcesRoot)/Facilities/BuildGraph.fsi" />
<Compile Include="$(FSharpSourcesRoot)/Facilities/BuildGraph.fs" />
<Compile Include="$(FSharpSourcesRoot)/Utilities/ReadOnlySpan.fsi" />
<Compile Include="$(FSharpSourcesRoot)/Utilities/ReadOnlySpan.fs" />
<!-- <Compile Include="$(FSharpSourcesRoot)/Utilities/ReadOnlySpan.fsi" /> -->
<!-- <Compile Include="$(FSharpSourcesRoot)/Utilities/ReadOnlySpan.fs" /> -->
<!-- <FsLex Include="$(FSharpSourcesRoot)/AbstractIL/illex.fsl" /> -->
<!-- <None Include="$(FSharpSourcesRoot)/AbstractIL/illex.fsl" /> -->
<!-- <FsYacc Include="$(FSharpSourcesRoot)/AbstractIL/ilpars.fsy" /> -->
Expand Down
2 changes: 1 addition & 1 deletion fcs/fcs-fable/test/fcs-fable-test.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<ItemGroup>
<!-- <PackageReference Include="FSharp.Core" Version="8.0.0" /> -->
<!-- <Reference Include="../../../artifacts/bin/FSharp.Compiler.Service/Release/netstandard2.0/FSharp.Core.dll" /> -->
<PackageReference Include="Fable.Core" Version="4.1.0" />
<PackageReference Include="Fable.Core" Version="4.2.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"sdk": {
"version": "8.0.100-rc.1.23463.5",
"version": "8.0.100",
"allowPrerelease": true
},
"tools": {
"dotnet": "8.0.100-rc.1.23463.5",
"dotnet": "8.0.100",
"vs": {
"version": "17.6",
"components": [
Expand Down
17 changes: 6 additions & 11 deletions src/Compiler/AbstractIL/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,19 +1219,14 @@ type ISeekReadIndexedRowReader<'RowT, 'KeyT, 'T when 'RowT: struct> =
abstract CompareKey: 'KeyT -> int
abstract ConvertRow: ref<'RowT> -> 'T

#if FABLE_COMPILER
[<Struct>]
type CustomAttributeRow =
val mutable parentIndex: TaggedIndex<HasCustomAttributeTag>
val mutable typeIndex: TaggedIndex<CustomAttributeTypeTag>
val mutable valueIndex: int

let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowReader<CustomAttributeRow, 'KeyT, 'T>) =
let mutable row = ref Unchecked.defaultof<CustomAttributeRow>
#else
let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowReader<'RowT, _, _>) =
let mutable row = Unchecked.defaultof<'RowT>
#endif
let mutable row = ref Unchecked.defaultof<'RowT>

let mutable startRid = -1
let mutable endRid = -1
Expand Down Expand Up @@ -1310,9 +1305,9 @@ let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowRead
let mutable fin = false

while rid <= numRows && not fin do
reader.GetRow(rid, &row)
reader.GetRow(rid, row)

if reader.CompareKey(reader.GetKey(&row)) = 0 then
if reader.CompareKey(reader.GetKey(row)) = 0 then
endRid <- rid
else
fin <- true
Expand All @@ -1329,9 +1324,9 @@ let seekReadIndexedRowsByInterface numRows binaryChop (reader: ISeekReadIndexedR
else

Array.init (endRid - startRid + 1) (fun i ->
let mutable row = Unchecked.defaultof<'RowT>
reader.GetRow(startRid + i, &row)
reader.ConvertRow(&row))
let mutable row = ref Unchecked.defaultof<'RowT>
reader.GetRow(startRid + i, row)
reader.ConvertRow(row))

let inline rowAddr (ctxt: ILMetadataReader) (tn: TableName) (idx: int) =
ref (ctxt.rowAddr tn idx)
Expand Down
4 changes: 0 additions & 4 deletions src/Compiler/Checking/QuotationTranslator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,9 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
let witnessArgInfo =
if g.generateWitnesses && inWitnessPassingScope then
let witnessInfo = traitInfo.GetWitnessInfo()
#if FABLE_COMPILER
env.witnessesInScope.TryFind witnessInfo
#else
match env.witnessesInScope.TryGetValue witnessInfo with
| true, storage -> Some storage
| _ -> None
#endif
else
None

Expand Down
4 changes: 0 additions & 4 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,13 +1318,9 @@ let ComputeGenerateWitnesses (g: TcGlobals) eenv =
&& not eenv.suppressWitnesses

let TryStorageForWitness (_g: TcGlobals) eenv (w: TraitWitnessInfo) =
#if FABLE_COMPILER
eenv.witnessesInScope.TryFind w
#else
match eenv.witnessesInScope.TryGetValue w with
| true, storage -> Some storage
| _ -> None
#endif

let IsValRefIsDllImport g (vref: ValRef) =
vref.Attribs |> HasFSharpAttributeOpt g g.attrib_DllImportAttribute
Expand Down
18 changes: 0 additions & 18 deletions src/Compiler/TypedTree/TypedTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10293,23 +10293,6 @@ let CombineCcuContentFragments l =
/// An immutable mappping from witnesses to some data.
///
/// Note: this uses an immutable HashMap/Dictionary with an IEqualityComparer that captures TcGlobals, see EmptyTraitWitnessInfoHashMap
#if FABLE_COMPILER
type TraitWitnessInfoHashMap<'T> = Internal.Utilities.Collections.Tagged.Map<TraitWitnessInfo, 'T>

/// Create an empty immutable mapping from witnesses to some data
let EmptyTraitWitnessInfoHashMap g : TraitWitnessInfoHashMap<'T> =
let comparer =
{ new IComparer<TraitWitnessInfo> with
member _.Compare(x, y) =
let xhash = hash x
let yhash = hash y
let equals x y = traitKeysAEquiv g TypeEquivEnv.Empty x y
if xhash = yhash
then if equals x y then 0 else -1
else if xhash < yhash then -1 else 1
}
Internal.Utilities.Collections.Tagged.Map<_,_>.FromList(comparer, [])
#else //!FABLE_COMPILER
type TraitWitnessInfoHashMap<'T> = ImmutableDictionary<TraitWitnessInfo, 'T>

/// Create an empty immutable mapping from witnesses to some data
Expand All @@ -10319,7 +10302,6 @@ let EmptyTraitWitnessInfoHashMap g : TraitWitnessInfoHashMap<'T> =
member _.Equals(a, b) = traitKeysAEquiv g TypeEquivEnv.Empty a b
member _.GetHashCode(a) = hash a.MemberName
})
#endif //!FABLE_COMPILER

let (|WhileExpr|_|) expr =
match expr with
Expand Down
4 changes: 0 additions & 4 deletions src/Compiler/TypedTree/TypedTreeOps.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2585,11 +2585,7 @@ val GetTraitWitnessInfosOfTypars: TcGlobals -> numParentTypars: int -> typars: T
/// An immutable mappping from witnesses to some data.
///
/// Note: this uses an immutable HashMap/Dictionary with an IEqualityComparer that captures TcGlobals, see EmptyTraitWitnessInfoHashMap
#if FABLE_COMPILER
type TraitWitnessInfoHashMap<'T> = Internal.Utilities.Collections.Tagged.Map<TraitWitnessInfo, 'T>
#else
type TraitWitnessInfoHashMap<'T> = ImmutableDictionary<TraitWitnessInfo, 'T>
#endif

/// Create an empty immutable mapping from witnesses to some data
val EmptyTraitWitnessInfoHashMap: TcGlobals -> TraitWitnessInfoHashMap<'T>
Expand Down
8 changes: 8 additions & 0 deletions src/Compiler/Utilities/Cancellable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ module Cancellable =
if ct.IsCancellationRequested then
ValueOrCancelled.Cancelled(OperationCanceledException ct)
else
#if FABLE_COMPILER
oper ct
#else
try
oper ct
with :? OperationCanceledException as e ->
ValueOrCancelled.Cancelled(OperationCanceledException e.CancellationToken)
#endif

let fold f acc seq =
Cancellable(fun ct ->
Expand Down Expand Up @@ -142,7 +146,11 @@ type CancellableBuilder() =
| Choice2Of2 err -> Cancellable.run ct (handler err)
| ValueOrCancelled.Cancelled err1 -> ValueOrCancelled.Cancelled err1)

#if FABLE_COMPILER
member inline _.Using(resource: 'Resource when 'Resource :> IDisposable, [<InlineIfLambda>] comp) =
#else
member inline _.Using(resource, [<InlineIfLambda>] comp) =
#endif
Cancellable(fun ct ->
#if !FSHARPCORE_USE_PACKAGE
__debugPoint ""
Expand Down

0 comments on commit b9cfa2b

Please sign in to comment.