Skip to content

Commit

Permalink
Bunch of renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
LPeter1997 committed Jan 21, 2025
1 parent 0cda1b4 commit 8c509c1
Show file tree
Hide file tree
Showing 26 changed files with 85 additions and 80 deletions.
24 changes: 12 additions & 12 deletions src/Draco.Compiler.Tests/Semantics/SemanticModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void GetReferencedSymbolFromModuleMemberAccess()
Assert.Empty(diags);
Assert.NotNull(writeLineSymbol);
Assert.NotNull(consoleSymbol);
Assert.Contains(writeLineSymbol, consoleSymbol.Members);
Assert.Contains(writeLineSymbol, consoleSymbol.AllMembers);
}

[Fact]
Expand Down Expand Up @@ -209,8 +209,8 @@ public void GetReferencedSymbolFromFullyQualifiedName()
Assert.NotNull(writeLineSymbol);
Assert.NotNull(consoleSymbol);
Assert.NotNull(systemSymbol);
Assert.Contains(writeLineSymbol, consoleSymbol.Members);
Assert.Contains(consoleSymbol, systemSymbol.Members);
Assert.Contains(writeLineSymbol, consoleSymbol.AllMembers);
Assert.Contains(consoleSymbol, systemSymbol.AllMembers);
}

[Fact]
Expand Down Expand Up @@ -250,8 +250,8 @@ public void GetReferencedSymbolFromFullyQualifiedType()
Assert.NotNull(sbSymbol);
Assert.NotNull(textSymbol);
Assert.NotNull(systemSymbol);
Assert.Contains(sbSymbol, textSymbol.Members);
Assert.Contains(textSymbol, systemSymbol.Members);
Assert.Contains(sbSymbol, textSymbol.AllMembers);
Assert.Contains(textSymbol, systemSymbol.AllMembers);
}

[Fact]
Expand Down Expand Up @@ -292,7 +292,7 @@ public void GetReferencedSymbolFromFullyQualifiedIncompleteName()
Assert.NotNull(errorSymbol);
Assert.NotNull(consoleSymbol);
Assert.NotNull(systemSymbol);
Assert.Contains(consoleSymbol, systemSymbol.Members);
Assert.Contains(consoleSymbol, systemSymbol.AllMembers);
Assert.True(errorSymbol.IsError);
}

Expand Down Expand Up @@ -331,7 +331,7 @@ public void GetReferencedSymbolFromTypeMemberAccess()
Assert.Empty(diags);
Assert.NotNull(appendLineSymbol);
Assert.NotNull(builderSymbol);
Assert.Contains(appendLineSymbol, builderSymbol.Type.Members);
Assert.Contains(appendLineSymbol, builderSymbol.Type.AllMembers);
}

[Fact]
Expand Down Expand Up @@ -402,8 +402,8 @@ public void GetPathSymbolsFromImport()
Assert.NotNull(systemSymbol);
Assert.NotNull(systemCollectionsSymbol);
Assert.NotNull(systemCollectionsGenericSymbol);
Assert.Contains(systemCollectionsSymbol, systemSymbol.Members);
Assert.Contains(systemCollectionsGenericSymbol, systemCollectionsSymbol.Members);
Assert.Contains(systemCollectionsSymbol, systemSymbol.AllMembers);
Assert.Contains(systemCollectionsGenericSymbol, systemCollectionsSymbol.AllMembers);
}

[Fact]
Expand Down Expand Up @@ -440,8 +440,8 @@ public void GetPathSymbolsFromLocalImport()
Assert.NotNull(systemSymbol);
Assert.NotNull(systemCollectionsSymbol);
Assert.NotNull(systemCollectionsGenericSymbol);
Assert.Contains(systemCollectionsSymbol, systemSymbol.Members);
Assert.Contains(systemCollectionsGenericSymbol, systemCollectionsSymbol.Members);
Assert.Contains(systemCollectionsSymbol, systemSymbol.AllMembers);
Assert.Contains(systemCollectionsGenericSymbol, systemCollectionsSymbol.AllMembers);
}

