Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match expression #333

Draft
wants to merge 72 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
8b007c0
Lexing done for match keyword
LPeter1997 Sep 3, 2023
e5794d9
Syntax tree, arrow token
LPeter1997 Sep 3, 2023
a12b870
Syntax tree done for patterns
LPeter1997 Sep 3, 2023
8ac7d35
Update Parser.cs
LPeter1997 Sep 3, 2023
105fc8c
Written untyped and bound nodes
LPeter1997 Sep 10, 2023
aabec7f
Binder done for match expressions
LPeter1997 Sep 10, 2023
3defdc2
Lowering done for match expression
LPeter1997 Sep 10, 2023
caf1b78
Update CilCodegen.cs
LPeter1997 Sep 12, 2023
bd094e3
Create BinarySearch.cs
LPeter1997 Sep 26, 2023
c14c85b
Create ValueDomain.cs
LPeter1997 Sep 26, 2023
b3b2418
Basic integral domain
LPeter1997 Sep 26, 2023
294fd79
Update IntegralDomain.cs
LPeter1997 Sep 27, 2023
1f9706c
Update ValueDomain.cs
LPeter1997 Sep 27, 2023
a299a6e
Added isEmpty to domain
LPeter1997 Sep 27, 2023
bf3666c
Added cloning
LPeter1997 Sep 27, 2023
f08d654
Update ValueDomain.cs
LPeter1997 Sep 27, 2023
33082ab
Added ToString
LPeter1997 Sep 27, 2023
8e4d7bb
Added basic integral domain tests
LPeter1997 Sep 27, 2023
cc269f9
Update IntegralDomainTests.cs
LPeter1997 Sep 27, 2023
48089b4
Update IntegralDomain.cs
LPeter1997 Sep 28, 2023
bbe873c
Update IntegralDomain.cs
LPeter1997 Oct 3, 2023
2f2518c
Update IntegralDomain.cs
LPeter1997 Oct 3, 2023
ebdf5b1
Threw out unused utils
LPeter1997 Oct 3, 2023
d0ac874
Update IntegralDomain.cs
LPeter1997 Oct 3, 2023
e5d8077
Update IntegralDomain.cs
LPeter1997 Oct 3, 2023
b055268
Update IntegralDomainTests.cs
LPeter1997 Oct 3, 2023
fae6072
Added string domain
LPeter1997 Oct 3, 2023
d014e2f
Update ValueDomain.cs
LPeter1997 Oct 3, 2023
20be7ee
Cleanup
LPeter1997 Oct 4, 2023
6eb2810
Added outline for decision tree
LPeter1997 Oct 4, 2023
3ab626c
Update DecisionTree.cs
LPeter1997 Oct 4, 2023
a70217a
Update DecisionTree.cs
LPeter1997 Oct 4, 2023
6d2ca42
Factored out match lowering
LPeter1997 Oct 5, 2023
23eb5de
Update LocalRewriter_MatchExpression.cs
LPeter1997 Oct 5, 2023
0cf83ef
Update DecisionTree.cs
LPeter1997 Oct 5, 2023
031cace
Tweak
LPeter1997 Oct 5, 2023
b3df53d
Update DecisionTree.cs
LPeter1997 Oct 5, 2023
429410e
Implemented specialization
LPeter1997 Oct 5, 2023
9ff64e2
Update DecisionTree.cs
LPeter1997 Oct 5, 2023
1f3e965
Update DecisionTree.cs
LPeter1997 Oct 5, 2023
4da06a0
Update DecisionTree.cs
LPeter1997 Oct 5, 2023
0e0c159
Better API
LPeter1997 Oct 5, 2023
fc9422f
Update DecisionTree.cs
LPeter1997 Oct 5, 2023
c24965e
Update DecisionTree.cs
LPeter1997 Oct 5, 2023
5b65465
Reporting tree analysis
LPeter1997 Oct 5, 2023
4f74f17
Update MatchExhaustiveness.cs
LPeter1997 Oct 5, 2023
f174f7c
More diags
LPeter1997 Oct 5, 2023
eae55e1
Update draco.tmLanguage.yml
LPeter1997 Oct 5, 2023
a9eac8e
Update draco.tmLanguage.json
LPeter1997 Oct 5, 2023
f20f3e0
Merge branch 'main' into match-expression
LPeter1997 Oct 13, 2023
0cdc214
Fix
LPeter1997 Oct 13, 2023
25668d2
Cleanup
LPeter1997 Oct 13, 2023
d3bab8d
Update DecisionTree.cs
LPeter1997 Oct 14, 2023
32a1585
Update DecisionTree.cs
LPeter1997 Oct 14, 2023
055c60b
Update DecisionTree.cs
LPeter1997 Oct 15, 2023
2ffb60b
Update DecisionTree.cs
LPeter1997 Oct 15, 2023
85fa323
Update DecisionTree.cs
LPeter1997 Oct 15, 2023
7f9666a
Update DecisionTree.cs
LPeter1997 Oct 15, 2023
c26162d
Tweak
LPeter1997 Oct 15, 2023
4186b7d
Update TypeProvider.cs
LPeter1997 Oct 15, 2023
a4e6a01
Update LocalRewriter_MatchExpression.cs
LPeter1997 Oct 15, 2023
a87bae6
Update BoundTree.sbncs
LPeter1997 Oct 15, 2023
c3a55e8
Update CompilingCodeTests.cs
LPeter1997 Oct 15, 2023
76ef003
Added flow analysis test
LPeter1997 Oct 15, 2023
3f18fc8
Update FlowAnalysisTests.cs
LPeter1997 Oct 15, 2023
e3102ca
Fix
LPeter1997 Oct 16, 2023
ab38bf7
Merge branch 'main' into match-expression
LPeter1997 Oct 17, 2023
e348313
Highlight discard
LPeter1997 Oct 17, 2023
e324a46
Crash fixes
LPeter1997 Oct 17, 2023
2b13639
Merge branch 'main' into match-expression
LPeter1997 Oct 29, 2023
9c8044d
Merge branch 'main' into match-expression
LPeter1997 Oct 29, 2023
b172a0b
Update DecisionTree.cs
LPeter1997 Oct 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update TypeProvider.cs
  • Loading branch information
