root / trunk / compiler / cppAst / ast / identifiers / MainModule.hpp @ 5
1 |
/**
|
---|---|
2 |
*
|
3 |
* OOAS Compiler - C++ AST
|
4 |
*
|
5 |
* Copyright 2015, AIT Austrian Institute of Technology.
|
6 |
* All rights reserved.
|
7 |
*
|
8 |
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
|
9 |
*
|
10 |
* If you modify the file please update the list of contributors below to in-
|
11 |
* clude your name. Please also stick to the coding convention of using TABs
|
12 |
* to do the basic (block-level) indentation and spaces for anything after
|
13 |
* that. (Enable the display of special chars and it should be pretty obvious
|
14 |
* what this means.) Also, remove all trailing whitespace.
|
15 |
*
|
16 |
* Contributors:
|
17 |
* Willibald Krenn (AIT)
|
18 |
* Stephan Zimmerer (AIT)
|
19 |
* Christoph Czurda (AIT)
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
#pragma once
|
27 |
|
28 |
#include <ast/identifiers/Module.hpp> |
29 |
#include <ast/IAstVisitor.hpp> |
30 |
#include <ast/identifiers/IdentifierBlock.hpp> |
31 |
|
32 |
namespace Ast {
|
33 |
|
34 |
class MainModule final |
35 |
: public Module
|
36 |
{ |
37 |
protected:
|
38 |
IdentifierBlock* m_systemDescription; // this is what we get from the frontend
|
39 |
FunctionIdentifier* m_systemMainFunction; // Avail after AstFinaliser has run
|
40 |
|
41 |
MainModule(): |
42 |
Module(IdentifierKind::MainModule), |
43 |
m_systemDescription (nullptr),
|
44 |
m_systemMainFunction (nullptr)
|
45 |
{} |
46 |
MainModule(const MainModule &toCopy):
|
47 |
Module(toCopy), |
48 |
m_systemDescription (toCopy.m_systemDescription), |
49 |
m_systemMainFunction (toCopy.m_systemMainFunction) |
50 |
{} |
51 |
|
52 |
static MainModule* create() {return new MainModule();} |
53 |
static MainModule* createCopy(const MainModule& toCopy) {return new MainModule(toCopy);} |
54 |
public:
|
55 |
friend class Ast; |
56 |
friend class Identifier; |
57 |
|
58 |
void init(int line, int col, const char* text, IScope* scopeRef, |
59 |
Type* typeRef, const char* prefix, SymbolTable* symTabRef, IdentifierBlock* list) |
60 |
{ |
61 |
Module::init(line,col,text,scopeRef,typeRef,prefix,symTabRef); |
62 |
m_systemDescription = list; |
63 |
} |
64 |
|
65 |
|
66 |
IdentifierBlock* systemDescription() {return m_systemDescription;};
|
67 |
void setSystemDescription(IdentifierBlock* aDescr) {m_systemDescription = aDescr;};
|
68 |
void accept(IAstVisitor& visitor) override {visitor.visit(this);}; |
69 |
|
70 |
FunctionIdentifier* getMainFunction() {return m_systemMainFunction;}
|
71 |
void setMainFunction(FunctionIdentifier* mainFunction) {m_systemMainFunction = mainFunction;}
|
72 |
static std::string mainFunctionName() {return ".main";} |
73 |
}; |
74 |
} |