Project

General

Profile

/**
*
* 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 <base/TiresiasObject.hpp>
#include <ast/Ast.hpp> // pull in Ast
#include <ast/IAstVisitor.hpp>
#include <ast/IScope.hpp>
#include <ast/AstAnnotation.hpp>

namespace Ast {

enum class AstNodeTypeEnum : std::uint8_t {
type,
identifier,
expression,
statement
};

class AstElement:
public Base::TiresiasObject
{
protected:
const AstNodeTypeEnum m_astNodeType; // byte @ +1 byte
AstAnnotation* m_astAnnotation;

protected:
AstElement(AstNodeTypeEnum nodeType):
Base::TiresiasObject(),
m_astNodeType(nodeType),
m_astAnnotation(nullptr)
{}

public:
~AstElement(){
delete m_astAnnotation;
};


// AstElement* Ast::internalCreate(std::uint8_t typeId) {
// AstElement* result = ((create)static_astVTable[0][typeId])();
// m_allocatedAstObjects.push_back(result);
// return result;
// }

AstAnnotation* getAnnotation() {return m_astAnnotation;}
void setAnnotation(AstAnnotation* annotation) {m_astAnnotation = annotation;}

AstNodeTypeEnum nodeType() const {return m_astNodeType;};

virtual IScope* asScope(){return nullptr;}
virtual void accept(IAstVisitor& visitor) = 0;
};

}
(4-4/23)