Project

General

Profile

7 krennw
/**
*
* 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)
*
*/
2 krennw



#pragma once

#include <ast/identifiers/Scope.hpp>
#include <ast/statements/Block.hpp>
#include <ast/identifiers/ParameterIdentifier.hpp>
#include <deque>
#include <ast/Containers.hpp>

namespace Ast {

class FunctionIdentifier
: public Scope
{
protected:
ParameterList m_parameter;
Statement* m_body;

FunctionIdentifier(IdentifierKind id):
Scope(id),
m_parameter(),
m_body (nullptr)
{};
FunctionIdentifier(const FunctionIdentifier& toCopy):
Scope(toCopy),
m_parameter (toCopy.m_parameter),
m_body (toCopy.m_body)
{}
public:

void init (std::int32_t line, std::int32_t col, const char* text,
IScope* scopeRef, Type* typeRef, const char* prefix,
ParameterList* parameterListRef, SymbolTable* symbolTableRef, Statement* bodyRef)
{
Scope::init(line,col,text,scopeRef,typeRef,prefix,symbolTableRef);
m_parameter = std::move(*parameterListRef);
m_body = bodyRef;
}

std::deque<ParameterIdentifier*>& parameter() {return m_parameter;}
const std::deque<ParameterIdentifier*>& parameter() const {return m_parameter;}
Statement* body() const {return m_body;};
size_t parameterCount() const {return m_parameter.size(); }

void setBody(Statement* body) {m_body = body;};
void addParameter(ParameterIdentifier* aParameter) {m_parameter.push_back(aParameter);};
std::string getScopeName() const override {return toString();}
};
}