|
/**
|
|
*
|
|
* 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)
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
* StatementVisitor.cpp
|
|
*
|
|
* Created on: Feb 4, 2014
|
|
* Author: willibald
|
|
*/
|
|
|
|
#include "StatementVisitor.hpp"
|
|
#include <ast/statements/GuardedCommand.hpp>
|
|
#include <ast/statements/SeqBlock.hpp>
|
|
#include <ast/statements/NondetBlock.hpp>
|
|
#include <ast/statements/PrioBlock.hpp>
|
|
|
|
|
|
namespace Ast {
|
|
|
|
|
|
StatementVisitor::StatementVisitor(CallContext* context):
|
|
m_context(context)
|
|
{}
|
|
|
|
StatementVisitor::~StatementVisitor()
|
|
{}
|
|
|
|
|
|
void StatementVisitor::visitSub(AstElement* subElement, AstElement* parent) {
|
|
if (subElement == nullptr)
|
|
return;
|
|
visitAstElement(subElement, parent);
|
|
}
|
|
|
|
void StatementVisitor::visitAstElement(AstElement* element, AstElement* ){
|
|
switch (element->nodeType()) {
|
|
case AstNodeTypeEnum::expression:
|
|
case AstNodeTypeEnum::identifier:
|
|
case AstNodeTypeEnum::type:
|
|
error();
|
|
break;
|
|
case AstNodeTypeEnum::statement:
|
|
static_cast<Statement*>(element)->accept(*this);
|
|
break;
|
|
default:
|
|
m_context->logError("Internal error. Unknown AST type.");
|
|
abort();
|
|
}
|
|
}
|
|
|
|
void StatementVisitor::error() {
|
|
m_context -> logError("Internal error. This visitor only supports statements.");
|
|
abort();
|
|
}
|
|
|
|
//Identifiers
|
|
void StatementVisitor::visit(TypeIdentifier* ) { error(); };
|
|
void StatementVisitor::visit(EnumIdentifier* ) { error(); };
|
|
//void StatementVisitor::visit(ValuedEnumIdentifier* enumIdentifier) { error(); };
|
|
void StatementVisitor::visit(AttributeIdentifier* ) { error(); };
|
|
void StatementVisitor::visit(LocalVariableIdentifier* ) { error(); };
|
|
void StatementVisitor::visit(ParameterIdentifier* ) { error(); };
|
|
void StatementVisitor::visit(ExpressionVariableIdentifier* ) { error(); };
|
|
void StatementVisitor::visit(MethodIdentifier* ) { error(); };
|
|
void StatementVisitor::visit(NamedActionIdentifier* ) { error(); };
|
|
void StatementVisitor::visit(Module* ) { error(); };
|
|
void StatementVisitor::visit(ConstantIdentifier* ) { error(); };
|
|
void StatementVisitor::visit(UnspecIdentifierBlock* ) { error(); };
|
|
void StatementVisitor::visit(SeqIdentifierBlock* ) { error(); };
|
|
void StatementVisitor::visit(NondetIdentifierBlock* ) { error(); };
|
|
void StatementVisitor::visit(PrioIdentifierBlock* ) { error(); };
|
|
void StatementVisitor::visit(MainModule* ) { error(); };
|
|
|
|
//Types
|
|
void StatementVisitor::visit(IntType* ) { error(); };
|
|
void StatementVisitor::visit(BoolType* ) { error(); };
|
|
void StatementVisitor::visit(EnumType* ) { error(); };
|
|
void StatementVisitor::visit(ListType* ) { error(); };
|
|
void StatementVisitor::visit(TupleType* ) { error(); };
|
|
void StatementVisitor::visit(NullType* ) { error(); };
|
|
void StatementVisitor::visit(PointerType* ) { error(); };
|
|
void StatementVisitor::visit(FunctionType* ) { error(); };
|
|
void StatementVisitor::visit(ActionSystemType* ) { error(); };
|
|
|
|
// Statements
|
|
void StatementVisitor::visit(GuardedCommand* guardedCommand) {
|
|
visitSub(guardedCommand->body(), guardedCommand);
|
|
};
|
|
|
|
void StatementVisitor::visit(Call* ) { };
|
|
void StatementVisitor::visit(Assignment* ) { };
|
|
void StatementVisitor::visit(SeqBlock* seqBlock) {
|
|
for (auto& s: seqBlock->statements())
|
|
visitSub(s, seqBlock);
|
|
};
|
|
void StatementVisitor::visit(NondetBlock* nondetBlock) {
|
|
for (auto& s: nondetBlock->statements())
|
|
visitSub(s, nondetBlock);
|
|
};
|
|
void StatementVisitor::visit(PrioBlock* prioBlock) {
|
|
for (auto& s: prioBlock->statements())
|
|
visitSub(s, prioBlock);
|
|
};
|
|
void StatementVisitor::visit(Skip* ) { };
|
|
void StatementVisitor::visit(Break* ) { };
|
|
void StatementVisitor::visit(Abort* ) { };
|
|
|
|
// Expressions
|
|
void StatementVisitor::visit(TernaryOperator* ) { error(); };
|
|
void StatementVisitor::visit(BinaryOperator* ) { error(); };
|
|
void StatementVisitor::visit(UnaryOperator* ) { error(); };
|
|
void StatementVisitor::visit(ExistsQuantifier* ) { error(); };
|
|
void StatementVisitor::visit(ForallQuantifier* ) { error(); };
|
|
void StatementVisitor::visit(ListConstructor* ) { error(); };
|
|
void StatementVisitor::visit(SetConstructor* ) { error(); };
|
|
void StatementVisitor::visit(TupleConstructor* ) { error(); };
|
|
void StatementVisitor::visit(ObjectConstructor* ) { error(); };
|
|
void StatementVisitor::visit(BoolValueExpression* ) { error(); };
|
|
void StatementVisitor::visit(IntValueExpression* ) { error(); };
|
|
void StatementVisitor::visit(RefValueExpression* ) { error(); };
|
|
void StatementVisitor::visit(IdentifierExpression* ) { error(); };
|
|
void StatementVisitor::visit(TypeExpression* ) { error(); };
|
|
void StatementVisitor::visit(TupleMapAccessExpression* ) { error(); };
|
|
void StatementVisitor::visit(CallExpression* ) { error(); };
|
|
void StatementVisitor::visit(AccessExpression* ) { error(); };
|
|
|
|
} /* namespace Ast */
|