mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
Add support for const declarations (#264)
Adds: - analyzer/Constants: holds constant name -> value for lookup - ast/ConstDeclaration: AST node for a const declaration - optimizer/ConstValidator: validates that an optimized expression is valid to use as a constant. the Optimizer converts Identifiers that refer to a constant to the optimized constant value.
This commit is contained in:
parent
6d163918c5
commit
6ce9c38de3
21 changed files with 354 additions and 13 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "ModuleProcessor.h"
|
||||
|
||||
#include "compiler/Profile.h"
|
||||
#include "compiler/ast/ConstDeclaration.h"
|
||||
#include "compiler/ast/ModuleFunctionDeclaration.h"
|
||||
#include "compiler/astbuilder/BuilderWorkspace.h"
|
||||
#include "compiler/file/SourceFile.h"
|
||||
|
|
@ -31,6 +32,11 @@ antlrcpp::Any ModuleProcessor::visitModuleDeclarationStatement(
|
|||
|
||||
workspace.compiler_workspace.module_function_declarations.push_back( std::move( ast ) );
|
||||
}
|
||||
else if ( auto constStatement = ctx->constStatement() )
|
||||
{
|
||||
workspace.compiler_workspace.const_declarations.push_back(
|
||||
tree_builder.const_declaration( constStatement ) );
|
||||
}
|
||||
return antlrcpp::Any();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue