root / trunk / compiler / cppAst / ast / statements / Statement.cpp @ 2
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 |
#include "Statement.hpp" |
26 |
#include <base/Exceptions.hpp> |
27 |
#include <ast/statements/GuardedCommand.hpp> |
28 |
#include <ast/statements/Call.hpp> |
29 |
#include <ast/statements/Assignment.hpp> |
30 |
#include <ast/statements/SeqBlock.hpp> |
31 |
#include <ast/statements/NondetBlock.hpp> |
32 |
#include <ast/statements/PrioBlock.hpp> |
33 |
#include <ast/statements/Skip.hpp> |
34 |
#include <ast/statements/Abort.hpp> |
35 |
#include <ast/statements/Break.hpp> |
36 |
//#include <Kill.hpp>
|
37 |
|
38 |
namespace Ast {
|
39 |
|
40 |
static void abstractError() { |
41 |
throw new Base::NotImplementedException(); |
42 |
} |
43 |
|
44 |
Base::FuncPtr Statement::s_stmntVmt [2][STATEMENTKIND_NR_ITEMS] =
|
45 |
{ |
46 |
{ |
47 |
/* GuardedCommand = 0 */ (Base::FuncPtr)&GuardedCommand::create,
|
48 |
/* Call = 1 */ (Base::FuncPtr)&Call::create,
|
49 |
/* Assignment = 2 */ (Base::FuncPtr)&Assignment::create,
|
50 |
/* SeqBlock = 3 */ (Base::FuncPtr)&SeqBlock::create,
|
51 |
/* NondetBlock = 4 */ (Base::FuncPtr)&NondetBlock::create,
|
52 |
/* PrioBlock = 5 */ (Base::FuncPtr)&PrioBlock::create,
|
53 |
/* Skip = 6 */ (Base::FuncPtr)&Skip::create,
|
54 |
/* Abort = 7 */ (Base::FuncPtr)&Abort::create,
|
55 |
/* Kill = 8 */ &abstractError,
|
56 |
/* QualConstraint = 9 */ &abstractError,
|
57 |
/* Break = 10 */ (Base::FuncPtr)&Break::create
|
58 |
}, |
59 |
{ |
60 |
/* GuardedCommand = 0 */ (Base::FuncPtr)&GuardedCommand::createCopy,
|
61 |
/* Call = 1 */ (Base::FuncPtr)&Call::createCopy,
|
62 |
/* Assignment = 2 */ (Base::FuncPtr)&Assignment::createCopy,
|
63 |
/* SeqBlock = 3 */ (Base::FuncPtr)&SeqBlock::createCopy,
|
64 |
/* NondetBlock = 4 */ (Base::FuncPtr)&NondetBlock::createCopy,
|
65 |
/* PrioBlock = 5 */ (Base::FuncPtr)&PrioBlock::createCopy,
|
66 |
/* Skip = 6 */ (Base::FuncPtr)&Skip::createCopy,
|
67 |
/* Abort = 7 */ (Base::FuncPtr)&Abort::createCopy,
|
68 |
/* Kill = 8 */ &abstractError,
|
69 |
/* QualConstraint = 9 */ &abstractError,
|
70 |
/* Break = 10 */ (Base::FuncPtr)&Break::createCopy
|
71 |
} |
72 |
}; |
73 |
|
74 |
|
75 |
void Statement::accept(IAstVisitor& ) {throw new Base::NotImplementedException();}; |
76 |
|
77 |
Statement* Statement::createVirtual(StatementKind aType) { |
78 |
return (std::uint8_t)aType < STATEMENTKIND_NR_ITEMS ? ((ConstrPtr)s_stmntVmt[0][(int)aType])() : nullptr; |
79 |
} |
80 |
|
81 |
Statement* Statement::createVirtual(const Statement& toCopy) {
|
82 |
std::uint8_t atype ((std::uint8_t)toCopy.kind()); |
83 |
return ((CopyConstrPtr)s_stmntVmt[1][atype])(toCopy); |
84 |
} |
85 |
|
86 |
|
87 |
} |