[Fact]
Expand Down Expand Up @@ -475,7 +475,7 @@ public void GetPathSymbolsFromPartiallyNonExistingImport()
Assert.NotNull(collectionsSymbol);
Assert.NotNull(nonexistingSymbol);
Assert.NotNull(fooSymbol);
Assert.Contains(collectionsSymbol, systemSymbol.Members);
Assert.Contains(collectionsSymbol, systemSymbol.AllMembers);
Assert.True(nonexistingSymbol.IsError);
Assert.True(fooSymbol.IsError);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler.Tests/TestUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static TSymbol GetInternalSymbol<TSymbol>(ISymbol? symbol)
public static TMember AssertMember<TMember>(Symbol parent, string memberName)
where TMember : Symbol
{
var member = parent.Members.OfType<TMember>().Where(x => x.Name == memberName).FirstOrDefault();
var member = parent.AllMembers.OfType<TMember>().Where(x => x.Name == memberName).FirstOrDefault();
if (member is null)
{
Assert.Fail($"member '{memberName}' not found in '{parent.Name}'");
Expand Down
10 changes: 5 additions & 5 deletions src/Draco.Compiler/Api/Semantics/SemanticModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private ImmutableArray<Diagnostic> GetDiagnostics(SourceSpan? span = null)
case VariableDeclarationSyntax varDecl when varDecl.FieldModifier is null:
{
// We need to search for this global
var globalSymbol = binder.ContainingSymbol?.Members
var globalSymbol = binder.ContainingSymbol?.AllMembers
.OfType<SyntaxAutoPropertySymbol>()
.FirstOrDefault(s => s.Name == varDecl.Name.Text);
globalSymbol?.Bind(this);
Expand All @@ -99,7 +99,7 @@ private ImmutableArray<Diagnostic> GetDiagnostics(SourceSpan? span = null)
case VariableDeclarationSyntax varDecl when varDecl.FieldModifier is not null:
{
// We need to search for this global
var globalSymbol = binder.ContainingSymbol?.Members
var globalSymbol = binder.ContainingSymbol?.AllMembers
.OfType<SyntaxFieldSymbol>()
.FirstOrDefault(s => s.Name == varDecl.Name.Text);
globalSymbol?.Bind(this);
Expand Down Expand Up @@ -190,7 +190,7 @@ public ImmutableArray<ISymbol> GetAllAccessibleSymbols(SyntaxNode? node)
if (module.DeclaringSyntaxes.Contains(syntax)) return containingSymbol;

// Just search for the corresponding syntax
var symbol = module.Members
var symbol = module.AllMembers
.SingleOrDefault(sym => sym.DeclaringSyntax == syntax);
return symbol;
}
Expand Down Expand Up @@ -250,7 +250,7 @@ public ImmutableArray<ISymbol> GetAllAccessibleSymbols(SyntaxNode? node)
if (containingSymbol is ISourceSymbol sourceSymbol)
{
sourceSymbol.Bind(this);
foreach (var nested in containingSymbol.Members.OfType<ISourceSymbol>()) nested.Bind(this);
foreach (var nested in containingSymbol.AllMembers.OfType<ISourceSymbol>()) nested.Bind(this);
}

// Attempt to retrieve
Expand Down Expand Up @@ -352,7 +352,7 @@ public ImmutableArray<IFunctionSymbol> GetReferencedOverloads(ExpressionSyntax s
{
var receiverSymbol = this.GetReferencedSymbolInternal(member.Accessed);
// NOTE: This is how we check for static access
if (receiverSymbol?.IsDotnetType == true)
if (receiverSymbol?.IsTypeOnCilLevel == true)
{
result.AddRange(receiverSymbol.StaticMembers.Where(m => m.Name == member.Member.Text));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler/Api/Semantics/Symbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ internal abstract class SymbolBase(Symbol symbol) : ISymbol
public bool IsSpecialName => this.Symbol.IsSpecialName;
public Location? Definition => this.Symbol.DeclaringSyntax?.Location;
public string Documentation => this.Symbol.Documentation.ToMarkdown();
public IEnumerable<ISymbol> Members => this.Symbol.Members.Select(x => x.ToApiSymbol());
public IEnumerable<ISymbol> Members => this.Symbol.AllMembers.Select(x => x.ToApiSymbol());
public bool IsGenericDefinition => this.Symbol.IsGenericDefinition;
public bool IsGenericInstance => this.Symbol.IsGenericInstance;
public ISymbol? GenericDefinition => this.Symbol.GenericDefinition?.ToApiSymbol();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static IEnumerable<Symbol> GetMemberSymbols(SemanticModel semanticModel,

var referencedType = semanticModel.GetReferencedSymbolInternal(receiverSyntax);
// NOTE: This is how we check for static access
if (referencedType?.IsDotnetType == true) return referencedType.StaticMembers;
if (referencedType?.IsTypeOnCilLevel == true) return referencedType.StaticMembers;

// Otherwise this is an instance access
if (receiverSyntax is not ExpressionSyntax accessedExpr) return [];
Expand Down
6 changes: 3 additions & 3 deletions src/Draco.Compiler/Internal/Binding/Binder_Symbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public virtual ScriptBinding BindScript(ScriptModuleSymbol module, DiagnosticBag
if (decl is VariableDeclarationSyntax { FieldModifier: not null } fieldDecl)
{
// Retrieve the symbol
var symbol = module.Members
var symbol = module.AllMembers
.OfType<ScriptFieldSymbol>()
.First(g => g.DeclaringSyntax == fieldDecl);

Expand All @@ -126,7 +126,7 @@ public virtual ScriptBinding BindScript(ScriptModuleSymbol module, DiagnosticBag
if (decl is VariableDeclarationSyntax { FieldModifier: null } propDecl)
{
// Retrieve the symbol
var symbol = module.Members
var symbol = module.AllMembers
.OfType<ScriptAutoPropertySymbol>()
.First(g => g.DeclaringSyntax == propDecl);

Expand All @@ -138,7 +138,7 @@ public virtual ScriptBinding BindScript(ScriptModuleSymbol module, DiagnosticBag
if (decl is FunctionDeclarationSyntax funcDecl)
{
// Retrieve the symbol
var symbol = module.Members
var symbol = module.AllMembers
.OfType<ScriptFunctionSymbol>()
.First(f => f.DeclaringSyntax == funcDecl);

Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler/Internal/Binding/Binder_Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private Symbol BindMemberType(MemberTypeSyntax syntax, DiagnosticBag diagnostics
else
{
// Module or type member access
var members = left.Members
var members = left.AllMembers
.Where(m => m.Name == memberName)
.Where(BinderFacts.IsTypeSymbol)
.ToImmutableArray();
Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler/Internal/Binding/GlobalImportsBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private ImmutableArray<Symbol> BuildDeclaredSymbols()
{
throw new InvalidOperationException($"the path '{path}' is invalid for global imports");
}
result.AddRange(module.Members);
result.AddRange(module.AllMembers);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Draco.Compiler/Internal/Binding/ImportBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private ImportItem BindImport(ImportDeclarationSyntax syntax, DiagnosticBag diag
}
else
{
return new(syntax, parts.ToImmutable(), importedSymbol.Members);
return new(syntax, parts.ToImmutable(), importedSymbol.AllMembers);
}

Symbol BindImportPath(ImportPathSyntax syntax)
Expand Down Expand Up @@ -108,7 +108,7 @@ Symbol BindImportPath(ImportPathSyntax syntax)
return parent;
}
// Look up in parent
var membersWithName = parent.Members
var membersWithName = parent.AllMembers
.Where(m => m.Name == mem.Member.Text)
.OfType<ModuleSymbol>()
.ToList();
Expand Down
4 changes: 2 additions & 2 deletions src/Draco.Compiler/Internal/Binding/ModuleBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class ModuleBinder : Binder

public override Symbol? ContainingSymbol => this.symbol;

public override IEnumerable<Symbol> DeclaredSymbols => this.symbol.Members;
public override IEnumerable<Symbol> DeclaredSymbols => this.symbol.AllMembers;

private readonly ModuleSymbol symbol;

Expand All @@ -34,7 +34,7 @@ public ModuleBinder(Binder parent, ModuleSymbol symbol)

internal override void LookupLocal(LookupResult result, string name, ref LookupFlags flags, Predicate<Symbol> allowSymbol, SyntaxNode? currentReference)
{
foreach (var symbol in this.symbol.Members)
foreach (var symbol in this.symbol.AllMembers)
{
if (symbol.Name != name) continue;
if (!allowSymbol(symbol)) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler/Internal/Codegen/MetadataCodegen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Symbol GetContainingSymbol()
// Search for the function where the generic definitions are the same but the container is not the array
var functionInBase = type.BaseTypes
.Except([type], SymbolEqualityComparer.Default)
.SelectMany(b => b.Members)
.SelectMany(b => b.AllMembers)
.OfType<FunctionSymbol>()
.First(f => SymbolEqualityComparer.Default.Equals(f.GenericDefinition, func.GenericDefinition));
return functionInBase.ContainingSymbol!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ public override void VisitFunction(FunctionSymbol functionSymbol)

public override void VisitModule(ModuleSymbol moduleSymbol)
{
foreach (var subModuleSymbol in moduleSymbol.Members.OfType<ModuleSymbol>())
foreach (var subModuleSymbol in moduleSymbol.AllMembers.OfType<ModuleSymbol>())
{
var module = this.module.DefineModule(subModuleSymbol);
var moduleCodegen = new ModuleCodegen(this.Compilation, module, this.EmitSequencePoints);
subModuleSymbol.Accept(moduleCodegen);
}

foreach (var member in moduleSymbol.Members.Where(x => x is not ModuleSymbol))
foreach (var member in moduleSymbol.AllMembers.Where(x => x is not ModuleSymbol))
{
member.Accept(this);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Draco.Compiler/Internal/Solver/ConstraintSolver_Rules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private IEnumerable<Rule> ConstructRules(DiagnosticBag diagnostics) => [
}

// Not a type variable, we can look into members
var membersWithName = accessed.Members
var membersWithName = accessed.AllMembers
.Where(m => m.Name == member.MemberName)
.ToImmutableArray();
if (membersWithName.Length == 0)
Expand Down Expand Up @@ -153,7 +153,7 @@ private IEnumerable<Rule> ConstructRules(DiagnosticBag diagnostics) => [
}

// Not a type variable, we can look into members
var indexers = accessed.Members
var indexers = accessed.AllMembers
.OfType<PropertySymbol>()
.Where(p => p.IsIndexer)
.Select(p => indexer.IsGetter ? p.Getter : p.Setter)
Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler/Internal/Symbols/FunctionSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public delegate IOperand CodegenDelegate(

// NOTE: We override for covariant return type
public override FunctionSymbol? GenericDefinition => null;
public override IEnumerable<Symbol> Members => this.Parameters;
public override IEnumerable<Symbol> AllMembers => this.Parameters;
public override SymbolKind Kind => SymbolKind.Function;

public TypeSymbol Type => LazyInitializer.EnsureInitialized(ref this.type, this.BuildType);
Expand Down
4 changes: 2 additions & 2 deletions src/Draco.Compiler/Internal/Symbols/MergedModuleSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal sealed class MergedModuleSymbol(
string name,
ImmutableArray<ModuleSymbol> modules) : ModuleSymbol
{
public override IEnumerable<Symbol> Members =>
public override IEnumerable<Symbol> AllMembers =>
InterlockedUtils.InitializeDefault(ref this.members, this.BuildMembers);
private ImmutableArray<Symbol> members;

Expand All @@ -27,7 +27,7 @@ private ImmutableArray<Symbol> BuildMembers()
foreach (var singleModule in modules)
{
// singleModule is a piece of this module, we need to go through each element of that
foreach (var member in singleModule.Members)
foreach (var member in singleModule.AllMembers)
{
if (member is ModuleSymbol module)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal class MetadataAssemblySymbol(
public override ImmutableArray<AttributeInstance> Attributes => InterlockedUtils.InitializeDefault(ref this.attributes, this.BuildAttributes);
private ImmutableArray<AttributeInstance> attributes;

public override IEnumerable<Symbol> Members => this.RootNamespace.Members;
public override IEnumerable<Symbol> AllMembers => this.RootNamespace.AllMembers;

/// <summary>
/// The version of this assembly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal sealed class MetadataNamespaceSymbol(
{
public override Compilation DeclaringCompilation => this.Assembly.DeclaringCompilation;

public override IEnumerable<Symbol> Members =>
public override IEnumerable<Symbol> AllMembers =>
InterlockedUtils.InitializeDefault(ref this.members, this.BuildMembers);
private ImmutableArray<Symbol> members;

Expand Down Expand Up @@ -79,12 +79,12 @@ private ImmutableArray<Symbol> BuildMembers()
for (var i = 0; i < parts.Length - 1; ++i)
{
var part = parts[i];
current = current.Members
current = current.AllMembers
.Where(m => m.MetadataName == part && m is ModuleSymbol or TypeSymbol)
.SingleOrDefault();
if (current is null) return null;
}

return current.Members.SingleOrDefault(m => MetadataDocumentation.GetPrefixedDocumentationName(m) == prefixedDocumentationName);
return current.AllMembers.SingleOrDefault(m => MetadataDocumentation.GetPrefixedDocumentationName(m) == prefixedDocumentationName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal sealed class MetadataStaticClassSymbol(
public override ImmutableArray<AttributeInstance> Attributes => InterlockedUtils.InitializeDefault(ref this.attributes, this.BuildAttributes);
private ImmutableArray<AttributeInstance> attributes;

public override IEnumerable<Symbol> Members =>
public override IEnumerable<Symbol> AllMembers =>
InterlockedUtils.InitializeDefault(ref this.members, this.BuildMembers);
private ImmutableArray<Symbol> members;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public Symbol GetGenericTypeParameter(Symbol genericContext, int index)
{
var typeAncestor = genericContext.AncestorChain
// Both types and modules are a type in .NET world
.Where(s => s.IsDotnetType)
.Where(s => s.IsTypeOnCilLevel)
.First();

return typeAncestor.IsGenericDefinition
Expand Down Expand Up @@ -225,7 +225,7 @@ private Symbol BuildTypeFromDefinition(MetadataReader reader, TypeDefinitionHand
var nestedGenericArgc = definition.GetGenericParameters().Count;
return declaringSymbol
.DefinedMembers
.Where(s => s.IsDotnetType)
.Where(s => s.IsTypeOnCilLevel)
.Where(t => t.Name == nestedName && t.GenericParameters.Length == nestedGenericArgc)
.Single();
}
Expand Down Expand Up @@ -274,7 +274,7 @@ private Symbol BuildTypeFromReference(MetadataReader reader, TypeReferenceHandle

return assembly.RootNamespace
.Lookup(parts.ToImmutable())
.Where(s => s.IsDotnetType)
.Where(s => s.IsTypeOnCilLevel)
.Single();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Draco.Compiler/Internal/Symbols/ModuleSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Draco.Compiler.Internal.Symbols;
/// </summary>
internal abstract partial class ModuleSymbol : Symbol, IMemberSymbol
{
public override Visibility Visibility => this.Members.Any(x => x.Visibility == Visibility.Public)
public override Visibility Visibility => this.AllMembers.Any(x => x.Visibility == Visibility.Public)
? Visibility.Public
: Visibility.Internal;
public override SymbolKind Kind => SymbolKind.Module;
Expand All @@ -33,11 +33,11 @@ public IEnumerable<Symbol> Lookup(ImmutableArray<string> parts)
for (var i = 0; i < parts.Length - 1; ++i)
{
var part = parts[i];
current = current.Members
current = current.AllMembers
.Where(m => m.MetadataName == part && m is ModuleSymbol or TypeSymbol)
.Single();
}

return current.Members.Where(m => m.MetadataName == parts[^1]);
return current.AllMembers.Where(m => m.MetadataName == parts[^1]);
}
}
Loading

0 comments on commit 8c509c1

Please sign in to comment.