Project

General

Profile

root / trunk / compiler / cppAst / ast / expressions / CallExpression.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/UnaryOperator.hpp>
29
#include <ast/IAstVisitor.hpp>
30
#include <deque>
31
#include <ast/IScope.hpp>
32
33
namespace Ast {
34
35
class CallExpression final
36
        : public UnaryOperator
37
{
38
private:
39
        ExpressionList m_arguments;
40
        IScope* m_callScope;
41
42
        CallExpression():
43
                UnaryOperator(ExpressionKind::Call),
44
                m_arguments (),
45
                m_callScope (nullptr)
46
        {};
47
        CallExpression(const CallExpression &toCopy):
48
                UnaryOperator(toCopy),
49
                m_arguments (toCopy.m_arguments),
50
                m_callScope (toCopy.m_callScope)
51
        {};
52
53
        static CallExpression* create(ExpressionKind) {return new CallExpression();}
54
        static CallExpression* createCopy(const CallExpression& toCopy) {return new CallExpression(toCopy);}
55
public:
56
        friend class Ast;
57
        friend class Expression;
58
59
        void init(std::int32_t line, std::int32_t pos,
60
                        Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef,
61
                        Expression* child, ExpressionList* argumentList, IScope* scopeRef)
62
        {
63
                UnaryOperator::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef,child);
64
                m_arguments = std::move(*argumentList);
65
                m_callScope = scopeRef;
66
        }
67
68
        ExpressionList& arguments() {return m_arguments;};
69
        IScope* scope() {return m_callScope;};
70
        void accept(IAstVisitor& visitor) override {visitor.visit(this);};
71
        //void setArguments(ExpressionList& newArgs) {m_arguments = newArgs;};
72
};
73
}