root/trunk/compiler/cppAst/ast/expressions/ObjectConstructor.hpp
7 | krennw | /**
|
|
*
|
|||
* 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)
|
|||
*
|
|||
*/
|
|||
2 | krennw | ||
#pragma once
|
|||
#include <ast/expressions/TypeConstructionExpression.hpp>
|
|||
#include <ast/IAstVisitor.hpp>
|
|||
#include <ast/types/ActionSystemType.hpp>
|
|||
#include <deque>
|
|||
#include <cstdint>
|
|||
#include <string>
|
|||
namespace Ast {
|
|||
class ObjectConstructor final
|
|||
: public TypeConstructionExpression
|
|||
{
|
|||
protected:
|
|||
/*std::int32_t*/ ActionSystemInstanceList::size_type m_currentInstance;
|
|||
ActionSystemInstanceList m_instances;
|
|||
std::string m_fixedObjectName;
|
|||
ObjectConstructor():
|
|||
TypeConstructionExpression(ExpressionKind::ObjectConstr),
|
|||
m_currentInstance (0),
|
|||
m_instances(),
|
|||
m_fixedObjectName ("")
|
|||
{};
|
|||
ObjectConstructor(const ObjectConstructor &toCopy):
|
|||
TypeConstructionExpression(toCopy),
|
|||
m_currentInstance(toCopy.m_currentInstance),
|
|||
m_instances(toCopy.m_instances),
|
|||
m_fixedObjectName (toCopy.m_fixedObjectName)
|
|||
{};
|
|||
static ObjectConstructor* create(ExpressionKind){return new ObjectConstructor();}
|
|||
static ObjectConstructor* createCopy(const ObjectConstructor& toCopy){return new ObjectConstructor(toCopy);}
|
|||
public:
|
|||
friend class Ast;
|
|||
friend class Expression;
|
|||
void init(std::int32_t line, std::int32_t pos,
|
|||
Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef,
|
|||
ActionSystemInstanceList* instanceList, std::uint32_t currentInstance, const char* name)
|
|||
{
|
|||
TypeConstructionExpression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
|
|||
m_instances = std::move(*instanceList);
|
|||
m_currentInstance = currentInstance;
|
|||
m_fixedObjectName = name == nullptr ? "" : name;
|
|||
}
|
|||
std::uint32_t currentInstance() const {return (std::uint32_t) m_currentInstance;};
|
|||
ActionSystemInstanceList& instances() {return m_instances;};
|
|||
std::string givenObjectName() {return m_fixedObjectName;};
|
|||
void resetCurrentInstance() {m_currentInstance = 0;};
|
|||
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
|
|||
void addInstance(ActionSystemInstance* anInstance) {m_instances.push_back(anInstance);};
|
|||
ActionSystemInstance* GetNextInstance() {
|
|||
ActionSystemInstance* result = m_instances[m_currentInstance];
|
|||
m_currentInstance++;
|
|||
return result;
|
|||
};
|
|||
};
|
|||
}
|