LPeter1997 committed Oct 15, 2023
commit 4186b7d74c2804ace80c98ce5bc3201f34058954
17 changes: 4 additions & 13 deletions src/Draco.Compiler/Internal/Symbols/Metadata/TypeProvider.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@@ -21,7 +22,7 @@ internal sealed class TypeProvider : ISignatureTypeProvider<TypeSymbol, Symbol>,
private IntrinsicSymbols IntrinsicSymbols => this.compilation.IntrinsicSymbols;

private readonly Compilation compilation;
private readonly Dictionary<CacheKey, TypeSymbol> cache = new();
private readonly ConcurrentDictionary<CacheKey, TypeSymbol> cache = new();

public TypeProvider(Compilation compilation)
{
@@ -94,12 +95,7 @@ public TypeSymbol GetGenericTypeParameter(Symbol genericContext, int index)
public TypeSymbol GetTypeFromDefinition(MetadataReader reader, TypeDefinitionHandle handle, byte rawTypeKind)
{
var key = new CacheKey(reader, handle);
if (!this.cache.TryGetValue(key, out var type))
{
type = this.BuildTypeFromDefinition(reader, handle, rawTypeKind);
this.cache.Add(key, type);
}
return type;
return this.cache.GetOrAdd(key, _ => this.BuildTypeFromDefinition(reader, handle, rawTypeKind));
}

private TypeSymbol BuildTypeFromDefinition(MetadataReader reader, TypeDefinitionHandle handle, byte rawTypeKind)
@@ -137,12 +133,7 @@ private TypeSymbol BuildTypeFromDefinition(MetadataReader reader, TypeDefinition
public TypeSymbol GetTypeFromReference(MetadataReader reader, TypeReferenceHandle handle, byte rawTypeKind)
{
var key = new CacheKey(reader, handle);
if (!this.cache.TryGetValue(key, out var type))
{
type = this.BuildTypeFromReference(reader, handle, rawTypeKind);
this.cache.Add(key, type);
}
return type;
return this.cache.GetOrAdd(key, _ => this.BuildTypeFromReference(reader, handle, rawTypeKind));
}

private TypeSymbol BuildTypeFromReference(MetadataReader reader, TypeReferenceHandle handle, byte rawTypeKind)