Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
TypeExpression.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <ast/Expression.h>
9#include <string>
10
11namespace cli {
12
13class TypeExpression final : public Expression {
14 std::unique_ptr < Expression > m_expression;
15
16public:
17 TypeExpression ( std::unique_ptr < Expression > expression ) : m_expression ( std::move ( expression ) ) {
18 }
19
20 std::shared_ptr < abstraction::Value > translateAndEval ( Environment & environment ) const override {
21 std::shared_ptr < abstraction::Value > translatedExpression = m_expression->translateAndEval ( environment );
22
23 std::string type;
24 if ( abstraction::TypeQualifiers::isConst ( translatedExpression->getTypeQualifiers ( ) ) )
25 type += "const ";
26 type += translatedExpression->getType ( );
27 if ( abstraction::TypeQualifiers::isRvalueRef ( translatedExpression->getTypeQualifiers ( ) ) )
28 type += " &&";
29 if ( abstraction::TypeQualifiers::isLvalueRef ( translatedExpression->getTypeQualifiers ( ) ) )
30 type += " &";
31
32 return std::make_shared < abstraction::ValueHolder < std::string > > ( std::move ( type ), true );
33 }
34
35};
36
37} /* namespace cli */
38
static constexpr bool isRvalueRef(TypeQualifierSet arg)
Definition: TypeQualifiers.hpp:43
static constexpr bool isConst(TypeQualifierSet arg)
Definition: TypeQualifiers.hpp:35
static constexpr bool isLvalueRef(TypeQualifierSet arg)
Definition: TypeQualifiers.hpp:47
Definition: Environment.h:29
Definition: Expression.h:14
Definition: TypeExpression.h:13
TypeExpression(std::unique_ptr< Expression > expression)
Definition: TypeExpression.h:17
std::shared_ptr< abstraction::Value > translateAndEval(Environment &environment) const override
Definition: TypeExpression.h:20
Definition: Arg.h:11
Definition: FordFulkerson.hpp:16