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



#include "Expression.hpp"
#include <ast/expressions/TernaryOperator.hpp>
#include <ast/expressions/BinaryOperator.hpp>
#include <ast/expressions/UnaryOperator.hpp>
#include <ast/expressions/ForallQuantifier.hpp>
#include <ast/expressions/ExistsQuantifier.hpp>
#include <ast/expressions/ListConstructor.hpp>
#include <ast/expressions/TupleConstructor.hpp>
#include <ast/expressions/ObjectConstructor.hpp>
#include <ast/expressions/IdentifierExpression.hpp>
#include <ast/expressions/TypeExpression.hpp>
#include <ast/expressions/TupleMapAccessExpression.hpp>
#include <ast/expressions/CallExpression.hpp>
#include <ast/expressions/AccessExpression.hpp>
#include <ast/expressions/ValueExpression.hpp>
#include <ast/expressions/SetConstructor.hpp>
#include <ast/expressions/TupleMapAccessExpression.hpp>
#include <ast/expressions/CallExpression.hpp>
#include <ast/expressions/AccessExpression.hpp>

namespace Ast {


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



Base::FuncPtr Expression::s_exprVmt [2][EXPRESSIONKIND_NR_ITEMS] =
{
{
/* conditional = 0, */ (Base::FuncPtr) &TernaryOperator::create,
/* domresby = 1, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* domresto = 2, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* rngresby = 3, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* rngresto = 4, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* munion = 5, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* conc = 6, */ (Base::FuncPtr) &BinaryOperator::create,
/* diff = 7, */ (Base::FuncPtr) &BinaryOperator::create,
/* inter = 8, */ (Base::FuncPtr) &BinaryOperator::create,
/* elemin = 9, */ (Base::FuncPtr) &BinaryOperator::create,
/* notelemin = 10, */ (Base::FuncPtr) &BinaryOperator::create,
/* subset = 11, */ (Base::FuncPtr) &BinaryOperator::create,
/* _union = 12, */ (Base::FuncPtr) &BinaryOperator::create,
/* div = 13, */ (Base::FuncPtr) &BinaryOperator::create,
/* greater = 14, */ (Base::FuncPtr) &BinaryOperator::create,
/* greaterequal = 15, */ (Base::FuncPtr) &BinaryOperator::create,
/* idiv = 16, */ (Base::FuncPtr) &BinaryOperator::create,
/* less = 17, */ (Base::FuncPtr) &BinaryOperator::create,
/* lessequal = 18, */ (Base::FuncPtr) &BinaryOperator::create,
/* minus = 19, */ (Base::FuncPtr) &BinaryOperator::create,
/* mod = 20, */ (Base::FuncPtr) &BinaryOperator::create,
/* pow = 21, */ (Base::FuncPtr) &BinaryOperator::create,
/* prod = 22, */ (Base::FuncPtr) &BinaryOperator::create,
/* sum = 23, */ (Base::FuncPtr) &BinaryOperator::create,
/* _and = 24, */ (Base::FuncPtr) &BinaryOperator::create,
/* biimplies = 25, */ (Base::FuncPtr) &BinaryOperator::create,
/* implies = 26, */ (Base::FuncPtr) &BinaryOperator::create,
/* _or = 27, */ (Base::FuncPtr) &BinaryOperator::create,
/* equal = 28, */ (Base::FuncPtr) &BinaryOperator::create,
/* notequal = 29, */ (Base::FuncPtr) &BinaryOperator::create,
/* seqmod_mapoverride = 30, */ (Base::FuncPtr) &abstractError,
/* dom = 31, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* range = 32, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* merge = 33, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* card = 34, */ (Base::FuncPtr) &UnaryOperator::create,
/* dconc = 35, */ (Base::FuncPtr) &UnaryOperator::create,
/* dinter = 36, */ (Base::FuncPtr) &UnaryOperator::create,
/* dunion = 37, */ (Base::FuncPtr) &UnaryOperator::create,
/* elems = 38, */ (Base::FuncPtr) &UnaryOperator::create,
/* head = 39, */ (Base::FuncPtr) &UnaryOperator::create,
/* inds = 40, */ (Base::FuncPtr) &UnaryOperator::create,
/* len = 41, */ (Base::FuncPtr) &UnaryOperator::create,
/* tail = 42, */ (Base::FuncPtr) &UnaryOperator::create,
/* unminus = 43, */ (Base::FuncPtr) &UnaryOperator::create,
/* unplus = 44, */ (Base::FuncPtr) &UnaryOperator::create,
/* _not = 45, */ (Base::FuncPtr) &UnaryOperator::create,
/* abs = 46, */ (Base::FuncPtr) &UnaryOperator::create,
/* forall = 47, */ (Base::FuncPtr) &ForallQuantifier::create,
/* exists = 48, */ (Base::FuncPtr) &ExistsQuantifier::create,
/* ListConstr = 49, */ (Base::FuncPtr) &ListConstructor::create,
/* SetConstr = 50, */ (Base::FuncPtr) &SetConstructor::create,
/* MapConstr = 51, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* TupleConstr = 52, */ (Base::FuncPtr) &TupleConstructor::create,
/* ObjectConstr = 53, */ (Base::FuncPtr) &ObjectConstructor::create,
/* QValConstr = 54, */ (Base::FuncPtr) &abstractError,
/* Identifier = 55, */ (Base::FuncPtr) &IdentifierExpression::create,
/* UnresolvedIdentifier = 56, */ (Base::FuncPtr) &abstractError,
/* Type = 57, */ (Base::FuncPtr) &TypeExpression::create,
/* TupleMapAccess = 58, */ (Base::FuncPtr) &TupleMapAccessExpression::create,
/* Call = 59, */ (Base::FuncPtr) &CallExpression::create,
/* Access = 60, */ (Base::FuncPtr) &AccessExpression::create,
/* Primed = 61, */ (Base::FuncPtr) &abstractError,
/* Cast = 62, */ (Base::FuncPtr) &UnaryOperator::create,
/* foldLR = 63, */ (Base::FuncPtr) &TernaryOperator::create,
/* foldRL = 64, */ (Base::FuncPtr) &abstractError,
/* Value_Integer = 65, */ (Base::FuncPtr) &IntValueExpression::create,
/* Value_Bool = 66, */ (Base::FuncPtr) &BoolValueExpression::create,
/* Value_Reference = 67, */ (Base::FuncPtr) &RefValueExpression::create
},
{
/* conditional = 0, */ (Base::FuncPtr) &TernaryOperator::createCopy,
/* domresby = 1, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* domresto = 2, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* rngresby = 3, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* rngresto = 4, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* munion = 5, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* conc = 6, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* diff = 7, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* inter = 8, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* elemin = 9, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* notelemin = 10, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* subset = 11, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* _union = 12, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* div = 13, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* greater = 14, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* greaterequal = 15, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* idiv = 16, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* less = 17, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* lessequal = 18, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* minus = 19, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* mod = 20, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* pow = 21, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* prod = 22, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* sum = 23, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* _and = 24, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* biimplies = 25, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* implies = 26, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* _or = 27, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* equal = 28, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* notequal = 29, */ (Base::FuncPtr) &BinaryOperator::createCopy,
/* seqmod_mapoverride = 30, */ (Base::FuncPtr) &abstractError,
/* dom = 31, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* range = 32, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* merge = 33, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* card = 34, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* dconc = 35, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* dinter = 36, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* dunion = 37, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* elems = 38, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* head = 39, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* inds = 40, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* len = 41, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* tail = 42, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* unminus = 43, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* unplus = 44, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* _not = 45, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* abs = 46, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* forall = 47, */ (Base::FuncPtr) &ForallQuantifier::createCopy,
/* exists = 48, */ (Base::FuncPtr) &ExistsQuantifier::createCopy,
/* ListConstr = 49, */ (Base::FuncPtr) &ListConstructor::createCopy,
/* SetConstr = 50, */ (Base::FuncPtr) &SetConstructor::createCopy,
/* MapConstr = 51, */ (Base::FuncPtr) &abstractError, // ops on maps not supported
/* TupleConstr = 52, */ (Base::FuncPtr) &TupleConstructor::createCopy,
/* ObjectConstr = 53, */ (Base::FuncPtr) &ObjectConstructor::createCopy,
/* QValConstr = 54, */ (Base::FuncPtr) &abstractError,
/* Identifier = 55, */ (Base::FuncPtr) &IdentifierExpression::createCopy,
/* UnresolvedIdentifier = 56, */ (Base::FuncPtr) &abstractError,
/* Type = 57, */ (Base::FuncPtr) &TypeExpression::createCopy,
/* TupleMapAccess = 58, */ (Base::FuncPtr) &TupleMapAccessExpression::createCopy,
/* Call = 59, */ (Base::FuncPtr) &CallExpression::createCopy,
/* Access = 60, */ (Base::FuncPtr) &AccessExpression::createCopy,
/* Primed = 61, */ (Base::FuncPtr) &abstractError,
/* Cast = 62, */ (Base::FuncPtr) &UnaryOperator::createCopy,
/* foldLR = 63, */ (Base::FuncPtr) &TernaryOperator::createCopy,
/* foldRL = 64, */ (Base::FuncPtr) &abstractError,
/* Value_Integer = 65, */ (Base::FuncPtr) &IntValueExpression::createCopy,
/* Value_Bool = 66, */ (Base::FuncPtr) &BoolValueExpression::createCopy,
/* Value_Reference = 67, */ (Base::FuncPtr) &RefValueExpression::createCopy
}
};


Expression* Expression::createVirtual(ExpressionKind k) {
return (std::uint8_t)k < EXPRESSIONKIND_NR_ITEMS ? ((ConstrPtr)s_exprVmt[0][(std::uint8_t)k])(k) : nullptr;
}

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

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

}
(5-5/20)