Project

General

Profile

« Previous | Next » 

Revision 2

Added by Willibald K. almost 10 years ago

initial import of ooasCompiler

View differences:

trunk/compiler/LICENSE
This is the BSD 3-Clause License.
Copyright (c) 2015, AIT Austrian Institute of Technology, and Graz University of Technology
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
trunk/compiler/cppAst/ast/expressions/ListConstructor.hpp
/**
*
* 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)
*
*/
#pragma once
#include <ast/expressions/TypeConstructionExpression.hpp>
#include <ast/IScope.hpp>
#include <deque>
#include <ast/SymbolTable.hpp>
#include <base/Exceptions.hpp>
#include <string>
#include <ast/IAstVisitor.hpp>
namespace Ast {
class ListConstructor final
: public TypeConstructionExpression
, public IScope
{
protected:
ExpressionList m_elements;
IScope* m_parentScope;
SymbolTable* m_comprehensionVars;
Expression* m_comprehension;
bool m_hasComprehension;
ListConstructor():
TypeConstructionExpression(ExpressionKind::ListConstr),
m_elements(),
m_parentScope(nullptr),
m_comprehensionVars(nullptr),
m_comprehension(nullptr),
m_hasComprehension(false)
{};
ListConstructor(const ListConstructor &toCopy):
TypeConstructionExpression(toCopy),
m_elements(toCopy.m_elements),
m_parentScope(toCopy.m_parentScope),
m_comprehensionVars(toCopy.m_comprehensionVars),
m_comprehension(toCopy.m_comprehension),
m_hasComprehension(toCopy.m_hasComprehension)
{};
static ListConstructor* create(ExpressionKind){return new ListConstructor();}
static ListConstructor* createCopy(const ListConstructor& toCopy){return new ListConstructor(toCopy);}
public:
friend class Ast;
friend class Expression;
void init(std::int32_t line, std::int32_t pos,
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef,
ExpressionList* exprList, SymbolTable *symTab, IScope* parentScope,
Expression* comprehension, bool hasComprehension)
{
TypeConstructionExpression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
m_elements = std::move(*exprList);
m_parentScope = parentScope;
m_comprehensionVars = symTab;
m_comprehension = comprehension;
m_hasComprehension = hasComprehension;
}
ExpressionList& elements() {return m_elements;};
Expression* comprehension() {return m_comprehension;};
bool hasComprehension() {return m_hasComprehension;};
SymbolTable* comprehensionVariables() {return m_comprehensionVars;};
void addElement(Expression* anElement) {m_elements.push_back(anElement);};
void setComprehension(Expression* comprehension) {m_comprehension = comprehension;};
void setHasComprehension(bool flag) {m_hasComprehension = flag;};
Identifier* resolveIdentifier(const std::string& aName) const override { return m_comprehensionVars->get(aName); };
IScope* getParentScope() const override {return m_parentScope;};
std::string getScopeName() const override {return "";}
void setParentScope(IScope* parentScope) override {m_parentScope = parentScope;};
void addIdentifier(Identifier* anIdentifier, void* ) override {m_comprehensionVars->addIdentifier(anIdentifier);};
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
// void setElements(std::deque<Expression*>& newElements) {};
IScope* asScope() final {return (IScope*) this;}
};
}
trunk/compiler/cppAst/ast/expressions/AccessExpression.hpp
/**
*
* 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)
*
*/
#pragma once
#include <ast/expressions/BinaryOperator.hpp>
#include <ast/IAstVisitor.hpp>
namespace Ast {
class AccessExpression final
: public BinaryOperator
{
protected:
AccessExpression():
BinaryOperator(ExpressionKind::Access)
{};
AccessExpression(const AccessExpression &toCopy):
BinaryOperator(toCopy)
{};
static AccessExpression* create(ExpressionKind){return new AccessExpression();}
static AccessExpression* createCopy(const AccessExpression& toCopy){return new AccessExpression(toCopy);}
public:
friend class Ast;
friend class Expression;
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
};
}
trunk/compiler/README
Object-Oriented Action System (OOAS) Compiler
=============================================
This directory contains the source code to the OOAS-Compiler that is used in
MoMuT::UML/OOAS. The compiler was originally written in C# at Graz University
of Technology and has subsequently been ported to Java at the AIT Austrian In-
stitute of Technology. See the LICENSE file for the exact terms the source is
distributed under.
Folder "licenses"
~~~~~~~~~~~~~~~~~~~~~
This folder contains information about the licenses of other open source
software the OOAS Compiler builds on.
Folder "ooasCompiler"
~~~~~~~~~~~~~~~~~~~~~
This folder contains the up-to-date version of the OOAS compiler as used in
MoMuT::UML/OOAS. It is a full Eclipse Kepler (Java) project, ready to im-
port.
Folder "ooasCompiler_tests"
~~~~~~~~~~~~~~~~~~~~~~~~~~~
This folder contains a small JUnit project and a few OOAS models to test.
Folder "cppAst"
~~~~~~~~~~~~~~~
This folder contains a C++ version of the AST classes including code to
de-serialize a serialized version of the AST. The de-/serialization code
relies on the Google Protocol Buffers library, see also the "serialization"
folder.
Please note that no self-compiling project is provided.
Folder "serialization"
~~~~~~~~~~~~~~~~~~~~~~
This folder contains the .proto files, which serve as input to the Google
Protocol Buffer Compiler.
Vienna, Graz, 30th March 2015
trunk/compiler/cppAst/ast/expressions/SetConstructor.hpp
/**
*
* 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)
*
*/
#pragma once
#include <ast/expressions/TypeConstructionExpression.hpp>
#include <ast/IScope.hpp>
#include <ast/expressions/Expression.hpp>
#include <ast/IAstVisitor.hpp>
#include <ast/SymbolTable.hpp>
#include <base/Exceptions.hpp>
#include <ast/identifiers/Identifier.hpp>
#include <deque>
namespace Ast {
class SetConstructor final
: public TypeConstructionExpression
, public IScope
{
protected:
ExpressionList m_items;
SymbolTable* m_comprehensionVars;
IScope* m_parentScope;
Expression* m_comprehension;
bool m_hasComprehension;
SetConstructor():
TypeConstructionExpression(ExpressionKind::SetConstr),
m_items (),
m_comprehensionVars (nullptr),
m_parentScope (nullptr),
m_comprehension (nullptr),
m_hasComprehension (false)
{};
SetConstructor(const SetConstructor &toCopy):
TypeConstructionExpression(toCopy),
m_items (toCopy.m_items),
m_comprehensionVars (toCopy.m_comprehensionVars),
m_parentScope (toCopy.m_parentScope),
m_comprehension (toCopy.m_comprehension),
m_hasComprehension (toCopy.m_hasComprehension)
{};
static SetConstructor* create(ExpressionKind) {return new SetConstructor();}
static SetConstructor* createCopy(const SetConstructor& toCopy) {return new SetConstructor(toCopy);}
public:
friend class Ast;
friend class Expression;
void init(std::int32_t line, std::int32_t pos,
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef,
ExpressionList* exprList, SymbolTable *symTab, IScope* parentScope,
Expression* comprehension, bool hasComprehension)
{
TypeConstructionExpression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
m_items = std::move(*exprList);
m_parentScope = parentScope;
m_comprehensionVars = symTab;
m_comprehension = comprehension;
m_hasComprehension = hasComprehension;
}
ExpressionList& items() {return m_items;}
Expression* comprehension() {return m_comprehension;}
bool hasComprehension() const {return m_hasComprehension;};
SymbolTable* comprehensionVariables() {return m_comprehensionVars;};
void addItem(Expression* anItem) {m_items.push_back(anItem);};
void setComprehension(Expression* anExpr) {m_comprehension = anExpr;};
void setHasComprehension(bool flag) {m_hasComprehension = flag;};
Identifier* resolveIdentifier(const string& aName) const override {return m_comprehensionVars->get(aName);};
IScope* getParentScope() const override {return m_parentScope;};
std::string getScopeName() const override {return "";}
void setParentScope(IScope* parentScope) override {m_parentScope = parentScope;};
void addIdentifier(Identifier* anIdentifier, void* ) override {m_comprehensionVars->addIdentifier(anIdentifier);};
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
//void setItems(ExpressionList& newItems) {m_items = newItems;};
IScope* asScope() final {return (IScope*) this;}
};
}
trunk/compiler/cppAst/ast/expressions/CallExpression.hpp
/**
*
* 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)
*
*/
#pragma once
#include <ast/expressions/UnaryOperator.hpp>
#include <ast/IAstVisitor.hpp>
#include <deque>
#include <ast/IScope.hpp>
namespace Ast {
class CallExpression final
: public UnaryOperator
{
private:
ExpressionList m_arguments;
IScope* m_callScope;
CallExpression():
UnaryOperator(ExpressionKind::Call),
m_arguments (),
m_callScope (nullptr)
{};
CallExpression(const CallExpression &toCopy):
UnaryOperator(toCopy),
m_arguments (toCopy.m_arguments),
m_callScope (toCopy.m_callScope)
{};
static CallExpression* create(ExpressionKind) {return new CallExpression();}
static CallExpression* createCopy(const CallExpression& toCopy) {return new CallExpression(toCopy);}
public:
friend class Ast;
friend class Expression;
void init(std::int32_t line, std::int32_t pos,
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef,
Expression* child, ExpressionList* argumentList, IScope* scopeRef)
{
UnaryOperator::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef,child);
m_arguments = std::move(*argumentList);
m_callScope = scopeRef;
}
ExpressionList& arguments() {return m_arguments;};
IScope* scope() {return m_callScope;};
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
//void setArguments(ExpressionList& newArgs) {m_arguments = newArgs;};
};
}
trunk/compiler/cppAst/ast/expressions/TupleMapAccessExpression.hpp
/**
*
* 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)
*
*/
#pragma once
#include <ast/expressions/UnaryOperator.hpp>
#include <ast/IAstVisitor.hpp>
namespace Ast {
class TupleMapAccessExpression final
: public UnaryOperator
{
protected:
Expression* m_argument;
TupleMapAccessExpression():
UnaryOperator(ExpressionKind::TupleMapAccess),
m_argument (nullptr)
{};
TupleMapAccessExpression(const TupleMapAccessExpression &toCopy):
UnaryOperator(toCopy),
m_argument (toCopy.m_argument)
{};
static TupleMapAccessExpression* create(ExpressionKind){return new TupleMapAccessExpression();}
static TupleMapAccessExpression* createCopy(const TupleMapAccessExpression& toCopy){return new TupleMapAccessExpression(toCopy);}
public:
friend class Ast;
friend class Expression;
void init(std::int32_t line, std::int32_t pos,
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef,
Expression* child, Expression* arg)
{
UnaryOperator::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef,child);
m_argument = arg;
}
Expression* argument() {return m_argument;};
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
void setArgument(Expression* newarg) {m_argument = newarg;};
};
}
trunk/compiler/cppAst/ast/Ast.cpp
/**
*
* 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)
*
*/
/*
* Ast.cpp
*
* Created on: Jan 27, 2014
* Author: willibald
*/
#include "Ast.hpp"
#include <ast/identifiers/TypeIdentifier.hpp>
#include <ast/identifiers/EnumIdentifier.hpp>
#include <ast/identifiers/AttributeIdentifier.hpp>
#include <ast/identifiers/LocalVariableIdentifier.hpp>
#include <ast/identifiers/ParameterIdentifier.hpp>
#include <ast/identifiers/ExpressionVariableIdentifier.hpp>
#include <ast/identifiers/MethodIdentifier.hpp>
#include <ast/identifiers/NamedActionIdentifier.hpp>
#include <ast/identifiers/Module.hpp>
#include <ast/identifiers/ConstantIdentifier.hpp>
#include <ast/types/IntType.hpp>
#include <ast/types/BoolType.hpp>
#include <ast/types/EnumType.hpp>
#include <ast/types/ValuedEnumType.hpp>
#include <ast/types/ListType.hpp>
#include <ast/types/TupleType.hpp>
#include <ast/types/NullType.hpp>
#include <ast/types/FunctionType.hpp>
#include <ast/types/ActionSystemType.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/expressions/TernaryOperator.hpp>
#include <ast/expressions/BinaryOperator.hpp>
#include <ast/expressions/UnaryOperator.hpp>
#include <ast/expressions/ExistsQuantifier.hpp>
#include <ast/expressions/ForallQuantifier.hpp>
#include <ast/expressions/ListConstructor.hpp>
#include <ast/expressions/SetConstructor.hpp>
#include <ast/expressions/TupleConstructor.hpp>
#include <ast/expressions/ObjectConstructor.hpp>
#include <ast/expressions/IdentifierExpression.hpp>
#include <ast/expressions/ValueExpression.hpp>
#include <ast/expressions/TypeExpression.hpp>
#include <ast/expressions/TupleMapAccessExpression.hpp>
#include <ast/expressions/CallExpression.hpp>
#include <ast/expressions/AccessExpression.hpp>
#include <ast/identifiers/IdentifierBlock.hpp>
#include <ast/identifiers/MainModule.hpp>
#include <ast/types/PointerType.hpp>
#include "DeepCloneVisitor.hpp"
#include <CallContext.hpp>
#include <base/CdtFixes.hpp>
#include <cassert>
namespace Ast {
Base::TiresiasObject* Ast::takeOwnership(Base::TiresiasObject* obj) {
m_allocatedAstObjects.push_back(obj);
return obj;
}
SymbolTable* Ast::createSymbolTable() {
return (SymbolTable*) takeOwnership(new SymbolTable());
}
SymbolTable* Ast::createSymbolTable(const SymbolTable& toCopy) {
return (SymbolTable*) takeOwnership(new SymbolTable(toCopy));
}
// Identifiers
Identifier* Ast::createIdentifier(IdentifierKind t) {
Identifier* result = (Identifier*) takeOwnership(Identifier::createVirtual(t));
assert(result == nullptr || result->kind() == t);
return result;
}
Identifier* Ast::createIdentifier(const Identifier& toCopy) {
Identifier* result = (Identifier*) takeOwnership(Identifier::createVirtual(toCopy));
assert(result == nullptr || result->kind() == toCopy.kind());
return result;
}
ActionSystemInstance* Ast::createActionSystemInstance(){
return (ActionSystemInstance*) takeOwnership(new ActionSystemInstance());
}
ActionSystemInstance* Ast::createActionSystemInstance(const ActionSystemInstance& toCopy) {
return (ActionSystemInstance*) takeOwnership(new ActionSystemInstance(toCopy));
}
IdentifierList* Ast::createIdentifierList() {
return (IdentifierList*) takeOwnership(new IdentifierList());
};
IdentifierList* Ast::createIdentifierList(const IdentifierList& toCopy) {
return (IdentifierList*) takeOwnership(new IdentifierList(toCopy));
}
ParameterList* Ast::createParameterList() {
return (ParameterList*) takeOwnership(new ParameterList());
}
ParameterList* Ast::createParameterList(const ParameterList& toCopy) {
return (ParameterList*) takeOwnership(new ParameterList(toCopy));
}
ActionSystemInstanceList* Ast::createActionSystemInstanceList() {
return (ActionSystemInstanceList*) takeOwnership(new ActionSystemInstanceList());
}
ActionSystemInstanceList* Ast::createActionSystemInstanceList(const ActionSystemInstanceList& toCopy) {
return (ActionSystemInstanceList*) takeOwnership(new ActionSystemInstanceList(toCopy));
}
// Types
Type* Ast::createType(TypeKind t) {
Type* result = (Type*)takeOwnership(Type::createVirtual(t));
assert(result == nullptr || result->kind() == t);
return result;
}
Type* Ast::createType(const Type& toCopy) {
Type* result = (Type*)takeOwnership(Type::createVirtual(toCopy));
assert(result == nullptr || result->kind() == toCopy.kind());
return result;
}
TypeList* Ast::createTypeList() {
return (TypeList*) takeOwnership(new TypeList());
}
TypeList* Ast::createTypeList(const TypeList& toCopy) {
return (TypeList*) takeOwnership(new TypeList(toCopy));
}
// Statements
Statement* Ast::createStatement(StatementKind t) {
Statement* result = (Statement*) takeOwnership(Statement::createVirtual(t));
assert(result == nullptr || result->kind() == t);
return result;
}
Statement* Ast::createStatement(const Statement& toCopy) {
Statement* result = (Statement*) takeOwnership(Statement::createVirtual(toCopy));
assert(result == nullptr || result->kind() == toCopy.kind());
return result;
}
Statement* Ast::deepCopyStatement(Statement* toCopy) {
Statement* result = createStatement(*toCopy);
DeepCloneVisitor cloner (m_context, this);
result->accept(cloner);
return result;
}
StatementList* Ast::createStatementList() {
return (StatementList*) takeOwnership( new StatementList());
};
StatementList* Ast::createStatementList(const StatementList& toCopy) {
return (StatementList*) takeOwnership( new StatementList(toCopy));
}
// Expressions
Expression* Ast::createExpression(ExpressionKind t) {
Expression* result = (Expression*) takeOwnership(Expression::createVirtual(t));
assert(result == nullptr || result->kind() == t);
return result;
}
Expression* Ast::createExpression(const Expression& toCopy) {
Expression* result = (Expression*) takeOwnership(Expression::createVirtual(toCopy));
assert(result == nullptr || result->kind() == toCopy.kind());
return result;
}
Expression* Ast::deepCopyExpression(Expression* toCopy) {
Expression* result = createExpression(*toCopy);
DeepCloneVisitor cloner (m_context, this);
result->accept(cloner);
return result;
}
ExpressionList* Ast::createExpressionList(){
return (ExpressionList*) takeOwnership(new ExpressionList());
};
ExpressionList* Ast::createExpressionList(const ExpressionList& toCopy) {
return (ExpressionList*) takeOwnership(new ExpressionList(toCopy));
}
Ast::Ast(CallContext* context):
m_context (context),
m_allocatedAstObjects()
{}
Ast::~Ast() {
for (auto& o: m_allocatedAstObjects)
delete o;
}
} /* namespace Ast */
trunk/compiler/cppAst/ast/expressions/Expression.cpp
/**
*
* 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();
};
}
trunk/compiler/cppAst/ast/expressions/UnaryOperator.hpp
/**
*
* 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)
*
*/
#pragma once
#include <ast/expressions/Expression.hpp>
#include <ast/IAstVisitor.hpp>
namespace Ast {
class UnaryOperator
: public Expression
{
protected:
Expression* m_child;
UnaryOperator(ExpressionKind kind):
Expression(kind),
m_child(nullptr)
{};
UnaryOperator(const UnaryOperator& toCopy):
Expression(toCopy),
m_child(toCopy.m_child)
{};
static UnaryOperator* create(ExpressionKind k) {return new UnaryOperator(k);}
static UnaryOperator* createCopy(const UnaryOperator& toCopy) {return new UnaryOperator(toCopy);}
public:
friend class Ast;
friend class Expression;
void init(std::int32_t line, std::int32_t pos,
Type* typeRef,IdentifierList* callTargetsIdentifierListRef,
SymbolTable* symbTabRef, Expression* child)
{
Expression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
m_child = child;
}
Expression* child() {return m_child;};
void setChild(Expression* child) {m_child = child;};
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
};
}
trunk/compiler/cppAst/ast/expressions/ForallQuantifier.hpp
/**
*
* 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)
*
*/
#pragma once
#include <ast/expressions/Quantifier.hpp>
#include <ast/IAstVisitor.hpp>
namespace Ast {
class ForallQuantifier final
: public Quantifier
{
protected:
ForallQuantifier():
Quantifier(ExpressionKind::forall)
{};
ForallQuantifier(const ForallQuantifier& toCopy):
Quantifier(toCopy)
{};
static ForallQuantifier* create(ExpressionKind) {return new ForallQuantifier();};
static ForallQuantifier* createCopy(const ForallQuantifier& toCopy) {return new ForallQuantifier(toCopy);};
public:
friend class Ast;
friend class Expression;
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
};
}
trunk/compiler/cppAst/ast/Ast.hpp
/**
*
* 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)
*
*/
#pragma once
#include <cstdint>
#include <deque>
#include <base/TiresiasObject.hpp>
class CallContext;
namespace Ast {
/**
* Forward declarations of the AST classes
*/
class TypeIdentifier;
class EnumIdentifier;
//class ValuedEnumIdentifier;
class AttributeIdentifier;
class LocalVariableIdentifier;
class ParameterIdentifier;
class ExpressionVariableIdentifier;
class MethodIdentifier;
class NamedActionIdentifier;
class Module;
class ConstantIdentifier;
class IntType;
class BoolType;
class EnumType;
class ListType;
class TupleType;
class NullType;
class FunctionType;
class ActionSystemType;
class GuardedCommand;
class Call;
class Assignment;
class SeqBlock;
class NondetBlock;
class PrioBlock;
class Skip;
class Break;
class Abort;
class TernaryOperator;
class BinaryOperator;
class UnaryOperator;
class ExistsQuantifier;
class ForallQuantifier;
class ListConstructor;
class SetConstructor;
class TupleConstructor;
class ObjectConstructor;
class IdentifierExpression;
class BoolValueExpression;
class IntValueExpression;
class RefValueExpression;
class TypeExpression;
class TupleMapAccessExpression;
class CallExpression;
class AccessExpression;
class UnspecIdentifierBlock;
class SeqIdentifierBlock;
class NondetIdentifierBlock;
class PrioIdentifierBlock;
class MainModule;
class PointerType;
class ActionSystemInstance;
class ValuedEnumType;
class ExpressionList;
class StatementList;
class IdentifierList;
class ParameterList;
class TypeList;
class ActionSystemInstanceList;
enum class ExpressionKind: std::uint8_t;
enum class TypeKind : std::uint8_t;
enum class StatementKind: std::uint8_t;
enum class IdentifierKind: std::uint8_t;
class SymbolTable;
class Type;
class Statement;
class Identifier;
class Expression;
/**
* Facade
*/
class Ast final {
private:
CallContext* m_context;
/* List of owned AST objects */
std::deque<Base::TiresiasObject*> m_allocatedAstObjects;
Base::TiresiasObject* takeOwnership(Base::TiresiasObject* obj);
public:
Ast(CallContext* context);
~Ast();
// Constructors: All the objects created are owned by this AST. IOW once
// this object is gone, all the created elements as well.
// ALL the copy constructors will do a shallow copy. Use the clone visitor to get a deep clone.
Type* createType(TypeKind t);
Type* createType(const Type& toCopy);
Statement* createStatement(StatementKind t); // new, empty statement
Statement* createStatement(const Statement& toCopy); // shallow copy statement
Statement* deepCopyStatement(Statement* toCopy); // deep copy statement
Identifier* createIdentifier(IdentifierKind t);
Identifier* createIdentifier(const Identifier& toCopy);
Expression* createExpression(ExpressionKind t); // new, empty expression
Expression* createExpression(const Expression& toCopy); // shallow copy expression
Expression* deepCopyExpression(Expression* toCopy); // deep copy expression
ActionSystemInstance* createActionSystemInstance();
ActionSystemInstance* createActionSystemInstance(const ActionSystemInstance& toCopy);
ExpressionList* createExpressionList();
ExpressionList* createExpressionList(const ExpressionList& toCopy);
IdentifierList* createIdentifierList();
IdentifierList* createIdentifierList(const IdentifierList& toCopy);
StatementList* createStatementList();
StatementList* createStatementList(const StatementList& toCopy);
ParameterList* createParameterList();
ParameterList* createParameterList(const ParameterList& toCopy);
TypeList* createTypeList();
TypeList* createTypeList(const TypeList& toCopy);
ActionSystemInstanceList* createActionSystemInstanceList();
ActionSystemInstanceList* createActionSystemInstanceList(const ActionSystemInstanceList& toCopy);
SymbolTable* createSymbolTable();
SymbolTable* createSymbolTable(const SymbolTable& toCopy);
};
}
trunk/compiler/cppAst/ast/identifiers/ConstantIdentifier.hpp
/**
*
* 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)
*
*/
#pragma once
#include <ast/identifiers/ValueIdentifier.hpp>
#include <ast/expressions/Expression.hpp>
#include <ast/IAstVisitor.hpp>
namespace Ast {
class ConstantIdentifier final
: public ValueIdentifier
{
protected:
Expression* m_value;
ConstantIdentifier():
ValueIdentifier(IdentifierKind::Constant),
m_value (nullptr)
{}
ConstantIdentifier(const ConstantIdentifier& toCopy) :
ValueIdentifier(toCopy),
m_value (toCopy.m_value)
{}
static ConstantIdentifier* create() {return new ConstantIdentifier();}
static ConstantIdentifier* createCopy(const ConstantIdentifier& toCopy) {return new ConstantIdentifier(toCopy);}
public:
friend class Ast;
friend class Identifier;
void init (std::int32_t line, std::int32_t col, const char* text,
IScope* scopeRef, Type* typeRef, Expression* valueRef)
{
ValueIdentifier::init(line, col, text, scopeRef, typeRef);
m_value = valueRef;
}
Expression* value() const {return m_value;};
void setValue(Expression* aValue) {m_value = aValue;};
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
};
}
trunk/compiler/cppAst/ast/AstAnnotation.hpp
/**
*
* 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)
*
*/
#pragma once
#include <deque>
namespace Ast {
class AstElement; // forward
enum class AstAnnotationEnum: std::uint8_t {
mutation, // one mutation
list // list of annotations
};
class AstAnnotation {
protected:
const AstAnnotationEnum m_annotationType;
AstAnnotation(AstAnnotationEnum annotationType):
m_annotationType(annotationType)
{}
public:
virtual ~AstAnnotation(){}
AstAnnotationEnum getAnnotationType() {return m_annotationType;}
};
class AstAnnotationList final: public AstAnnotation {
public:
std::deque<AstAnnotation> m_annotationList;
AstAnnotationList():
AstAnnotation(AstAnnotationEnum::list),
m_annotationList()
{}
};
class MutationAnnotation final: public AstAnnotation {
public:
const std::uint32_t m_mutationID; // all mutation annotations with the same number form one mutant-AST
const AstElement* m_replacement; // replacement AST, NOT owned
MutationAnnotation(std::uint32_t mutationID, AstElement* mutatedElement) :
AstAnnotation(AstAnnotationEnum::mutation),
m_mutationID (mutationID),
m_replacement(mutatedElement)
{}
};
} // namespace
trunk/compiler/cppAst/ast/expressions/LeafExpression.hpp
/**
*
* 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)
*
*/
#pragma once
#include <ast/expressions/Expression.hpp>
namespace Ast {
enum class LeafTypeEnum {
unset = 0,
_bool = 1,
integer = 2,
real = 3,
chr = 4,
qval = 5,
reference = 6,
identifier = 7,
type = 8,
complex = 9
};
class LeafExpression
: public Expression
{
protected:
LeafTypeEnum m_valueType;
LeafExpression(LeafTypeEnum lt, ExpressionKind kind):
Expression(kind),
m_valueType (lt)
{};
LeafExpression(const LeafExpression &toCopy):
Expression(toCopy),
m_valueType (toCopy.m_valueType)
{};
public:
~LeafExpression() override {};
LeafTypeEnum valueType() const {return m_valueType;};
};
}
trunk/compiler/cppAst/ast/identifiers/FunctionIdentifier.hpp
/**
*
* 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)
*
*/
#pragma once
#include <ast/identifiers/Scope.hpp>
#include <ast/statements/Block.hpp>
#include <ast/identifiers/ParameterIdentifier.hpp>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff