Skip to content

Commit e9b76ed

Browse files
Add computable declaration fields
1 parent 3c97a1a commit e9b76ed

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Grammars/SimpleSharp.Compiler/ClassDeclaration.nitra

+2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ namespace JetBrains.Nitra.Samples.SimpleSharp
77
Baz : int -> Nitra.NSpan * Nitra.NSpan? * Nitra.NSpan+ -> Nitra.Ast?;
88
Foo : Nitra.Ast+;
99
Bar : Nitra.NSpan? * Nitra.Ast;
10+
Bar2 : Nitra.NSpan? * Nitra.Ast = Bar;
11+
Paz : int { 4 * 2 }
1012
}
1113
}

Nitra/Nitra.Compiler/Generation/Declarations/DeclarationEmitter.n

+10-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,16 @@ namespace Nitra.Compiler
4242

4343
foreach (fieldSymbol in this._declarationSymbol.Fields)
4444
{
45-
unless (fieldSymbol.HasBody)
45+
if (fieldSymbol.HasBody)
46+
{
47+
this._tb.DefineConditional(<[ decl:
48+
public $(fieldSymbol.Name : usesite) : $(makeType(fieldSymbol))
49+
{
50+
get { $(fieldSymbol.Body.Expr) }
51+
}
52+
]>);
53+
}
54+
else
4655
{
4756
this._tb.DefineConditional(<[ decl:
4857
public $(fieldSymbol.Name : usesite) : $(makeType(fieldSymbol));

0 commit comments

Comments
 (0)