Project

General

Profile

root / trunk / compiler / cppAst / ast / expressions / TupleConstructor.hpp

1 7 krennw
/**
2
  *
3
  *                  OOAS Compiler - C++ AST
4
  *
5
  * Copyright 2015, AIT Austrian Institute of Technology.
6
  * All rights reserved.
7
  *
8
  * SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
9
  *
10
  * If you modify the file please update the list of contributors below to in-
11
  * clude your name. Please also stick to the coding convention of using TABs
12
  * to do the basic (block-level) indentation and spaces for anything after
13
  * that. (Enable the display of special chars and it should be pretty obvious
14
  * what this means.) Also, remove all trailing whitespace.
15
  *
16
  * Contributors:
17
  *               Willibald Krenn (AIT)
18
  *               Stephan Zimmerer (AIT)
19
  *               Christoph Czurda (AIT)
20
  *
21
  */
22 2 krennw
23
24
25
26
#pragma once
27
28
#include <ast/expressions/TypeConstructionExpression.hpp>
29
#include <ast/IAstVisitor.hpp>
30
#include <ast/identifiers/Identifier.hpp>
31
#include <deque>
32
33
namespace Ast {
34
35
class TupleConstructor final
36
        : public TypeConstructionExpression
37
{
38
protected:
39
        ExpressionList m_values;
40
        Identifier* m_tupleType;
41
        bool m_matcher;
42
43
        TupleConstructor():
44
                TypeConstructionExpression(ExpressionKind::TupleConstr),
45
                m_values(),
46
                m_tupleType(nullptr),
47
                m_matcher(false)
48
        {};
49
        TupleConstructor(const TupleConstructor &toCopy):
50
                TypeConstructionExpression(toCopy),
51
                m_values(toCopy.m_values),
52
                m_tupleType(toCopy.m_tupleType),
53
                m_matcher(toCopy.m_matcher)
54
        {};
55
56
        static TupleConstructor* create(ExpressionKind) {return new TupleConstructor();}
57
        static TupleConstructor* createCopy(const TupleConstructor& toCopy) {return new TupleConstructor(toCopy);}
58
public:
59
        friend class Ast;
60
        friend class Expression;
61
62
        void init(std::int32_t line, std::int32_t pos,
63
                        Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef,
64
                        ExpressionList* exprList, Identifier* tupleTypeId, bool isMatcher)
65
        {
66
                TypeConstructionExpression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
67
                m_values = std::move(*exprList);
68
                m_tupleType = tupleTypeId,
69
                m_matcher = isMatcher;
70
        }
71
72
        ExpressionList& values() {return m_values;}
73
        Identifier* tupleType() {return m_tupleType;};
74
        bool isMatcher() {return m_matcher;}
75
76
        void setIsMatcher(bool newVal) {m_matcher = newVal;};
77
        void accept(IAstVisitor& visitor) override {visitor.visit(this);};
78
        //void setTupleValues(ExpressionList& values) {m_values = values;};
79
};
80
}