polserver/pol-core/bscript/compiler/ast/Program.cpp
Eric Swanson e344a8a483
Consolidate local variable scope information (#301)
Adds:
- model/LocalVariableScopeInfo.h

Stores, for local variable blocks:
- the names of the local variables in the block
- the "base index" of those local variables within the current scope

The code generator uses these to clean up local variables as they go out of scope.

We also need this when writing debug information.
2020-09-12 09:31:52 -07:00

43 lines
942 B
C++

#include "Program.h"
#include <format/format.h>
#include "compiler/ast/FunctionBody.h"
#include "compiler/ast/NodeVisitor.h"
#include "compiler/ast/ProgramParameterList.h"
namespace Pol::Bscript::Compiler
{
Program::Program( const SourceLocation& source_location,
std::unique_ptr<ProgramParameterList> parameter_list,
std::unique_ptr<FunctionBody> body )
: Node( source_location )
{
children.reserve( 2 );
children.push_back( std::move( parameter_list ) );
children.push_back( std::move( body ) );
}
Program::~Program() = default;
void Program::accept( NodeVisitor& visitor )
{
visitor.visit_program( *this );
}
void Program::describe_to( fmt::Writer& w ) const
{
w << "program";
}
ProgramParameterList& Program::parameter_list()
{
return child<ProgramParameterList>( 0 );
}
FunctionBody& Program::body()
{
return child<FunctionBody>( 1 );
}
} // namespace Pol::Bscript::Compiler