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


#include "Statement.hpp"
#include <base/Exceptions.hpp>
#include <ast/statements/GuardedCommand.hpp>
#include <ast/statements/Call.hpp>
#include <ast/statements/Assignment.hpp>
#include <ast/statements/SeqBlock.hpp>
#include <ast/statements/NondetBlock.hpp>
#include <ast/statements/PrioBlock.hpp>
#include <ast/statements/Skip.hpp>
#include <ast/statements/Abort.hpp>
#include <ast/statements/Break.hpp>
//#include <Kill.hpp>

namespace Ast {

static void abstractError() {
throw new Base::NotImplementedException();
}

Base::FuncPtr Statement::s_stmntVmt [2][STATEMENTKIND_NR_ITEMS] =
{
{
/* GuardedCommand = 0 */ (Base::FuncPtr)&GuardedCommand::create,
/* Call = 1 */ (Base::FuncPtr)&Call::create,
/* Assignment = 2 */ (Base::FuncPtr)&Assignment::create,
/* SeqBlock = 3 */ (Base::FuncPtr)&SeqBlock::create,
/* NondetBlock = 4 */ (Base::FuncPtr)&NondetBlock::create,
/* PrioBlock = 5 */ (Base::FuncPtr)&PrioBlock::create,
/* Skip = 6 */ (Base::FuncPtr)&Skip::create,
/* Abort = 7 */ (Base::FuncPtr)&Abort::create,
/* Kill = 8 */ &abstractError,
/* QualConstraint = 9 */ &abstractError,
/* Break = 10 */ (Base::FuncPtr)&Break::create
},
{
/* GuardedCommand = 0 */ (Base::FuncPtr)&GuardedCommand::createCopy,
/* Call = 1 */ (Base::FuncPtr)&Call::createCopy,
/* Assignment = 2 */ (Base::FuncPtr)&Assignment::createCopy,
/* SeqBlock = 3 */ (Base::FuncPtr)&SeqBlock::createCopy,
/* NondetBlock = 4 */ (Base::FuncPtr)&NondetBlock::createCopy,
/* PrioBlock = 5 */ (Base::FuncPtr)&PrioBlock::createCopy,
/* Skip = 6 */ (Base::FuncPtr)&Skip::createCopy,
/* Abort = 7 */ (Base::FuncPtr)&Abort::createCopy,
/* Kill = 8 */ &abstractError,
/* QualConstraint = 9 */ &abstractError,
/* Break = 10 */ (Base::FuncPtr)&Break::createCopy
}
};


void Statement::accept(IAstVisitor& ) {throw new Base::NotImplementedException();};

Statement* Statement::createVirtual(StatementKind aType) {
return (std::uint8_t)aType < STATEMENTKIND_NR_ITEMS ? ((ConstrPtr)s_stmntVmt[0][(int)aType])() : nullptr;
}

Statement* Statement::createVirtual(const Statement& toCopy) {
std::uint8_t atype ((std::uint8_t)toCopy.kind());
return ((CopyConstrPtr)s_stmntVmt[1][atype])(toCopy);
}


}