|
/**
|
|
*
|
|
* OOAS Compiler - C++ AST
|
|
*
|
|
* Copyright 2015, AIT Austrian Institute of Technology.
|
|
* All rights reserved.
|
|
*
|
|
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
|
|
*
|
|
* If you modify the file please update the list of contributors below to in-
|
|
* clude your name. Please also stick to the coding convention of using TABs
|
|
* to do the basic (block-level) indentation and spaces for anything after
|
|
* that. (Enable the display of special chars and it should be pretty obvious
|
|
* what this means.) Also, remove all trailing whitespace.
|
|
*
|
|
* Contributors:
|
|
* Willibald Krenn (AIT)
|
|
* Stephan Zimmerer (AIT)
|
|
* Christoph Czurda (AIT)
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <ast/identifiers/Module.hpp>
|
|
#include <ast/IAstVisitor.hpp>
|
|
#include <ast/identifiers/IdentifierBlock.hpp>
|
|
|
|
namespace Ast {
|
|
|
|
class MainModule final
|
|
: public Module
|
|
{
|
|
protected:
|
|
IdentifierBlock* m_systemDescription; // this is what we get from the frontend
|
|
FunctionIdentifier* m_systemMainFunction; // Avail after AstFinaliser has run
|
|
|
|
MainModule():
|
|
Module(IdentifierKind::MainModule),
|
|
m_systemDescription (nullptr),
|
|
m_systemMainFunction (nullptr)
|
|
{}
|
|
MainModule(const MainModule &toCopy):
|
|
Module(toCopy),
|
|
m_systemDescription (toCopy.m_systemDescription),
|
|
m_systemMainFunction (toCopy.m_systemMainFunction)
|
|
{}
|
|
|
|
static MainModule* create() {return new MainModule();}
|
|
static MainModule* createCopy(const MainModule& toCopy) {return new MainModule(toCopy);}
|
|
public:
|
|
friend class Ast;
|
|
friend class Identifier;
|
|
|
|
void init(int line, int col, const char* text, IScope* scopeRef,
|
|
Type* typeRef, const char* prefix, SymbolTable* symTabRef, IdentifierBlock* list)
|
|
{
|
|
Module::init(line,col,text,scopeRef,typeRef,prefix,symTabRef);
|
|
m_systemDescription = list;
|
|
}
|
|
|
|
|
|
IdentifierBlock* systemDescription() {return m_systemDescription;};
|
|
void setSystemDescription(IdentifierBlock* aDescr) {m_systemDescription = aDescr;};
|
|
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
|
|
|
|
FunctionIdentifier* getMainFunction() {return m_systemMainFunction;}
|
|
void setMainFunction(FunctionIdentifier* mainFunction) {m_systemMainFunction = mainFunction;}
|
|
static std::string mainFunctionName() {return ".main";}
|
|
};
|
|
}
|