/** * * 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 #include #include 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 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); }; }