From d0f73604d396fab4b533045e2184079986d7549c Mon Sep 17 00:00:00 2001 From: LPeter1997 Date: Sat, 26 Oct 2024 19:28:01 +0200 Subject: [PATCH] Added declaration --- .../Internal/Symbols/Source/SourceAutoPropertySymbol.cs | 6 ++++++ .../Internal/Symbols/Source/SourceModuleSymbol.cs | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Draco.Compiler/Internal/Symbols/Source/SourceAutoPropertySymbol.cs b/src/Draco.Compiler/Internal/Symbols/Source/SourceAutoPropertySymbol.cs index 605cc8b3a..2ef575eb5 100644 --- a/src/Draco.Compiler/Internal/Symbols/Source/SourceAutoPropertySymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Source/SourceAutoPropertySymbol.cs @@ -2,6 +2,7 @@ using Draco.Compiler.Api.Syntax; using Draco.Compiler.Internal.Binding; using Draco.Compiler.Internal.BoundTree; +using Draco.Compiler.Internal.Declarations; using Draco.Compiler.Internal.FlowAnalysis; using Draco.Compiler.Internal.Symbols.Syntax; using Draco.Compiler.Internal.Symbols.Synthetized.AutoProperty; @@ -43,6 +44,11 @@ internal sealed class SourceAutoPropertySymbol( private readonly object buildLock = new(); + public SourceAutoPropertySymbol(Symbol containingSymbol, GlobalDeclaration declaration) + : this(containingSymbol, declaration.Syntax) + { + } + public override void Bind(IBinderProvider binderProvider) { this.BindTypeAndValueIfNeeded(binderProvider); diff --git a/src/Draco.Compiler/Internal/Symbols/Source/SourceModuleSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Source/SourceModuleSymbol.cs index 599e604f4..0490e6d4f 100644 --- a/src/Draco.Compiler/Internal/Symbols/Source/SourceModuleSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Source/SourceModuleSymbol.cs @@ -105,7 +105,9 @@ private ImmutableArray BindMembers(IBinderProvider binderProvider) }; private SourceFunctionSymbol BuildFunction(FunctionDeclaration declaration) => new(this, declaration); - private SourceFieldSymbol BuildGlobal(GlobalDeclaration declaration) => new(this, declaration); + private Symbol BuildGlobal(GlobalDeclaration declaration) => declaration.Syntax.FieldModifier is null + ? new SourceAutoPropertySymbol(this, declaration) + : new SourceFieldSymbol(this, declaration); private SourceModuleSymbol BuildModule(MergedModuleDeclaration declaration) => new(this.DeclaringCompilation, this, declaration); private SymbolDocumentation BuildDocumentation() =>