@@ -26,7 +26,7 @@ public AstBuilder( DynamicRuntimeState globalState )
2626
2727 public override IAstNode VisitErrorNode ( IErrorNode node )
2828 {
29- return new ErrorNode < DiagnosticCode > ( node . GetSourceRange ( ) , DiagnosticCode . SyntaxError , $ "Syntax Error: { node } " ) ;
29+ return new ErrorNode ( node . GetSourceRange ( ) , ( int ) DiagnosticCode . SyntaxError , $ "Syntax Error: { node } " ) ;
3030 }
3131
3232 public override IAstNode VisitParenExpression ( ParenExpressionContext context )
@@ -44,15 +44,15 @@ public override IAstNode VisitVariableExpression( VariableExpressionContext cont
4444 string varName = context . Name ;
4545 return NamedValues . TryGetValue ( varName , out IVariableDeclaration ? declaration )
4646 ? new VariableReferenceExpression ( context . GetSourceRange ( ) , declaration )
47- : new ErrorNode < DiagnosticCode > ( context . GetSourceRange ( ) , DiagnosticCode . UnknownVariable , $ "Unknown variable name: { varName } " ) ;
47+ : new ErrorNode ( context . GetSourceRange ( ) , ( int ) DiagnosticCode . UnknownVariable , $ "Unknown variable name: { varName } " ) ;
4848 }
4949
5050 public override IAstNode VisitFunctionCallExpression ( FunctionCallExpressionContext context )
5151 {
5252 Prototype ? function = FindCallTarget ( context . CaleeName ) ;
5353 if ( function is null )
5454 {
55- return new ErrorNode < DiagnosticCode > ( context . GetSourceRange ( ) , DiagnosticCode . InvokeUnknownFunction , $ "Call to unknown function '{ context . CaleeName } '" ) ;
55+ return new ErrorNode ( context . GetSourceRange ( ) , ( int ) DiagnosticCode . InvokeUnknownFunction , $ "Call to unknown function '{ context . CaleeName } '" ) ;
5656 }
5757
5858 var argNodes = ( from expCtx in context . expression ( )
@@ -98,7 +98,7 @@ public override IAstNode VisitExpression( ExpressionContext context )
9898 public override IAstNode VisitExternalDeclaration ( ExternalDeclarationContext context )
9999 {
100100 var retVal = ( Prototype ) context . Signature . Accept ( this ) ;
101- var errors = retVal . CollectErrors < DiagnosticCode > ( ) ;
101+ var errors = retVal . CollectErrors ( ) ;
102102 if ( errors . Length == 0 )
103103 {
104104 RuntimeState . FunctionDeclarations . AddOrReplaceItem ( retVal ) ;
@@ -118,7 +118,7 @@ public override IAstNode VisitFunctionDefinition( FunctionDefinitionContext cont
118118 }
119119
120120 var body = context . BodyExpression . Accept ( this ) ;
121- var errors = body . CollectErrors < DiagnosticCode > ( ) ;
121+ var errors = body . CollectErrors ( ) ;
122122
123123 // test for a non-expression (ErrorNode)
124124 if ( body is not IExpression exp )
@@ -152,7 +152,7 @@ public override IAstNode VisitTopLevelExpression( TopLevelExpressionContext cont
152152 BeginFunctionDefinition ( ) ;
153153 var sig = new Prototype ( context . GetSourceRange ( ) , RuntimeState . GenerateAnonymousName ( ) , true ) ;
154154 var bodyNode = context . expression ( ) . Accept ( this ) ;
155- var errors = bodyNode . CollectErrors < DiagnosticCode > ( ) ;
155+ var errors = bodyNode . CollectErrors ( ) ;
156156
157157 // only add valid definitions to the runtime state.
158158 if ( errors . Length > 0 || bodyNode is not IExpression bodyExp )
@@ -172,14 +172,14 @@ public override IAstNode VisitUnaryOpExpression( UnaryOpExpressionContext contex
172172 var opKind = RuntimeState . GetUnaryOperatorInfo ( context . Op ) . Kind ;
173173 if ( opKind == OperatorKind . None )
174174 {
175- return new ErrorNode < DiagnosticCode > ( context . GetSourceRange ( ) , DiagnosticCode . InvalidUnaryOp , $ "invalid unary operator { context . Op } " ) ;
175+ return new ErrorNode ( context . GetSourceRange ( ) , ( int ) DiagnosticCode . InvalidUnaryOp , $ "invalid unary operator { context . Op } " ) ;
176176 }
177177
178178 string calleeName = CreateUnaryFunctionName ( context . OpToken ) ;
179179 var function = FindCallTarget ( calleeName ) ;
180180 if ( function == null )
181181 {
182- return new ErrorNode < DiagnosticCode > ( context . GetSourceRange ( ) , DiagnosticCode . InvalidUnaryOpRef , $ "reference to unknown unary operator function { calleeName } " ) ;
182+ return new ErrorNode ( context . GetSourceRange ( ) , ( int ) DiagnosticCode . InvalidUnaryOpRef , $ "reference to unknown unary operator function { calleeName } " ) ;
183183 }
184184
185185 var arg = context . Rhs . Accept ( this ) ;
@@ -355,13 +355,13 @@ private IAstNode CreateBinaryOperatorNode( IExpression lhs, BinaryopContext op,
355355 var opKind = RuntimeState . GetBinOperatorInfo ( op . OpToken . Type ) . Kind ;
356356 if ( opKind != OperatorKind . InfixLeftAssociative && opKind != OperatorKind . InfixRightAssociative )
357357 {
358- return new ErrorNode < DiagnosticCode > ( op . GetSourceRange ( ) , DiagnosticCode . InvalidBinaryOp , $ "Invalid binary operator '{ op . OpToken . Text } '" ) ;
358+ return new ErrorNode ( op . GetSourceRange ( ) , ( int ) DiagnosticCode . InvalidBinaryOp , $ "Invalid binary operator '{ op . OpToken . Text } '" ) ;
359359 }
360360
361361 string calleeName = CreateBinaryFunctionName ( op . OpToken ) ;
362362 Prototype ? callTarget = FindCallTarget ( calleeName ) ;
363363 return callTarget is null
364- ? new ErrorNode < DiagnosticCode > ( op . GetSourceRange ( ) , DiagnosticCode . UnaryOpNotFound , $ "Unary operator function '{ calleeName } ' not found" )
364+ ? new ErrorNode ( op . GetSourceRange ( ) , ( int ) DiagnosticCode . UnaryOpNotFound , $ "Unary operator function '{ calleeName } ' not found" )
365365 : new FunctionCallExpression ( op . GetSourceRange ( ) , callTarget , lhs , rhs ) ;
366366 }
367367 #endregion
@@ -397,11 +397,11 @@ private IAstNode BuildPrototype( PrototypeContext context, string name )
397397 {
398398 if ( existingPrototype . Parameters . Count != retVal . Parameters . Count )
399399 {
400- return new ErrorNode < DiagnosticCode > ( context . GetSourceRange ( ) , DiagnosticCode . IncompatibleRedclaration , "Declaration incompatible with previous declaration" ) ;
400+ return new ErrorNode ( context . GetSourceRange ( ) , ( int ) DiagnosticCode . IncompatibleRedclaration , "Declaration incompatible with previous declaration" ) ;
401401 }
402402 }
403403
404- var errors = retVal . CollectErrors < DiagnosticCode > ( ) ;
404+ var errors = retVal . CollectErrors ( ) ;
405405 if ( errors . Length == 0 )
406406 {
407407 RuntimeState . FunctionDeclarations . AddOrReplaceItem ( retVal ) ;
0 commit comments