/** * * 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 namespace Ast { class TernaryOperator final : public Expression { protected: Expression* m_left; Expression* m_mid; Expression* m_right; IScope* m_definingScope; TernaryOperator(ExpressionKind kind): Expression(kind), m_left (nullptr), m_mid (nullptr), m_right(nullptr), m_definingScope (nullptr) {} TernaryOperator(const TernaryOperator& toCopy): Expression(toCopy), m_left (toCopy.m_left), m_mid (toCopy.m_mid), m_right(toCopy.m_right), m_definingScope (toCopy.m_definingScope) {} static TernaryOperator* create(ExpressionKind k){return new TernaryOperator(k);} static TernaryOperator* createCopy(const TernaryOperator& toCopy){return new TernaryOperator(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* left, Expression* mid, Expression* right, IScope* defScopeRef) { Expression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef); m_left = left; m_mid = mid; m_right = right; m_definingScope = defScopeRef; } Expression* left() {return m_left;}; Expression* mid() {return m_mid;}; Expression* right() {return m_right;}; IScope* definingScope() {return m_definingScope;}; void accept(IAstVisitor& visitor) override {visitor.visit(this);}; void setLeftChild(Expression* newExpression) {m_left = newExpression;}; void setMidChild(Expression* newExpression) {m_mid = newExpression;}; void setRightChild(Expression* newExpression) {m_right = newExpression;}; }; }