root/trunk/compiler/cppAst/ast/expressions/IdentifierExpression.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/LeafExpression.hpp>
|
|||
#include <ast/identifiers/Identifier.hpp>
|
|||
namespace Ast {
|
|||
class IdentifierExpression
|
|||
: public LeafExpression
|
|||
{
|
|||
protected:
|
|||
bool m_self;
|
|||
Identifier* m_identifier;
|
|||
IdentifierExpression():
|
|||
LeafExpression(LeafTypeEnum::identifier, ExpressionKind::Identifier),
|
|||
m_self (false),
|
|||
m_identifier (nullptr)
|
|||
{};
|
|||
IdentifierExpression(const IdentifierExpression &toCopy):
|
|||
LeafExpression(toCopy),
|
|||
m_self (toCopy.m_self),
|
|||
m_identifier (toCopy.m_identifier)
|
|||
{};
|
|||
static IdentifierExpression* create(ExpressionKind){return new IdentifierExpression();}
|
|||
static IdentifierExpression* createCopy(const IdentifierExpression& toCopy) {return new IdentifierExpression(toCopy);}
|
|||
public:
|
|||
friend class Ast;
|
|||
friend class Expression;
|
|||
void init(std::int32_t line, std::int32_t pos,
|
|||
Type* typeRef,IdentifierList* callTargetsIdentifierListRef,
|
|||
SymbolTable* symbTabRef, Identifier* identifierRef, bool isSelf)
|
|||
{
|
|||
LeafExpression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
|
|||
m_identifier = identifierRef;
|
|||
m_self = isSelf;
|
|||
}
|
|||
Identifier* identifier() {return m_identifier;};
|
|||
bool isSelf() const {return m_self;};
|
|||
void setIsSelf(bool newValue) {m_self = newValue;};
|
|||
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
|
|||
void setIdentifier(Identifier* newIdentifier) {m_identifier = newIdentifier;};
|
|||
};
|
|||
}
|